mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 12:55:57 +00:00
Compare commits
No files matched your search
@@ -28,10 +28,10 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
- In-game settings menu (F1) and performance overlay (F10)
|
||||
- Play time across runs on the Game tab of the settings menu, kept in `playtime.txt` next to the saves
|
||||
- Discord Rich Presence ("Playing TotK Recomp" with the play time), off by default, own application id supported
|
||||
- Setup and in-game menu in English, Russian, Brazilian Portuguese and Simplified Chinese
|
||||
- Setup in 11 languages, in-game menu in 4 ([Languages](#languages))
|
||||
- Keyboard, mouse and gamepad with remapping, rumble and gyro
|
||||
- Stereo or 5.1 surround sound output
|
||||
- Xbox button prompts: LB, RB, LT, RT, Menu and View, and A, B, X and Y as labelled on the button to press, with either button layout
|
||||
- Xbox and PlayStation button prompts: Xbox's LB, RB, LT, RT, Menu, View and A, B, X, Y, or PlayStation's ○ × △ □, L1, R1, L2, R2, Options and Share, as labelled on the button to press, with either button layout
|
||||
- Shaders prepared at install instead of during play
|
||||
- Mods made for emulators: unpack a mod into the `mods` folder next to `totk.exe`; switch and order them in the menu. RomFS
|
||||
mods, TKMM's merged output and ExeFS code patches (`.ips`, `.pchtxt`) work; the game rebuilds itself for code patches
|
||||
@@ -39,6 +39,30 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
with the HDPacks.com 4K Texture Pack v1.0 on 1.4.3 and 1.2.1; other packs come with no guarantee
|
||||
- Atmosphère cheats: put a cheat file into a mod and switch its cheats in the menu ([docs/cheats.md](docs/cheats.md))
|
||||
|
||||
## Languages
|
||||
|
||||
The game keeps the text and voices of every language it shipped with. The port's own setup and in-game menu (F1) come
|
||||
in these; both follow the Windows display language, and the menu has its own choice on its Menu tab. A Traditional
|
||||
Chinese Windows gets the Simplified Chinese setup.
|
||||
|
||||
| Language | Setup | In-game menu |
|
||||
|---|:---:|:---:|
|
||||
| English | ✅ | ✅ |
|
||||
| Русский | ✅ | ✅ |
|
||||
| Português (Brasil) | ✅ | ✅ |
|
||||
| 简体中文 | ✅ | ✅ |
|
||||
| Deutsch | ✅ | English |
|
||||
| Français | ✅ | English |
|
||||
| Español | ✅ | English |
|
||||
| Italiano | ✅ | English |
|
||||
| Nederlands | ✅ | English |
|
||||
| 日本語 | ✅ | English |
|
||||
| 한국어 | ✅ | English |
|
||||
|
||||
Spotted a clumsy phrase, or want your language added? The setup texts are in `installer/text/<language>.json`, the
|
||||
menu texts in `runtime/ui_text.c`; open an issue or a pull request ([CONTRIBUTING.md](CONTRIBUTING.md)). Fixes from
|
||||
native speakers are welcome.
|
||||
|
||||
## Planned
|
||||
|
||||
- VRR
|
||||
|
||||
@@ -30,7 +30,10 @@ Code copied or adapted from another project is listed here with its source, the
|
||||
| SDL 3.4.20, dynamic link, `SDL3.dll` copied next to `totk.exe`. Developer builds use the MSYS2 build (`mingw-w64-ucrt-x86_64-sdl3`, which imports `libiconv-2.dll`, LGPL-2.1, unmodified, copied beside it); the installer release ships the upstream release `SDL3-3.4.20-win32-x64.zip`, which imports no libiconv | https://libsdl.org, Copyright (c) 1997-2026 Sam Lantinga | zlib | `runtime/input_win.c` (gamepad input, rumble, gyro and accelerometer) |
|
||||
| libopus (MSYS2 `mingw-w64-ucrt-x86_64-opus`), dynamic link, `libopus-0.dll` copied next to `totk.exe` | https://opus-codec.org, Copyright (c) 2001-2023 Xiph.Org, Skype Limited, Octasic, Jean-Marc Valin, Timothy B. Terriberry, CSIRO, Gregory Maxwell, Mark Borgerding, Erik de Castro Lopo, Mozilla, Amazon | BSD-3-Clause | `runtime/ov_media.c` (nn::codec hardware Opus decoder) |
|
||||
| Dear ImGui 1.91.9 (core and Vulkan back end, unmodified), as vendored by LAS Recomp | https://github.com/ocornut/imgui, via https://github.com/peiikai/LASRecomp @ `da35b83a9611d046a9a681aae668d7085954d37f` (`third_party/imgui/`), Copyright (c) 2014-2025 Omar Cornut | MIT | `runtime/third_party/imgui/` (compiled into `totk.exe` for the in-game menu, `runtime/ui/`) |
|
||||
| AMD FidelityFX SDK 1.1.4 subset (public host and shader headers, frame interpolation, optical flow and FSR 3 upscaler components, the Vulkan backend `ffx_vk.cpp` and its GLSL shaders, shared helpers), with four marked Savage Wind patches (64-byte aligned backend scratch arrays, doubled context size where `wchar_t` is 4 bytes, all six descriptor pool sizes, the upscaler's Catmull-Rom history reprojection) and one of ours (the upscaler's luma history declared `rgba16f`) | https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/tree/v1.1.4, Copyright (C) 2024 Advanced Micro Devices, Inc., via https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`third_party/FidelityFX/`) | MIT | `runtime/third_party/FidelityFX/` (compiled into `totk.exe`; licence text in `runtime/third_party/FidelityFX/LICENSE.txt`, shipped as `licenses/FidelityFX-SDK-LICENSE.txt`) |
|
||||
| SavageWindRecomp FidelityFX build support, frame generation and FSR 3 upscaler set-up: the SDK-to-clang compat header, the glslang SPIR-V shader generator with its resource reflection and its FSR 3 upscaler permutations, the blob lookup and the backend and context creation of `runtime/nvn/vulkan/framegen.cpp`, the upscaler context with its shared images and the dispatch parameters of `runtime/nvn/vulkan/fsr3.cpp`, the pair's present spacing of `runtime/nvn/vulkan/device.c` `present_wait_turn` | https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`third_party/FidelityFX/ffx_compat.h`, `tools/ffx_shaders.py`, `runtime/nvn/vulkan/framegen.cpp`, `runtime/nvn/vulkan/fsr3.cpp`, `runtime/nvn/vulkan/device.c`) | MIT | `runtime/third_party/FidelityFX/ffx_compat.h`, `runtime/third_party/FidelityFX/spirv/ffx_shaders_vk.h` and `ffx_fsr3upscaler_vk.h` (output of `tools/ffx_shaders.py`), `tools/ffx_shaders.py`, `runtime/vk_fg.cpp`, `runtime/vk_fsr3.cpp`, `runtime/vk_backend.c` (`present_pair`) |
|
||||
| SavageWindRecomp settings menu: two-pane option rows (row look, left / right stepping, hold speed-up, description pane), the menu style and tab bar | https://github.com/Revivedx/SavageWindRecomp @ `575ad88e02f9a89a9a885d90039d48af33c982f4` (`runtime/ui/option_rows.mm`, `runtime/ui/menu.mm`), Copyright (c) 2026 Revivedx and the Savage Wind Recomp contributors, Copyright (c) 2026 Peiikai | MIT | `runtime/ui/option_rows.cpp`, `runtime/ui/option_rows.h`, `runtime/ui/menu.cpp` |
|
||||
| SavageWindRecomp GPU overlap one-off readback rule: a target not read back within the last 16 frames (64-entry table) makes the frame wait wait up to the value that rendered it | https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`runtime/nvn/vulkan/exec.c` readback_schedule, renderer_wait_seq), Copyright (c) 2026 Revivedx and the Savage Wind Recomp contributors, Copyright (c) 2026 Peiikai | MIT | `runtime/vk_texture.c` (oneoff_streaming, vk_texture_oneshot) |
|
||||
| SavageWindRecomp descriptor sets allocated in growing batches per layout | https://github.com/Revivedx/SavageWindRecomp @ `740b18025fe11ba03c117dbb56668db304b5043e` (`runtime/nvn/vulkan/exec.c` vk_alloc_set), Copyright (c) 2026 Revivedx and the Savage Wind Recomp contributors, Copyright (c) 2026 Peiikai | MIT | `runtime/vk_exec_draw.c` (alloc_set_batched) |
|
||||
| SavageWindRecomp performance overlay: the frame ring and its one-second summary, the NVML calls, the sampling loop, the full panel's layout | https://github.com/Revivedx/SavageWindRecomp @ `575ad88e02f9a89a9a885d90039d48af33c982f4` (`runtime/perfmon.c`, `runtime/perfmon.h`, `perf_overlay_draw` in `runtime/ui/menu.mm`), Copyright (c) 2026 Revivedx and the Savage Wind Recomp contributors, Copyright (c) 2026 Peiikai | MIT | `runtime/perfmon.c`, `runtime/perfmon.h`, `runtime/ui/menu.cpp` |
|
||||
| Roboto Medium font (Dear ImGui's `misc/fonts/Roboto-Medium.ttf`, unmodified) | https://fonts.google.com/specimen/Roboto, via https://github.com/peiikai/LASRecomp @ `da35b83a9611d046a9a681aae668d7085954d37f` (`third_party/imgui/misc/fonts/`), Copyright 2011 Google Inc. | Apache-2.0 | `runtime/ui/fonts/Roboto-Medium.ttf` (licence text in `runtime/ui/fonts/LICENSE-Roboto.txt`), embedded by `runtime/ui/menu.cpp` |
|
||||
@@ -73,6 +76,7 @@ These tools run on the developer's or player's machine during the build. They ar
|
||||
| Tcl/Tk 9.0.4, rebuilt with Xft for the Linux installer | https://github.com/tcltk/tcl and https://github.com/tcltk/tk, tag `core-9-0-4`; archives pinned by SHA-256 in `tools/make_release_linux.py` | Tcl/Tk licence (BSD-style) | `python/lib/`; licence texts in `licenses/tcl-license.terms` and `licenses/tk-license.terms` |
|
||||
| libXft 2 and libXrender 1, the sniper SDK sysroot's shared libraries, bundled beside the Xft Tk of the Linux installer; their Debian `copyright` files go into `licenses/` | https://repo.steampowered.com/steamrt-images-sniper/snapshots/3.0.20261021.266025/ | HPND (MIT-style) | `python/lib/`; `licenses/libXft-copyright.txt`, `licenses/libXrender-copyright.txt` |
|
||||
| CPython 3.14.9 embeddable package, with `tkinter` and Tcl/Tk 9.0.4 taken from the python.org 3.14.9 installer's component MSI (unpacked, never run); includes `vcruntime140*.dll` (Microsoft, redistributable with Python), OpenSSL, libffi, SQLite, zlib, libtommath | https://www.python.org/downloads/release/python-3149/ | PSF-2.0 (Tcl/Tk: Tcl/Tk licence, BSD-style) | `python/` |
|
||||
| Sun Valley ttk theme (sv-ttk 2.6.1): the light and dark themes, their sprite sheets and fonts, the look of the setup window | https://github.com/rdbende/Sun-Valley-ttk-theme @ `cefdf5d383073f29f04cb7254e24e195d8bda6a2` (tag v2.6.1, `sv_ttk/sv.tcl`, `sv_ttk/theme/`), Copyright (c) rdbende | MIT | `installer/vendor/sv_ttk/` (unmodified, licence in `installer/vendor/sv_ttk/LICENSE`), loaded by `installer/gui.py` use_sun_valley |
|
||||
| numpy 2.5.4 (with its bundled OpenBLAS), lz4 4.4.5, cryptography 50.0.2 (with its bundled OpenSSL), fontTools 4.68.0, cffi 2.1.1, pycparser 3.11 | PyPI binary wheels, pins in `tools/requirements-installer.txt` | BSD-3-Clause; lz4 BSD-3-Clause; cryptography Apache-2.0 OR BSD-3-Clause; fontTools MIT; cffi MIT; pycparser BSD-3-Clause | `python/Lib/site-packages/` |
|
||||
| llvm-mingw 20261020 (LLVM/Clang/LLD 23, mingw-w64, libc++, libunwind, compiler-rt), x86_64 subset | https://github.com/mstorsjo/llvm-mingw/releases/tag/20261020 | Apache-2.0 with LLVM exception; mingw-w64 ZPL-2.1/BSD/public domain; libc++ and libunwind Apache-2.0 with LLVM exception and MIT/UIUC; winpthreads MIT | `llvm/` |
|
||||
| SDL 3.4.20 upstream Windows release (`SDL3.dll`) and mingw development package (headers, `libSDL3.dll.a`) | https://github.com/libsdl-org/SDL/releases/tag/release-3.4.20 | zlib | `bin/SDL3.dll`, `runtime/deps/` |
|
||||
|
||||
@@ -53,6 +53,7 @@ scene you expected. Title menus on a slow boot eat presses, and runs of one scri
|
||||
| every render pass of one frame | `TOTK_DUMP=<frame>` and `TOTK_DUMP_DIR`: a PNG per pass target plus `passes.txt` (draws, bound textures with swizzles, storage buffers, copies, clears) and `images.txt`; `TOTK_DUMP_BUF` adds a guest buffer |
|
||||
| Vulkan misuse | `TOTK_VK_VALIDATION=1` (needs the Vulkan SDK), run into the world; compare the message kinds with a run without your change. The layer caps repeats, so counts are not totals |
|
||||
| which pass the GPU was in at a device lost | the `vk: pass marks` lines; on by default on AMD, `TOTK_PASS_CRUMBS=1` elsewhere |
|
||||
| which object held the address of a GPU memory fault | `TOTK_ADDR_REPORT=1` (off by default: it slows recording, on AMD's Windows driver more and more over a session); the `vk: fault address` lines after the device lost |
|
||||
| a crash | the crash report at the end of the log: exception, guest and host addresses, registers |
|
||||
| a run on a large card that acts like a small one | `TOTK_VRAM_LIMIT_MIB=<MiB>` |
|
||||
|
||||
|
||||
@@ -11,12 +11,14 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
|
||||
| Symptom | Usual causes | First check |
|
||||
|---|---|---|
|
||||
| magenta, brown or stale textures; caves or sky wrong | the CPU filled the texture and the GPU never got the upload (no flush on the console) | frame dump: the texture's upload count and mirror state in `passes.txt` |
|
||||
| rain shows only its splashes on the ground, no falling drops; waterfall splashes and mist blink | a GPU write-back copies a whole range over particle records the CPU spawned in it (`vk_memory.c`: the write-back merge, and with `shadow = 1` the shadow's pending ranges) | a run with `TOTK_WB_MERGE=0` or `TOTK_SHADOW=0` against one without |
|
||||
| effects that never happen: cut grass stays up, fire does not spread | the CPU reads a GPU-rendered texture that was never written back | which texture the game reads after its fence; write-back of that target |
|
||||
| black scene, black dialog background or loading map | deferred binds read at record time; a 3D target rejected; a texture compare ignoring the channel mapping | frame dump: the first pass whose target goes black |
|
||||
| lime silhouettes, rectangles in the sky | a target outside the shader's output map overwritten instead of kept | dump: the target's previous contents versus after the pass |
|
||||
| dark or magenta 16x16 blocks, missing characters | a pass samples its own render targets (G-buffer feedback) | feedback-loop layout and barriers on that pass |
|
||||
| tile rectangles, wrong data in tiles | storage buffers bound in the wrong slot order | `passes.txt`: storage buffers with their c0 slots |
|
||||
| streaks on cliffs, characters stretched into streaks | primitive restart ignored; integer vertex inputs against a float format | validation run; the draw's topology and vertex formats in the dump |
|
||||
| huge stretched slabs over the ground, a ceiling over Link, the ground up to his chest, from the load on for the whole session (the Depths); some runs only, most at a high frame rate; with `sync_ahead`, `replay_workers` and a discrete GPU | a VRAM mirror copied from the shadow before the CPU's write reached it, and kept the old vertices while marked synced (fixed: `vk_memory.c` `vk_mem_mirror_seal`) | `TOTK_MEMORY=verify` mismatch lines; `memory = import` or `replay_workers = 0` makes it go; `fps_limit = 144` shows it in most runs |
|
||||
| garbage geometry on title or load screens | 8-bit indices widened on the CPU before a copy in the same submission wrote them | whether a copy to the index buffer precedes the draw in one submission |
|
||||
| black tiles, masks not cleared | clears with a partial channel or stencil mask skipped or done in full | `passes.txt` clears and their masks |
|
||||
| garbage in feedback effects at first use | new GPU-only images start undefined; the console starts them at zero | clear on creation and compare |
|
||||
@@ -25,7 +27,13 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
|
||||
| no sun shadows, wrong lighting | unwritten vertex outputs read as zero instead of (0,0,0,1) | the shader's output map |
|
||||
| one flat ambient colour | a 1-layer 2D array sampled as 2D | the view type the shader expects |
|
||||
| upside-down text | lower-left window origin | origin mode in the log |
|
||||
| puddles and still water flicker: the reflection turns on and off in patches from frame to frame while the camera stands still, more with DLAA | the game's water volume mask: a volume's top face lies on the water surface and is tested LEQUAL against a depth rebuilt at quarter size, so rounding and the camera's sub-millimetre motion decide it (fixed: `vk_pipeline.c` `vk_pipeline_volume_bias` gives such draws a depth bias toward the viewer) | a `--capture` run: the puddle's brightness swing (`capture.py` frames, a region's mean) with `TOTK_VOLUME_MASK_BIAS=0` and without; in a frame dump, the quarter-size mask after the volume draw changes from frame to frame |
|
||||
| with DLAA on, water seen at a low angle (ponds, streams) flickers in large patches with a period of about three frames, between the reflection of the trees and that of the sky; without DLAA it is still | the jitter moved the viewport of the scene's draws but not the game's camera, so its full-screen passes rebuilt positions half a pixel off the surface and its screen-space reflections flipped between hit and miss with the jitter's phase (fixed on 1.4.3: `vk_dlaa.c` puts the jitter into the camera blocks where the game copies its matrices, `vk_dlaa_camera_copied`) | `TOTK_DLAA_CAM_JITTER=0` brings the viewport jitter back; a `--capture` run: the region's brightness swing with DLAA, against `TOTK_DLAA_JITTER=0` |
|
||||
| with DLAA on, the world behind the inventory smears into horizontal streaks on the right half, from the second time the inventory is opened (when Link's model is drawn there) | the camera jitter's read-back took the inventory camera's own off-centre projection (P[0][2] about -0.6) for a jitter and gave DLSS an offset of about 1152 pixels (fixed: `vk_dlaa.c` `cam_offset` takes only an offset it gave that block) | `TOTK_DLAA_CAM_JITTER=0` makes it go; a `--capture` run over the opened inventory: the background's horizontal gradient against its vertical one |
|
||||
| with DLAA/DLSS on, large distant blocks behind the fog (the Depths) turn darker or lighter for a frame while the camera moves | DLSS created with AutoExposure estimated the exposure of the dark scene itself, and the estimate moved from frame to frame (fixed with `dlss_fixed_exposure = 1`: `vk_dlaa.c` evaluate creates the feature without it) | a flat fogged patch in `capture.py` frames: one value without DLAA, jumps with it |
|
||||
| flicker or a texture swapped with a similar one | the newest texture picked at shared storage instead of the one with the matching view | texture lookup by id in the dump |
|
||||
| with DLAA on, dust and small particles in fog (shrines) vanish, smear or behave oddly; the fog looks processed | DLSS ran at the bloom, after the fog and the particles, which have no motion vectors or jitter of their own (fixed: `vk_dlaa.c` effects_point runs DLSS at the first pass into the light target after the lighting, and the effects go over its picture) | `dlaa_effects_after = 0` (Screen tab) brings the old point back; the count "before the effects" in the `dlaa:` log line against the frames anti-aliased |
|
||||
| with DLAA on, the picture flickers from frame to frame: a little outdoors; the whole scene in a fogged shrine with an ability's targeting view (Ultrahand) open, where the fog also goes back under DLSS | DLSS ran before some effects in one frame and after them in the next: their order changes from frame to frame (the yard's half-size effects pass is in some frames only; the ability highlight, drawn into the light target with a D16 depth of its own, comes before or after the fog layer), and a rule that waited for one of them or took any D16 pass for the lighting followed it (fixed: `vk_dlaa.c` effects_point knows the lighting by its depth and runs DLSS right after it) | the `dlaa:` log line: "before the effects" must equal the frames anti-aliased in the world; a log of the passes into the light target per frame |
|
||||
|
||||
## Timing and frame pacing
|
||||
|
||||
@@ -36,6 +44,8 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
|
||||
| frame counter wanders 50-60 | two 60 Hz clocks (vsync event and present acquire) drifting apart | whether both follow one display tick |
|
||||
| a 30 Hz thread runs at 27 Hz, slow cutscenes | host sleep overshoot: Windows waitable timers wake 0.3-0.5 ms late | `TOTK_TRACE=sched` sleep asked versus took |
|
||||
| 20 fps after a scheduler change | a yield back-off that starts too early | yield handling against the console's |
|
||||
| in the Depths Link takes gloom damage and wears the gloom haze while standing on clean ground, some runs only; only with `sync_ahead = 1` | the game read a GPU result of the frame it was told is done before the GPU wrote it: its one-pixel readbacks go through a buffer per request, which then holds zeros or an answer from the ring's last round (fixed: `vk_memory.c` `vk_mem_shadow_read` waits at the invalidate) | `sync_ahead = 0`; the exit line `mem: the game waited for a GPU write it reads` |
|
||||
| in shrines the lamps' reflections on the floor go out for single frames, every other frame at some camera angles; only with `sync_ahead = 1`, more with DLAA (the GPU runs further behind) | the game reads its depth query results two frames later and refuses them unless their frame number is exactly the counter - 2; with sync_ahead it is the counter - 3 on frames where the GPU is behind (fixed: patch set `qstamp` in `recomp/patches-v143.txt` also takes the counter - 3) | `sync_ahead = 0`; a `--capture` run with `TOTK_SYNC_AHEAD` on, counting one-frame drops in floor regions |
|
||||
| climbing or movement wrong only above some fps | game code that assumes a fixed step count per frame | compare at 30, 60 and the failing rate |
|
||||
|
||||
## Threads and crashes
|
||||
|
||||
+10
-6
@@ -90,7 +90,9 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app
|
||||
- Memory pools. Apple's unified memory let MacNativeGames use the game's pools zero-copy. The back end imports the pools as host memory (`VK_EXT_external_memory_host`). On a discrete GPU, pools bound as buffers are mirrored in device-local memory and the pages the CPU wrote (write watch, above) are uploaded before a replay; idle pool regions are made read-only so the write-watch queries skip them (`vk_memory.c`). GPU-rendered textures are written back when the CPU reads them: on a pool invalidate, on a CPU copy, and for small targets once the CPU waits for a fence (`vk_texture.c`).
|
||||
- Replay thread. `TOTK_REPLAY_ASYNC=1` moves the replay off the submitting thread onto a queue at most one frame behind the game; reads of GPU results wait for the newest writer instead of draining the queue (`vk_backend.c`). It is off by default. Where the game waits for the GPU it overlaps the replay with the game threads (a GTX 1650 in the Depths, issue #88), a gain measured only there; while it was the default, a GTX 1660 Ti at the 60 fps cap with the GPU at 26 % reported uneven motion (#659). It adds up to a frame of latency; `replay_async = 1` turns it on.
|
||||
- Chunked replay. A large submission is recorded in chunks by several threads (`TOTK_REPLAY_WORKERS`, 0 by default: the sequential replay; 4 is a good value from 8 logical processors) and the chunks go to the queue in order (`vk_exec.c`). A sequential scan keeps a copy of the queue state where each chunk starts and lists what a chunk would otherwise learn from the chunks before it: inline uniform updates, conditions, contact shadow marches, uniform drops. It also makes render targets live in replay order and notes the op, since a chunk can sample a storage before the chunk that renders it got there or after the scan went past a later target there: a chunk's texture slots resolve as of its own op, and the chunks after a texture with no entry yet wait for the chunk that makes it. DLSS's decisions (the G-buffer, the light target, the end of the scene, the scaling pass) are the scan's too, and its copy of the lit scene and its evaluation are records of the chunk that holds the op; a chunk's draws are jittered while they come before the scan's end of the scene. The evaluation waits until the chunks before it are recorded, as it reads what their draws noted (the camera block, the jitter, the per-object motion list, which chunks add to under one lock), and the chunks after it wait for it, as they sample its output. `TOTK_REPLAY_STATE_CHECK=1` compares the state after the last chunk with the scan's.
|
||||
- Frame ahead. `TOTK_SYNC_AHEAD=1` (`sync_ahead`, off by default) makes the one `nvnSyncWait` per frame that waits for the frame presented last wait for the frame before it, so the game builds the next frame while the GPU still runs the previous one (`nvn_api_core.c`, `nvnSyncWait`). The game then writes memory that in-flight work still reads. This is safe only with shadow storage (`vk_memory.c`, the CPU-visible pools are host-visible copies of guest memory, on by default on Linux and Wine, `shadow = 1` (`TOTK_SHADOW=1`) on native Windows; without it the switch is ignored): a CPU write reaches the GPU only through the shadow copy made before each submit (`vk_mem_shadow_sync`), and a copy that would overwrite bytes an unfinished submission reads is queued as a GPU copy in the prologue command buffer of the part submitted next (`vk_mem_shadow_prologue`, `TOTK_SHADOW_DEFER=1`, the default with the feature) or, with `=0`, waited for on the replay thread (`shadow_reader_wait`). Only that one wait lags (identified by its call site, known for 1.2.1 and 1.4.3); results the game reads back from the GPU after it can be a frame old.
|
||||
- Frame ahead. `TOTK_SYNC_AHEAD=1` (`sync_ahead`, off by default) makes the one `nvnSyncWait` per frame that waits for the frame presented last wait for the frame before it, so the game builds the next frame while the GPU still runs the previous one (`nvn_api_core.c`, `nvnSyncWait`). The game then writes memory that in-flight work still reads. Two forms guard that. With shadow storage (`vk_memory.c`, the CPU-visible pools are host-visible copies of guest memory, on by default on Linux and Wine, `shadow = 1` (`TOTK_SHADOW=1`) on native Windows) a CPU write reaches the GPU only through the shadow copy made before each submit (`vk_mem_shadow_sync`), and a copy that would overwrite bytes an unfinished submission reads is queued as a GPU copy in the prologue command buffer of the part submitted next (`vk_mem_shadow_prologue`, `TOTK_SHADOW_DEFER=1`, the default with the feature) or, with `=0`, waited for on the replay thread (`shadow_reader_wait`). Only that one wait lags (identified by its call site, known for 1.1.0, 1.2.1 and 1.4.3). GPU writes into pool storage come back with their fence, so a buffer the game reads back every frame after that wait holds the result of the frame before; a buffer it has not read lately holds none, and its `nvnMemoryPoolInvalidateMappedRange` waits for the write (`vk_mem_shadow_read`): TotK reads single pixels through a buffer per request, and in the Depths zeros in one of them put Link in gloom. The exit line `mem: the game waited for a GPU write it reads` counts these waits and their time. On 1.4.3 the patch set `qstamp` (`recomp/patches-v143.txt`) lets the game take its depth query results one frame older; it follows the switch and is off when the switch is refused. The fence write-back of small render targets (`vk_texture.c`, `write_back_n`) does not wait for the GPU with `TOTK_WB_EAGER=1` (`wb_eager`, the default, but only while frame-ahead is in effect: with `sync_ahead` off or refused the setting does nothing and the write-back reads the image when it runs): `vk_sync_submit` has `vk_texture_eager_record` copy the targets that value rendered into staging buffers inside the same command buffer, so once the value has passed the write-back only copies from staging into the target's storage. Only a target that was written back within the last 64 timeline values is copied (the first write-back of a target takes the blocking path), and the staging of a target past that window, no longer wanted or released goes through the deferred free (`vk_defer_buffer_until`). A snapshot is used only when its value is the one that last rendered the target, nothing recorded a write to the image since (`wr_fence`) and the GPU has finished it; otherwise the write-back reads the image as before, and the exit line `vk: wb_eager:` counts the reasons. With frame-ahead in effect the exit line `vk: fence write-backs waited for the GPU` counts the write-backs that waited for a copy and the time they waited, for every value of the setting. `check` also reads the old way and compares.
|
||||
- Frame ahead in place. Without shadow storage the GPU reads the game's own memory, as in Savage Wind's overlap, and `vk_ahead_init` (`runtime/vk_ahead.c`) turns on guards for what the GPU reads or writes there after the recording, each with a switch `TOTK_SYNC_AHEAD_<NAME>` (1 by default unless noted) for A/B runs. `MSYNC`: the VRAM mirrors' sync copies take the synced pages from a staging copy the replay thread makes at submit (`vk_memory.c` `stage_ranges`), not from guest memory when the GPU runs them; the frame wait returns only after the replay submitted the asked value, so those are that frame's bytes. A synced range that an earlier value still writes back into waits for that value first, or the copy would drop its GPU words. `WBMERGE`: every GPU write into a mirror goes back through the word merge (`wb_merge_record`), so a write-back that lands after the game wrote the range for the next frame puts back only the words the GPU changed. `DESWZ`: a texture the CPU rewrote after its last upload is deswizzled on the CPU (`upload_gpu`, reason `frame ahead`). `READS`: GPU writes into CPU-visible memory are listed with their value until it completes (bounded, `aw_add`), and an invalidate of a range not read lately waits for the writer's own value (`ahead_read`). `ONESHOT`: the frame wait waits up to the value that rendered a dirty small target not written back within the last 16 frames (Savage Wind's one-off rule, `vk_texture_oneshot`), so a photo or a pick reads its own frame, while targets read every frame or in turns get the frame before. `QUERIES` (0 by default): the same for samples-passed reports; TotK reads those two updates after it asks (1.2.1 `f_70010c3298`). With import memory (`TOTK_MEMORY=import`, the integrated-GPU mode) the GPU reads vertex, index and storage data in place, which no guard covers (a check run saw the game rewrite about 10 KiB of them a frame after the wait, particles mostly), so the switch is refused there without shadow storage. The exit lines `mem: sync-ahead in place` and `sync-ahead: frame waits made exact` give the guards' waits and copies. `TOTK_SYNC_AHEAD_CHECK=1` runs the detector below with the late wait itself.
|
||||
- Frame-ahead check. `TOTK_SYNC_AHEAD=check` keeps the frame wait exact and measures what a one-frame-late wait without shadow storage would race (`runtime/vk_ahead.c`). The replay notes, with each submission's value, every access of guest memory the GPU makes after the recording: in-place bindings of imported pools without a VRAM mirror (`VK_AHEAD_READ`), the mirror's sync copies (`vk_mem_mirror_prologue`), GPU deswizzle sources (`vk_texture.c` `upload_gpu`) and the mirror write-backs (`vk_mem_mirror_end`). At the frame wait for value A, whose late form would have waited for L, the notes of values in (L, A] form the frame's read set: merged per class, gap-joined into at most 512 write-watch queries that stamp the writes made so far into the shared page generations (`vk_mem_ahead_observe`). At the next frame-wait entry the queries run again, and every page of the set stamped since is a CPU write the late wait would have raced; memory without a write watch is compared by page hashes. GPU writes into CPU-visible memory and reports are listed with their value: an invalidate of a range written by a value in (L, A] of the last frame wait, and the fence write-back of a small target rendered by one, count as stale readbacks. One line `sync-ahead check:` per second of host time and a run summary with the largest offenders by pool at exit. `--probe-vkmem` checks the detector on a watched pool (`vk_ahead_selftest`); `tests/sync_ahead_check.py` checks that the wait stays exact.
|
||||
- Recorder thread. The Vulkan calls the replay makes into its command buffer are made by a thread of their own (`vk_rec.c`, after Savage Wind Recomp and LAS Recomp): each `vkCmd*` copies its arguments into a packet of a ring and the recorder makes the calls in order; calls into other command buffers are made at once; the recorder also ends the command buffer, and the submit waits until it has. In the town on an RX 9070 the replay takes 17% less time on the submitting thread. It is off by default on AMD GPUs, where the driver loses the device or hangs the GPU at startup with it (`TOTK_VK_RECORDER=1` forces it on, `=0` makes every call on the submitting thread).
|
||||
- Uniform snapshot. The game rewrites per-object uniform blocks on other threads soon after it submits the frame
|
||||
that reads them, while the replay still records it. At the start of a submission's replay every uniform range it
|
||||
@@ -109,11 +111,13 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app
|
||||
RCAS) on the present. An `output_res` that is not 16:9 (more than 1% off, `res_is_16x9`) also switches on the
|
||||
`aspect` patch set, which hands the output's ratio to the camera, and `romfs.c` `overlay_init` loads the
|
||||
`romfs-patches-<w>x<h>` overlay for it when it exists (`tools/make_romfs_patches.py --aspect`, laid out by
|
||||
`tools/ultrawide_layout.py`; the installer builds fifteen sizes: 21:9 2560x1080, 3440x1440, 3840x1600, 5120x2160,
|
||||
32:9 3840x1080, 5120x1440, 16:10 1280x800, 1680x1050, 1920x1200, 2560x1600 and 3:2 1920x1280, 2160x1440, 2256x1504,
|
||||
2880x1920, 3000x2000). A wider layout moves the HUD to the
|
||||
screen's corners, a narrower one to its top and bottom edges. Other sizes get the camera of their shape and the 16:9
|
||||
HUD stretched over it. The `aspect` setting (`fit`, the default; `stretch`) decides what the present does
|
||||
`tools/ultrawide_layout.py`; installer/steps.py Shapes builds one canonical folder per needed display/output shape,
|
||||
chosen by installer/screens.py). A wider layout moves the HUD to the
|
||||
screen's corners (`hud_width = 21:9` or `16:9` keeps it in the middle of the screen instead, from the `-hud21x9` or
|
||||
`-hud16x9` variant of the folder), a narrower one to its top and bottom edges. Shapes generates a capped variant
|
||||
only when selected, alongside the full layout and selected button prompts. `romfs.c` `shaped_name` checks the exact
|
||||
size then its canonical shape; a missing cap falls back to full, while the menu still offers preparation for the cap.
|
||||
Without any matching layout the output falls back to 16:9. The `aspect` setting (`fit`, the default; `stretch`) decides what the present does
|
||||
when the window's shape differs from the output's: `fit` letterboxes, where a 16:9 game in a wider window used to be
|
||||
stretched.
|
||||
- HDR (`hdr = 1`, `vk_hdr.c`). The game tonemaps its scene into an r11g11b10f target, upscales it and draws the HUD
|
||||
|
||||
+33
-6
@@ -111,18 +111,37 @@ of them.
|
||||
$env:SCCACHE = "path\to\sccache.exe"
|
||||
.venv\Scripts\python tools\build_game.py --version <ver>
|
||||
```
|
||||
|
||||
A build into another `--out` (a task build, or a private lift of a patch change with `--gen generated\<ver>-<tag>`)
|
||||
hardlinks the objects of the main build `build\<ver>` and compiles only `runtime/` and the generated files whose
|
||||
compile differs. An object is reused when the main `build.ninja` has the same compiler, flags and rule, the main
|
||||
build is up to date, and every file its compile read according to the main Ninja deps log (the `.c`, the `runtime/`
|
||||
and generated headers, the system headers) has the same bytes in this build's trees and has not changed since the
|
||||
object was written, and neither has the compiler. A lift that changes one patch site then compiles one or two chunks
|
||||
instead of all of them. The build prints `reused N of M generated objects`; `--verbose` lists the others with the
|
||||
reason, and `--full-build` compiles everything.
|
||||
`--patches` builds in the frame-rate, resolution and other patch sets, switchable at run time. The link copies
|
||||
`SDL3.dll`, `libiconv-2.dll` and `libopus-0.dll` next to the exe.
|
||||
For Xbox button prompts, run `make_romfs_patches.py` twice more, with `--prompts xbox` and `--prompts xbox-label`:
|
||||
they write `build\<ver>\romfs-patches-xbox` and `romfs-patches-xbox-label` ([controls.md](controls.md), "Xbox
|
||||
button prompts"), which `build_game.py` copies next to `totk.exe` like `romfs-patches`. `--prompts pc` writes
|
||||
`romfs-patches-pc`, the keyboard and mouse prompts ([controls.md](controls.md), "PC button prompts").
|
||||
For Xbox and PlayStation button prompts, run `make_romfs_patches.py` twice more for each, with `--prompts xbox`,
|
||||
`--prompts xbox-label`, `--prompts playstation` and `--prompts playstation-xbox`: they write
|
||||
`build\<ver>\romfs-patches-xbox`, `-xbox-label`, `-playstation` and `-playstation-xbox`
|
||||
([controls.md](controls.md), "Xbox and PlayStation button prompts"), which `build_game.py` copies next to `totk.exe`
|
||||
like `romfs-patches`. `--prompts pc` writes `romfs-patches-pc`, the keyboard and mouse prompts
|
||||
([controls.md](controls.md), "PC button prompts").
|
||||
`--aspect <w>x<h>` writes the UI laid out for a game resolution of another shape; with `--hud 16:9` or `--hud 21:9`
|
||||
(a screen wider than that) the HUD stays within the middle 16:9 or 21:9 instead of the screen's corners. The default
|
||||
`--out` then is `build\<ver>\romfs-patches-<w>x<h>-hud16x9` (`-hud21x9`), which the game loads for `hud_width = 16:9`
|
||||
(`21:9`) in `totk.ini` ([totk.ini.example](../totk.ini.example)).
|
||||
Setup's Shapes step builds only the currently selected cap for the canonical shapes needed by connected displays
|
||||
and `output_res`, together with the selected prompts. `full` generates no capped folders. After changing the HUD
|
||||
width, use the Screen tab's layout preparation action or rerun setup before restarting the game. Lookup prefers
|
||||
the selected cap at the exact or canonical size before falling back to a full-width layout.
|
||||
|
||||
A build from source has no layouts for other shapes than 16:9. At an `output_res` such as 5120x1440 the game then
|
||||
draws the largest 16:9 size inside it (2560x1440) and the present adds bars, instead of a wide camera over a
|
||||
stretched HUD (`runtime/resolution.c`, `shape_fallback`). For the full shape make `romfs-patches-<w>x<h>` once per
|
||||
size: `make_romfs_patches.py --version <ver> --aspect <w>x<h> --out build\<ver>\romfs-patches-<w>x<h>` (the sizes
|
||||
the installer makes are `ASPECT_SIZES` in `installer/steps.py`); `build_game.py` copies every `romfs-patches*`
|
||||
the installer maps to are in `installer/screens.py`); `build_game.py` copies every `romfs-patches*`
|
||||
folder next to `totk.exe`.
|
||||
|
||||
6. Prepare the shaders (once per build folder and translator). It needs `refs\MacNativeGames` (`tools\fetch_refs.sh`)
|
||||
@@ -217,7 +236,15 @@ Before a commit:
|
||||
A change to the button prompts (`tools/make_romfs_patches.py --prompts`, `tools/button_icons.py`) passes
|
||||
`.venv-py314\Scripts\python tests\romfs_prompts_test.py`, which runs the tool on a RomFS it makes itself (no game
|
||||
files); a change to the settings passes `totk.exe --probe-cfg` and `python tests\settings_doc_check.py`, which fails
|
||||
when a setting is described neither in `totk.ini.example` nor in [settings.md](settings.md). A change to the mods' ExeFS patches
|
||||
when a setting is described neither in `totk.ini.example` nor in [settings.md](settings.md).
|
||||
HUD pane/animation and generator naming regressions run with Python 3.14+: `tests/hud_layout_test.py`.
|
||||
Set `HUD_TEST_ROMFS` to a verified extracted RomFS directory to include a real-archive comparison against the
|
||||
pre-port layout generator; all game-derived temporary data stays under `build/`.
|
||||
`python tests/romfs_shapes_check.py --cc <clang>` compiles the production folder-selection and preparation helpers
|
||||
to check canonical aliases, capped/full fallback, prompt arguments, the missing 16:9 prompts and generation
|
||||
deduplication without game files. `tests/romfs_prompts_test.py` checks that two `--background` runs for one folder
|
||||
publish it once and that a folder with a manifest is kept.
|
||||
A change to the mods' ExeFS patches
|
||||
(`tools/exefs_patches.py`, `runtime/mods.c`, the `folded.txt` of `recomp/gen.py`) passes
|
||||
`.venv\Scripts\python tests\exefs_patches_test.py`, which makes its own modules and runs `gen.py` on one with a jump
|
||||
table (no game files), and `totk.exe --probe-mods`. A change to the cheat VM or the cheat opcode tables
|
||||
|
||||
+106
-8
@@ -8,7 +8,7 @@ Input comes from the first SDL3 gamepad, the keyboard and the mouse, merged into
|
||||
- `xbox`: south A, east B, west X, north Y, as an Xbox pad labels them; on a PlayStation pad cross is A, circle B, square X, triangle Y.
|
||||
- `auto` (default): `nintendo` for a pad whose east button SDL reports labelled A (Switch Pro Controller, Nintendo-layout pads), `xbox` for the others.
|
||||
|
||||
The log names the layout in effect (`input: gamepad layout ...`); the menu shows it under *Automatic*. Which controller's buttons the game's prompts show is `TOTK_PROMPTS` (see Xbox button prompts below). 0.1.9's `pad_layout = xbox_prompts` is read as `pad_layout = nintendo` with `prompts = xbox`, and the menu writes it that way.
|
||||
The log names the layout in effect (`input: gamepad layout ...`); the menu shows it under *Automatic*. Which controller's buttons the game's prompts show is `TOTK_PROMPTS` (see Button prompts below). 0.1.9's `pad_layout = xbox_prompts` is read as `pad_layout = nintendo` with `prompts = xbox`, and the menu writes it that way.
|
||||
|
||||
| Switch | Gamepad (by position, Nintendo layout) | Keyboard and mouse | Action in the world |
|
||||
|---|---|---|---|
|
||||
@@ -31,9 +31,9 @@ The log names the layout in effect (`input: gamepad layout ...`); the menu shows
|
||||
|
||||
Esc is unbound in the game; it opens the settings menu and releases the mouse cursor (see Mouse camera). Z and X duplicate ZL and ZR so menu pages turn with two neighbouring keys; the menu tabs (L, R) are Q and R. T duplicates Y for the game's menus, where the left mouse button is A while the pointer is shown (sort the inventory with T). The mouse wheel zooms the Purah Pad's map and its camera, steps the game's menus and the d-pad strips (see Mouse in the game's menus), and is unbound elsewhere. The bindings are the tables of `input_map` in `runtime/input_map.c`: the keys (platform-neutral key ids) and one gamepad table per layout (gamepad inputs by position); `runtime/input_win.c` translates Win32 virtual keys and SDL buttons.
|
||||
|
||||
## Xbox button prompts
|
||||
## Xbox and PlayStation button prompts
|
||||
|
||||
`TOTK_PROMPTS` (`prompts`, the *Button prompts* row on the Controls tab, read at start) picks the controller whose buttons the game's prompts show: `nintendo` (default) keeps the game's own, `xbox` shows an Xbox controller's, `pc` the keyboard and mouse (PC button prompts, below).
|
||||
`TOTK_PROMPTS` (`prompts`, the *Button prompts* row on the Controls tab, read at start) picks the controller whose buttons the game's prompts show: `nintendo` (default) keeps the game's own, `xbox` shows an Xbox controller's, `playstation` a PlayStation controller's, `pc` the keyboard and mouse (PC button prompts, below).
|
||||
|
||||
- L, R, ZL, ZR, Plus and Minus become LB, RB, LT, RT, Menu and View, and the d-pad prompts a cross with an arrow for each direction meant. The letters on the keys are cut out in the game's own text font.
|
||||
- A, B, X and Y name the label of the button the pad layout presses, so each prompt names the button to press. `pad_layout = nintendo` plays an Xbox pad by position: the right button, labelled B, does Switch A (interact, confirm), and the bottom one, labelled A, does Switch B (run, cancel), so the prompts swap A with B and X with Y. `xbox` and `auto` put Switch A on the button labelled A, and the letters stay.
|
||||
@@ -48,16 +48,34 @@ Esc is unbound in the game; it opens the settings menu and releases the mouse cu
|
||||
|
||||
The action prompt (`DoCommand_00`) shows its button in a diamond whose shape gives the face buttons' positions as on a Switch, with the other three letters around it. With `nintendo` its letters are swapped with the rest and every one names the button in that place. With `xbox` and `auto` the letters stay and the diamond is laid out as an Xbox pad: A at the bottom, B on the right, X on the left and Y at the top, the button the prompt names lit in its place, its bar reaching left from X and right from the others (`tools/make_romfs_patches.py`, `bflyt_xbox_diamond`: the panes of `blyt/DoCommand_00.bflyt` take their partner's place, A's of B and X's of Y). The sticks keep the Switch icons, and so do prompts drawn as fixed images (some tutorial animations).
|
||||
|
||||
The prompts are part of the game's fonts, textures and messages, so they follow the layout and not the bindings. A button remapped with a `bind_` line or on the Controls tab keeps the prompt the game draws for it, which then names the wrong button. Use the Xbox prompts with the default bindings.
|
||||
### PlayStation
|
||||
|
||||
`prompts = playstation` shows a PlayStation pad's buttons: the face buttons as ○ (circle), × (cross), △ (triangle) and □ (square), L1, R1, L2 and R2 on the shoulders and triggers, Options and Share on Plus and Minus, and the d-pad as a cross. Each prompt names the button to press, so the shapes follow `pad_layout`:
|
||||
|
||||
| Switch | `nintendo` layout | `xbox` or `auto` layout |
|
||||
|---|---|---|
|
||||
| A, B, X, Y | ○, ×, △, □ | ×, ○, □, △ |
|
||||
| L, R | L1, R1 | L1, R1 |
|
||||
| ZL, ZR | L2, R2 | L2, R2 |
|
||||
| Plus, Minus | Options, Share | Options, Share |
|
||||
| D-pad | cross | cross |
|
||||
|
||||
The game's text fonts already have the four shapes (U+25CB, U+00D7, U+25B3 and U+25A1), so the action prompt's diamond uses them as text; the action prompt's button image and the button guide's images are drawn with the same shapes. The game loads `romfs-patches-playstation` (`pad_layout = nintendo`) or `romfs-patches-playstation-xbox` (`xbox`, `auto`) in place of `romfs-patches`; the setup writes both with `tools/make_romfs_patches.py --prompts playstation` and `--prompts playstation-xbox` (`tools/button_icons.py`, `playstation_icons`). With `xbox` and `auto` the diamond is laid out as for the Xbox prompts: × at the bottom, ○ on the right, □ on the left and △ at the top. At a game resolution of another shape the prompts follow the shape's UI layout as the Xbox ones do (below).
|
||||
|
||||
The prompts are part of the game's fonts, textures and messages, so they follow the layout and not the bindings. A button remapped with a `bind_` line or on the Controls tab keeps the prompt the game draws for it, which then names the wrong button. Use the Xbox or PlayStation prompts with the default bindings.
|
||||
|
||||
The game reads its UI archive and fonts once at boot, so the prompts change at the next start, also after `pad_layout` changes between `nintendo` and the others (the menu says *prompts change after restart*); the buttons change at once. Under that note the menu offers *Restart now*: after a confirmation it writes `totk.ini`, closes the game as *Quit game* does and starts the game again with the same command line, which waits until the old process is gone before it opens the log and the saves (`runtime/gfx_present.c`, `gfx_window_closed`; `plat_restart` and `plat_restart_wait` in `runtime/platform/win32.c` and `linux.c`). Progress since the last save is lost, as with *Quit game*; while the game writes a save, the confirmation waits. With `prompts = xbox` the game loads `romfs-patches-xbox` (`pad_layout = nintendo`) or `romfs-patches-xbox-label` (`xbox`, `auto`) next to `romfs-index.bin` in place of `romfs-patches` (`runtime/romfs.c`, `overlay_init`; `runtime/input_map.c`, `input_prompts_folder`): the same 60 fps patches, with the prompts drawn from the game's own files by `tools/make_romfs_patches.py --prompts xbox` or `--prompts xbox-label` (`tools/button_icons.py`, after MacNativeGames' `make_button_icons.py`), which the setup runs next to the plain one:
|
||||
|
||||
- every prompt but the button guide in play is text in the button font, `scft/External.bfotf` in each `Font/Font*.Nin_NX_NVN.bfarc.zs`: glyphs U+E040 to U+E043 (A B X Y), U+E044 to U+E047 (L R ZL ZR), U+E04B and U+E04C (Plus, Minus), U+E049 and U+E060 to U+E065 (the d-pad). fontTools writes the font again, so the archives grow and the folder also carries the resource size table (`System/Resource/ResourceSizeTable.Product.<n>...rsizetable.zs`) with their entries raised by as much; without that the game stops at start.
|
||||
- the button guide in play draws L and ZL from the images `Nt_KeyTexL_00` and `Nt_KeyTexZL_00` of the Common archive's `timg/__Combined.bntx`, painted with the same icons. The action prompt draws its button from `Nt_KeyTexA/B/X/Y_00`, whose image data is swapped for `nintendo`, and the diamond's letters are text the game takes from `LayoutMsg/DoCommand_00.msbt` of each language's `Mals` archive (and the layout's own text panes behind it), swapped the same way.
|
||||
|
||||
The Switch prompts stay, with a note under *Button prompts* and a `RomFS overlay: ...` line in the log, when the folder is missing (an install made by an older setup, or one where the setup could not prepare it and showed a warning; running the setup again on the install folder writes it), when it fails its check, with a game resolution of another shape than 16:9 that has no folder of its own (below), and when the `romfs_mods` folder replaces one of its files: `romfs-patches` then loads in its place, where two overlays replacing one file would stop the game. In a source build, `.venv-py314\Scripts\python tools\make_romfs_patches.py --version <ver> --prompts xbox` (and `--prompts xbox-label`) writes `build\<ver>\romfs-patches-xbox` (`-label`); it needs fontTools from `tools/requirements-py314.txt`. `--xbox-prompts` is the older name of `--prompts xbox`.
|
||||
With `prompts = playstation` the game loads `romfs-patches-playstation` (`pad_layout = nintendo`) or `romfs-patches-playstation-xbox` (`xbox`, `auto`) the same way, written by `tools/make_romfs_patches.py --prompts playstation` and `--prompts playstation-xbox`: the same 60 fps patches, with the face buttons' images and the diamond's letters drawn as ○ × △ □, the shoulders and triggers as L1 R1 L2 R2, Options and Share, and the button guide's L and ZL images. The game's text fonts already have the four shapes, so the diamond's panes and messages hold those characters instead of the letters.
|
||||
|
||||
At a game resolution of another shape than 16:9 the game loads `romfs-patches-xbox-<w>x<h>` (or `romfs-patches-xbox-label-<w>x<h>`) in place of `romfs-patches-<w>x<h>`: the same prompts with that shape's UI layout, `make_romfs_patches.py --prompts xbox --aspect <w>x<h> --reuse <install>\romfs-patches-xbox --out <install>\romfs-patches-xbox-<w>x<h>`. The setup writes both for each of the fifteen sizes it lays the UI out for, as for the PC prompts below, so on a display of one of those shapes the game resolution follows the display with these prompts too. At another size, without that folder, the Switch prompts stay (*off at this game resolution*).
|
||||
The Switch prompts stay, with a note under *Button prompts* and a `RomFS overlay: ...` line in the log, when the folder is missing (an install made by an older setup, or one where the setup could not prepare it and showed a warning; running the setup again on the install folder writes it; an install whose setup's tools sit next to the game makes it itself, see below), when it fails its check, with a game resolution of another shape than 16:9 that has no folder of its own (below), and when the `romfs_mods` folder replaces one of its files: `romfs-patches` then loads in its place, where two overlays replacing one file would stop the game. In a source build, `.venv-py314\Scripts\python tools\make_romfs_patches.py --version <ver> --prompts xbox` (and `--prompts xbox-label`) writes `build\<ver>\romfs-patches-xbox` (`-label`); `--prompts playstation` and `--prompts playstation-xbox` write `build\<ver>\romfs-patches-playstation` and `-playstation-xbox` the same way. It needs fontTools from `tools/requirements-py314.txt`. `--xbox-prompts` is the older name of `--prompts xbox`.
|
||||
|
||||
A missing prompts folder, at 16:9 or of a game resolution's shape, is made by the game itself on an install whose setup left its tools next to the game (`build-cache/rebuild.txt`): choosing those prompts or a pad layout that needs it, or starting the game with them selected, starts `make_romfs_patches.py --background` for it (`runtime/romfs.c`, `romfs_folders_prepare`; `runtime/ui/menu.cpp`, `folders_tick`, once the choice has stayed for 1.5 seconds). The note says *prompt files being made in the background; used at the next start*; when the tools did not start it says so and *Try again* starts them again. A source build has no `rebuild.txt` and keeps the notes above.
|
||||
|
||||
At a game resolution of another shape than 16:9 the game loads `romfs-patches-<style>-<w>x<h>` (`romfs-patches-xbox-<w>x<h>`, `-xbox-label-`, `-playstation-` or `-playstation-xbox-`) in place of `romfs-patches-<w>x<h>`: the same prompts with that shape's UI layout, `make_romfs_patches.py --prompts <style> --aspect <w>x<h> --reuse <install>\romfs-patches-<style> --out <install>\romfs-patches-<style>-<w>x<h>`. The setup writes it for the shapes of the connected displays and `output_res`, for the selected prompts only (installer Shapes step), as for the PC prompts below. At another size, without that folder, the Switch prompts stay (*off at this game resolution*) until the game has made it in the background (above).
|
||||
|
||||
## PC button prompts
|
||||
|
||||
@@ -85,6 +103,7 @@ At a game resolution of another shape than 16:9 the game loads `romfs-patches-xb
|
||||
| F1 or Esc | Minus and Plus together | open or close the settings menu; the game gets no input while it is open |
|
||||
| F10 | L3 + R3 (both stick clicks) | performance overlay: off, frame rate, full panel |
|
||||
| F11 | | borderless fullscreen on or off, saved to `totk.ini` |
|
||||
| F6, F7 | | with `quicksave = 1`: quick save and quick load, as in Half-Life, with no menu; `quicksave_key` and `quickload_key` choose other keys ([Quick save](#quick-save)) |
|
||||
|
||||
The Minus+Plus combo never reaches the game. In the menu the arrow keys, the D-pad or the left stick move, Enter or A selects, Q and E or L and R switch tabs, Esc or B goes back (Switch button names, as in the table above).
|
||||
|
||||
@@ -110,6 +129,40 @@ bind_X = pad:west, key:space
|
||||
bind_Y = pad:north, key:mouse_l
|
||||
```
|
||||
|
||||
## Free camera
|
||||
|
||||
On game 1.4.3, a chosen gamepad combo or a key steps the free camera through three stages: move, lock, and off again.
|
||||
It is off by default: turn on *Free camera* on the Controls tab (`freecam_patch = 1`) and restart. Then pick the
|
||||
combo or the key, neither set by default, with `freecam_pad` and `freecam_key` in `totk.ini` or on the Controls tab
|
||||
(for example ZL+ZR+L3, LT+RT+L3 on an Xbox pad, and F2; `none` turns one off). An input script can press the combo as a
|
||||
gamepad would; the keys bound to its buttons do not. While the free camera moves, the world goes on but the game gets
|
||||
no input, so Link stands where he was.
|
||||
|
||||
Locked, the view stays where the flight left it and the game gets its input back. Link walks where the left stick
|
||||
points on screen, as the game steers him by the camera it draws. The right stick and the mouse turn the game camera,
|
||||
which still follows Link unseen.
|
||||
|
||||
| Gamepad | Keyboard and mouse (default bindings) | Free camera |
|
||||
|---|---|---|
|
||||
| Left stick | W A S D | forward and back along the view, and sideways |
|
||||
| ZR / ZL (RT / LT) | X / Z | straight up / down; a trigger by how far it is pressed |
|
||||
| Right stick | mouse, arrow keys | turn (yaw and pitch; pitch stops 5 degrees short of straight up or down) |
|
||||
| R / L (RB / LB) | R / Q | each press doubles / halves the speed, 0.25 to 512 m/s |
|
||||
|
||||
The keys are the ones bound to the left and right stick and to ZR, ZL, R and L (`bind_` lines), so remapped keys follow.
|
||||
The mouse turns the free camera at the game camera's rate (0.08 degrees a count at `mouse_sens = 1`) and the game's
|
||||
mouse camera gets none of it meanwhile. Each switch starts at the game camera's position and view at 8 m/s; the speed
|
||||
follows the clock, so it is the same at any frame rate and game speed. The horizon stays level.
|
||||
|
||||
How it works (`runtime/freecam.c`): the camera component update (main+0x628460) copies each component's eye, target
|
||||
and up into its sead camera. The site `freecam` (`recomp/patches-v143.txt`, main+0x6286d4) runs before that copy and
|
||||
writes the component's one-shot eye and target overrides (+0x180, +0x198), which the update takes in place of the pose
|
||||
and then clears, so the game camera's own state is never changed and resumes the frame the free camera ends. Locked,
|
||||
the site keeps writing the overrides without moving them. The up
|
||||
vector is levelled through the component's up offset (+0x200), which is kept and put back. Of the three components a
|
||||
frame updates, the free camera drives the two that share the player camera's eye and leaves the one at the default pose
|
||||
(eye 0, 0, 10). After a load replaced the components it picks the new ones and keeps its position.
|
||||
|
||||
## Mouse camera
|
||||
|
||||
`mouse_mode = direct` (the default) turns the camera by the raw mouse motion on games 1.4.3 and 1.2.1, through hooks in the game's camera code (`runtime/mouse_direct.c`, the `mouse_direct` sites of `recomp/patches-v143.txt` and `recomp/patches-v121.txt`). None of them changes a step of the gamepad alone. The free-orbit camera receives raw-count
|
||||
@@ -135,6 +188,12 @@ degrees a count as the camera does elsewhere. The follow range is read from the
|
||||
once, the mouse is stick input there). The stick loads that only test for input keep the mouse in the stick. A step with mouse motion that no
|
||||
direct hook took is logged (`mouse: step N with mouse motion took the stick path`, the first 30, then one in 600, with
|
||||
the player's state), so the cameras still on stick input show in `logs/totk.log`.
|
||||
Some cameras run none of the direct hooks and read their turn from input the hooks never see: Autobuild's placement
|
||||
camera (games 1.4.3 and 1.2.1) turns by the right stick but, in direct mode, not by the mouse (issue #1300). After two
|
||||
camera steps in a row that ran no direct hook (none of the free orbit, the load sites above or Ultrahand's held-object
|
||||
input), the mouse acts as the right stick there, as with `mouse_mode = stick`, until a step runs a direct hook again
|
||||
(`mouse: the camera runs no direct hook; the mouse acts as the right stick` and `... runs a direct hook again` in the
|
||||
log, the first 6 changes; `camera_unhooked` in `runtime/mouse_direct.c`).
|
||||
Lock-on keeps pointing the camera at the target; the stick, and so the mouse, adds an offset around that direction,
|
||||
which the game limits and lets return: the mouse's degrees are the step's turn the game adds to the offset and judges
|
||||
the return by.
|
||||
@@ -213,6 +272,20 @@ With `map_click = 1` (off by default, so each key presses one controller button
|
||||
|
||||
With `dialogue_click = 1` (off by default, so each key presses one controller button as everywhere else), on game 1.4.3, while a dialogue box is open (the layout `MessageDialog_00`: a character's lines and the game's own messages), the left mouse button presses B and the right one A, instead of the buttons they are bound to. B continues the text as A does and also shows the rest of a line that is still scrolling in; the left button's default, Y, would open the dialogue log there, and the log stays in the way until B closes it. Dialogue choices are a menu with the focus box, so the pointer above takes their clicks and a left click is A on the choice under it: clicking through a conversation fast does not pick the choice the focus starts on. A press is the dialogue's button or the binding from the moment the button goes down until it is released: the click that closes the last box does not become an attack while it is still held, and a button held when the box opens does not skip its first line. Between two lines of a conversation the game closes the box and opens it again, so both buttons stay B and A for 500 ms after the box was last open (`DIALOGUE_GAP_MS`); the first clicks after a conversation fall in that time too, as they do for a player who taps the button through the last line. `TOTK_MENU_CURSOR_LOG=1` logs how long each such gap was. The dialogue window has no focus box of its own: the scan of `eui::ScreenMgr`'s open screens (every 100 ms) finds its screen, and from then on that screen's state is read at every pad read (`dialogue_shown` in `runtime/menu_cursor.c`), so the first click after a box opens is already the dialogue's. `dialogue_click = 1` (`TOTK_DIALOGUE_CLICK=1`, live; the *Clicks in dialogue* row of the Controls tab) turns it on and `0`, the default, leaves both buttons on their bindings; the setting does not depend on `menu_cursor`. The log names the first box it sees (`menu_cursor: a dialogue box is open ...`).
|
||||
|
||||
## Quick save
|
||||
|
||||
With `quicksave = 1` (off by default; the *Quick save and load* row of the Controls tab, live), on game 1.4.3, one key saves the game at once and another loads that save: F6 and F7 by default, the keys Half-Life has for them. No menu shows on the screen (`runtime/quicksave.c`). It is for the keyboard and the mouse only (a gamepad has no quick save button yet) and for game 1.4.3 only (the addresses below are 1.4.3's; on 1.2.1 the setting does nothing).
|
||||
|
||||
Quick save asks the game for one of its own autosaves, the way its event graphs do: it calls the AutoSaveMgr's request with the kind the sequence node `OneShotAutoSaveMgrRequestAutoSave` uses, after the game's own check whether it would autosave now. That check also holds autosaves back for some ten minutes after the game's last one; quick save, being the player's own, skips that wait (it sets the AutoSaveMgr's timer to 0, and puts it back when the game says no for another reason), as Save in the System tab does. The game then saves as it does after a shrine or a story event, its autosave icon included, into one of its autosave slots: the oldest autosave is replaced, as by any autosave of the game. The commit of that save names the slot folder it wrote (`fs_save_commits` in `runtime/fs_host.c`), and quick save keeps a copy of it: `<profile>/quicksave/slot`, with the slot's name in `<profile>/quicksave/slot.txt`. *Game saved* shows at the top of the picture for a few seconds (`menu_toast`, `runtime/ui/menu.cpp`). The game can take the request and still hold the autosave back (seen once in a fight in the Depths); when no save commit comes within 5 s, quick save takes its request back, so the game does not save some time later on its own, and says it is not possible right now. The game's manual save is not touched.
|
||||
|
||||
Quick load has no request in play to start from: the game starts a load only from its own load list (System tab) or its Game Over screen, and loads the slot that screen names. So quick load goes through the load list as a player with a controller would, but out of sight. *Loading the quick save* shows at the top of the picture, and from the next frames on the window keeps that picture (`gfx_present_hold` in `runtime/gfx_present.c`, as while the window is minimized) while quick load presses Plus, R until the System tab shows, Load, A on the list's first save and Load on the confirmation. From that confirmation on, every read the game makes of a file in a slot folder (`save:/slot_NN/<file>`) opens the quick save's file instead (`fs_save_read_from` in `runtime/fs_host.c`; the log names each one, `fs: quick load: ... read from ...`), so the game loads the quick save whichever slot the list offered first, and no slot of the save is written for it. The redirect ends with the load: once the game has read the quick save's files, its loading fade has closed and the HUD has been back for half a second (`quickload: slot reads go to the save again`); at once when a menu with the focus box opens, so a Load right after it lists and loads the slots as they are. The picture comes back with the game's loading fade, about 5 s after the key. When a step finds a screen it does not expect, or none within its time, the log names the step, B is pressed until no menu has the focus box, the picture comes back and the line says *Quick load failed*. The quick save stays in the profile, so F7 loads the same state again until F6 makes a new one.
|
||||
|
||||
Both start only in play: a save loaded, the HUD (`PlayerStatus_00`) open, no menu with the focus box, no dialogue box and no loading fade. Anywhere else, and wherever the game itself would not autosave (a cutscene, an event, a fight), nothing happens but a line at the top of the picture (*Quick save is not possible right now*), and the log says why (`quicksave: not now: ...`). Without a quick save F7 says so. Quick save's calls into the game run on the game thread in its pad read, between two of its own calls; while quick load runs the game gets only its presses, not the player's input. While the setting is on its two keys reach no binding; with it off nothing changes and nothing is logged.
|
||||
|
||||
The keys are `quicksave_key` and `quickload_key` (`TOTK_QUICKSAVE_KEY`, `TOTK_QUICKLOAD_KEY`, live). The *Quick save key* and *Quick load key* rows under the switch take any key or mouse button the way a binding's cell does: select the cell, press the key (Esc cancels); Delete, Backspace or X leaves that one without a key (`none`). In `totk.ini` the value is a key name of the [Remapping](#remapping) list, in any case, or `none`. A name the list does not have is logged (`quicksave: quickload_key: unknown key '...', f7 is used`) and the default is used; the same key for both saves and leaves loading without a key. With the setting on the log names the keys in use (`quicksave: f6 saves, f7 loads`). A key a binding also uses presses only quick save or quick load while the setting is on: the row says which button it took (*also A*).
|
||||
|
||||
`QUICKSAVE` and `QUICKLOAD` lines in an input script ([Scripted input](#scripted-input)) start it as the keys do.
|
||||
|
||||
## Gameplay tweaks
|
||||
|
||||
With `gameplay_tweaks_enabled = 1` (`TOTK_GAMEPLAY_TWEAKS_ENABLED=1`, live; off by default in `totk.ini`), the mouse wheel and keyboard can drive common gameplay interactions directly:
|
||||
@@ -231,6 +304,26 @@ Windows does not present the Switch 2 Pro Controller as a gamepad SDL can open (
|
||||
|
||||
Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as tested) give buttons and rumble but no motion: their virtual DualShock 4 reports a gyro and an accelerometer that never change, so motion aiming and Ultrahand rotation do nothing. Run one bridge at a time; Steam Input can also claim the controller, so close Steam if the bridge does not find it.
|
||||
|
||||
## Steam Input and motion
|
||||
|
||||
A game Steam starts sees Steam's virtual gamepad in place of the controllers Steam Input reads (Steam lists them in
|
||||
`SDL_GAMECONTROLLER_IGNORE_DEVICES`), and that virtual pad has no gyro or accelerometer. With `motion = 1` the game
|
||||
clears that list before SDL starts (`runtime/input.c`, `steam_reveal`): buttons and sticks still come from the virtual
|
||||
pad, so Steam's remapping applies and nothing is read twice, and when the virtual pad has no sensors the motion thread
|
||||
opens the real controller behind it for its gyro and accelerometer only (`motion_source`). The log then shows
|
||||
`input: motion from "<name>" (<vendor>:<product>), the controller behind Steam Input's virtual gamepad`. This covers the
|
||||
Steam Controller and the Steam Deck's built-in controls, which Steam Input cannot be turned off for, and other
|
||||
controllers Steam Input wraps. A controller Steam hid serves for buttons only while no other gamepad is there (Steam's
|
||||
virtual pad can come up after the game starts); once the virtual pad is up the buttons move to it. With `motion = 0`
|
||||
at start Steam's list stays in force.
|
||||
|
||||
Steam switches the controller's gyro off while the game's layout binds nothing to it: the reports keep coming with the
|
||||
gyro at zero, and the game's request for it (SDL renews it every 3 s) does not win. The layout needs a gyro binding,
|
||||
for example Gyro Behavior "As Mouse"; its activation only decides when Steam itself moves the mouse, the game gets the
|
||||
gyro all the time. Pick an activation the game does not need (a back button), or Steam's mouse turns the camera on top
|
||||
of the game's own motion. Under Steam the Steam Controller's gyro arrives already corrected, so it keeps a bias of its
|
||||
own (`gyro_bias_pad` ends in "(under Steam)").
|
||||
|
||||
## Scripted input
|
||||
|
||||
`TOTK_INPUT_SCRIPT=<file>` replays presses. It is ORed with real input and still applies under `TOTK_INPUT=none`. One event per line, `#` starts a comment:
|
||||
@@ -238,12 +331,14 @@ Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as teste
|
||||
```
|
||||
<frame> <button> [hold_frames] # A B X Y L R ZL ZR PLUS MINUS LEFT UP RIGHT DOWN LCLICK RCLICK; hold defaults to 4
|
||||
<frame> LSTICK|RSTICK <x> <y> [hold_frames] # -32767..32767, up is +y
|
||||
<frame> MOUSE <dx> <dy> # direct-mode raw counts, once; down is +dy
|
||||
<frame> MOUSE <dx> <dy> # raw mouse counts, once; down is +dy
|
||||
@<ms> <button> [hold_ms] # timed on the world clock
|
||||
@<ms> LSTICK|RSTICK <x> <y> [hold_ms]
|
||||
@<ms> MOUSE <dx> <dy>
|
||||
<frame> WHEEL <notches> # scroll wheel notches, once; + away from the player
|
||||
@<ms> WHEEL <notches>
|
||||
<frame> QUICKSAVE|QUICKLOAD # quicksave = 1's save or load key, once
|
||||
@<ms> QUICKSAVE|QUICKLOAD
|
||||
```
|
||||
|
||||
`<frame>` counts 60 Hz ticks of game time since the first frame (presented frames at 60 fps), so the title menus get the presses at the same game time at any frame limit. `@<ms>` counts milliseconds of the world clock: game time stepped since the end of the first save load (the player leaves the title screen's origin), so a timed event lands at the same game time at any frame rate and load length. A later load, such as fast travel, still shifts what follows. In a script with timed lines the untimed ones stop when the world clock starts, as the load ends at another tick in each run. Each event logs once (`input: script frame N tick T: A`). `tools/input/load_save.txt` loads the first save from the title screen.
|
||||
@@ -252,7 +347,10 @@ Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as teste
|
||||
|
||||
In direct mouse mode the recording also writes one `MOUSE` event per consumed raw displacement. These are one-shot
|
||||
displacements rather than held stick segments. They replay without cursor capture, including with `input = none`;
|
||||
the game must be accepting camera input when the event reaches its camera update.
|
||||
the game must be accepting camera input when the event reaches its camera update. Where the mouse acts as the right
|
||||
stick (`mouse_mode = stick`, a camera with no direct hook, the game not accepting camera input), a script's `MOUSE`
|
||||
lines move the right stick as the mouse would, also without cursor capture or with `input = none`, for 100 ms after
|
||||
each line (`mouse_camera` in `runtime/input.c`); spread a turn over lines a frame apart, as a real mouse moves.
|
||||
|
||||
`TOTK_TEST_PAD=<lx>,<ly>,<rx>,<ry>` attaches an SDL virtual gamepad at start whose sticks rest at these raw SDL axis values (-32768 to 32767, down is +y), so a drifting or held stick can be tested without a controller: the values go through the gamepad mapping and `TOTK_STICK_DEADZONE` like a real pad's, and `TOTK_INPUT_RECORD` shows what reached the game.
|
||||
|
||||
|
||||
+86
-53
@@ -1,8 +1,9 @@
|
||||
# Installer
|
||||
|
||||
A public release that turns the player's own game files into a playable TotK folder. The release carries no game
|
||||
data and no code derived from the game: the installer builds the game on the player's machine. The installed folder
|
||||
holds only the game; the installer and its tools stay outside it.
|
||||
data and no code derived from the game: the installer builds the game on the player's machine. On Windows the
|
||||
installed folder also holds the build kit, the installer's tools the game rebuilds itself with for code mods, so the
|
||||
setup folder can be deleted after the install and the install folder moved.
|
||||
|
||||
## What the player does
|
||||
|
||||
@@ -16,7 +17,8 @@ holds only the game; the installer and its tools stay outside it.
|
||||
needed for Chinese, Korean and Traditional Chinese text;
|
||||
- the game language and the install folder.
|
||||
3. Waits for the setup, one time. The window shows each step and its progress.
|
||||
4. Plays `totk.exe` from the install folder. The installer and the source NSP or XCI (or NSZ, XCZ) can be deleted.
|
||||
4. Plays `totk.exe` from the install folder. The setup folder and the source NSP or XCI (or NSZ, XCZ) can be deleted,
|
||||
and the install folder can be moved: code mods rebuild the game with the build kit inside it.
|
||||
|
||||
The install folder (`main.c` `portable_paths()` reads this layout; it stays portable):
|
||||
|
||||
@@ -32,16 +34,25 @@ The install folder (`main.c` `portable_paths()` reads this layout; it stays port
|
||||
logs/ totk.log of the last run, totk.1.log to totk.4.log of the runs before it
|
||||
shader and pipeline caches prepared by the setup; shader-cache/shader-cache.pack holds the translations
|
||||
totk-install.json what built this folder: release version, input hashes, finished steps
|
||||
build-kit/ Windows: the release folder without TotK-Setup.exe (about 0.65 GB); the game's rebuild
|
||||
for code mods runs the setup window from it
|
||||
build-cache/ what the rebuild built in (cheats.status, exefs.status, plugins.status), rebuild.txt,
|
||||
and work/: the generated C, the lift cache and the objects (about 1.6 GB, Windows)
|
||||
```
|
||||
|
||||
## Updating the port
|
||||
|
||||
The player runs a newer installer on the same folder. It reads `totk-install.json`, keeps `romfs/`, `exefs/`,
|
||||
`shared-fonts/`, `profile/` and `totk.ini` after checking their hashes, rebuilds `totk.exe` and re-prepares the
|
||||
shaders. A newer release that changes nothing game-derived skips the rebuild. The window starts with the last install folder
|
||||
and the base, update, keys and firmware paths it ran with (paths only, never the keys file's contents), kept in
|
||||
`%LOCALAPPDATA%\TotK Recomp\setup.json` (`$XDG_STATE_HOME/totk-recomp/setup.json` elsewhere). Entries that no longer exist
|
||||
stay empty. A reinstall or a switch to another game version starts filled in.
|
||||
`shared-fonts/`, `profile/` and `totk.ini` after checking their hashes, replaces `build-kit/` with its own files,
|
||||
rebuilds `totk.exe` and re-prepares the shaders. The setup is an installer and updater: nothing after the install needs
|
||||
its folder. An install made by a setup before the build kit kept its temp folder in that setup's folder
|
||||
(`<setup>/temp/<install name>-<hash>`, the setup `build-cache/rebuild.txt` named); the first newer setup moves it into
|
||||
`build-cache/work` when both are on one disk (on another it starts empty) and writes the new `rebuild.txt`. Until then
|
||||
the old `rebuild.txt` keeps using the old setup folder. A newer release that changes nothing game-derived skips the
|
||||
rebuild. The window starts with the last install folder and the base, update, keys and firmware paths it ran with (paths
|
||||
only, never the keys file's contents), kept in `%LOCALAPPDATA%\TotK Recomp\setup.json`
|
||||
(`$XDG_STATE_HOME/totk-recomp/setup.json` elsewhere). Entries that no longer exist stay empty. A reinstall or a switch
|
||||
to another game version starts filled in.
|
||||
|
||||
Given an update file other than the recorded one (1.1.0, then 1.2.1, then 1.4.3), the installer extracts and builds again from it
|
||||
and keeps `profile/`. Saves carry over both ways between 1.2.1 and 1.4.3: 1.4.3 converts a 1.2.1 save on load, and 1.2.1
|
||||
@@ -53,36 +64,45 @@ loads the saves 1.4.3 wrote.
|
||||
`tools/extract.py`), the keys are new enough for the update, enough space is free on the target disk (about 36 GiB at the peak of a
|
||||
first install, 20 GiB after it), the CPU is at least x86-64-v2 (SSE4.2; with AVX2/FMA the faster `v3` build is used,
|
||||
otherwise the `v2` one), a Vulkan 1.3 GPU exists. Each failure is one clear message.
|
||||
2. **Fonts** with Chinese, Korean or Traditional Chinese text and a firmware folder: extract the Switch system fonts
|
||||
2. **Kit** (Windows): copy the release folder without `TotK-Setup.exe` into `build-kit/` in the install folder
|
||||
(`installer/steps.py` `Kit`, `installer/layout.py` `KIT_ITEMS`); every step after it runs its tools from there, so
|
||||
the commands the build records (the compiler's path in the Ninja file) are the ones the game's rebuild runs later.
|
||||
A newer setup replaces the kit; the kit's own rebuild keeps it. The steps' keys fingerprint file contents, not
|
||||
paths (`runtime_key` leaves out the lines of `clang --version` that name its folder), so a rebuild from the kit
|
||||
or from a moved install folder keeps every step the setup recorded.
|
||||
3. **Fonts** with Chinese, Korean or Traditional Chinese text and a firmware folder: extract the Switch system fonts
|
||||
from the firmware into `shared-fonts/` (MacNativeGames' `extract_shared_fonts.py`, which verifies every NCA layer
|
||||
and BFTTF header). Without a firmware folder the setup warns and goes on; the game then lacks those glyphs.
|
||||
3. **Extract** ExeFS and RomFS into the install folder and verify the hashes.
|
||||
4. **Lift** the ExeFS to C (`recomp/gen.py`, `recomp/patches-v121.txt` or `patches-v143.txt`) into a temp folder next
|
||||
to the installer. The code cheats of the mods' cheat files and the mods' ExeFS patch files become patch sets first
|
||||
(`tools/cheats.py`, `tools/exefs_patches.py`, status in `build-cache/cheats.status` and `exefs.status`); a file the
|
||||
tools refuse costs those cheats or patches, not the install. The patch files' writes into main's data go to
|
||||
`build-cache/exefs.data`, which the game stores into main at start; after the lift they are checked against the
|
||||
bytes the lifted code read as constants (`<gen>/main/folded.txt`, its jump tables).
|
||||
5. **Compile** the generated C, `modules.c`, `romfs.c`, `patches.c` and `ov_zstd.c` (they bake the per-install layout, RomFS
|
||||
4. **Extract** ExeFS and RomFS into the install folder and verify the hashes.
|
||||
5. **Lift** the ExeFS to C (`recomp/gen.py`, `recomp/patches-v121.txt` or `patches-v143.txt`) into the temp folder,
|
||||
`build-cache/work` in the install folder (`.setup-temp` on Linux, `--temp DIR` elsewhere). The code cheats of the
|
||||
mods' cheat files and the mods' ExeFS patch files become patch sets first (`tools/cheats.py`,
|
||||
`tools/exefs_patches.py`, status in `build-cache/cheats.status` and `exefs.status`); a file the tools refuse costs
|
||||
those cheats or patches, not the install. The patch files' writes into main's data go to `build-cache/exefs.data`,
|
||||
which the game stores into main at start; after the lift they are checked against the bytes the lifted code read as
|
||||
constants (`<gen>/main/folded.txt`, its jump tables).
|
||||
6. **Compile** the generated C, `modules.c`, `romfs.c`, `patches.c` and `ov_zstd.c` (they bake the per-install layout, RomFS
|
||||
hashes and the game version's patch page) and link
|
||||
them with the prebuilt runtime library for the host's level (`libtotkrt.a` or `libtotkrt-v2.a`) into `totk.exe`
|
||||
(`build_game.py --runtime-lib`; about 3 min on 24 cores).
|
||||
6. **Prepare** (only when the runtime, the translator or the game version changed, not for a new lift) the RomFS
|
||||
7. **Prepare** (only when the runtime, the translator or the game version changed, not for a new lift) the RomFS
|
||||
patches and the shaders (`tools/make_romfs_patches.py`, `tools/prepare_shaders.py`,
|
||||
`totk.exe --prepare-shaders`) in the install folder, then fold the shader cache's loose files (four per shader, about
|
||||
117,000) into `shader-cache/shader-cache.pack` (`tools/pack_shader_cache.py`). totk.exe reads the pack first and
|
||||
writes the translations it makes in play as loose files; running the tool again with the game closed folds those in.
|
||||
The patches are written three times: `romfs-patches`, `romfs-patches-xbox` and `romfs-patches-xbox-label`
|
||||
The patches are written five times: `romfs-patches`, `romfs-patches-xbox` and `romfs-patches-xbox-label`
|
||||
(`--prompts`: Xbox button prompts for `prompts = xbox`, the first for `pad_layout = nintendo`, the second for `xbox`
|
||||
and `auto`). The prompt folders are optional: when one cannot be made, the setup warns and finishes.
|
||||
and `auto`), `romfs-patches-playstation` and `romfs-patches-playstation-xbox` (PlayStation prompts for
|
||||
`prompts = playstation`, the same split). The prompt folders are optional: when one cannot be made, the setup warns
|
||||
and finishes.
|
||||
**PC prompts** (step `pc_prompts`): `romfs-patches-pc`, the keyboard and mouse prompts for `prompts = pc`, drawn
|
||||
from the `bind_` lines of `totk.ini` (`--binds`). Its key holds those lines, so a setup run after a change of the
|
||||
bindings draws only these again. Optional like the Xbox prompts. All four 16:9 folders are always written, so a
|
||||
bindings draws only these again. Optional like the Xbox prompts. All six 16:9 folders are always written, so a
|
||||
switch of the prompts style at 16:9 needs no setup run.
|
||||
When the graphics driver crashes while building the shaders, `prepare_shaders.py` runs that part again without the
|
||||
variants it was building ([building.md](building.md), step 6), and the setup finishes with a warning that names how
|
||||
many were left out.
|
||||
7. **Shapes**: the UI laid out for each screen shape this player needs, `romfs-patches-<w>x<h>`
|
||||
8. **Shapes**: the UI laid out for each screen shape this player needs, `romfs-patches-<w>x<h>`
|
||||
(`--aspect`), and with Xbox or PC prompts in `totk.ini` that layout with those prompts too,
|
||||
`romfs-patches-<style>-<w>x<h>` (`--prompts <style> --aspect --reuse romfs-patches-<style>`, which hard-links every
|
||||
file but the UI archive; for `pc` with the same `--binds` as the PC prompts step, whose key the step follows). The shapes are those of every connected display (Windows: `EnumDisplayDevices`; Linux:
|
||||
@@ -90,42 +110,51 @@ loads the saves 1.4.3 wrote.
|
||||
`output_res` (`installer/screens.py`). One folder per shape, named after the shape's size in `ASPECT_SIZES` (the
|
||||
closest within 1%; `5120x2160` uses `2560x1080`); `runtime/romfs.c` `overlay_init` maps the game resolution the
|
||||
same way, and a folder of the exact size from an older setup still wins. A 16:9 player gets none. The step runs
|
||||
again when the displays, the prompts or the patches change; at a game resolution whose shape has no folder the
|
||||
game draws 16:9 with bars, and the settings menu marks such sizes and can write the shape's folders in the
|
||||
background for the next start.
|
||||
8. **DLSS** (the window's tick box, on by default, or `--dlss`; Windows with an NVIDIA RTX GPU): download
|
||||
again when the displays, the prompts or the patches change. At a game resolution whose shape has no folder the
|
||||
game draws 16:9 with bars and starts the generator itself, in the background, for the next start: at start and
|
||||
when the settings menu changes the resolution, the HUD width, the prompts or the pad layout
|
||||
(`runtime/romfs.c`, `romfs_folders_prepare`, with the Python and tools that `build-cache/rebuild.txt` names; a
|
||||
missing 16:9 prompts folder too). Those runs use `--background`: below-normal priority, and a folder that has a
|
||||
manifest is never written into. Every `make_romfs_patches.py` run writes `<folder>.part-<pid>` and renames it into
|
||||
place when complete; the clean-up step removes the `.part` folders of stopped runs once they are an hour old.
|
||||
9. **DLSS** (the window's tick box, on by default, or `--dlss`; Windows with an NVIDIA RTX GPU): download
|
||||
`nvngx_dlss.dll` from NVIDIA's own DLSS SDK repository (github.com/NVIDIA/DLSS, a pinned tag, NVIDIA RTX SDK
|
||||
license) into the install folder and check its size and SHA-256 (`steps.py`, `Dlss`). The release does not ship
|
||||
the library; NGX loads it from the folder of totk.exe for `dlaa` and the DLSS modes. A DLSS library already in the
|
||||
folder (a newer one the player put there) is kept. Without an RTX GPU the step only logs and does nothing; a failed
|
||||
download warns, the game runs without DLSS, and the next run of the setup tries again.
|
||||
9. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write
|
||||
10. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write
|
||||
`build-cache/rebuild.txt` in the install folder.
|
||||
|
||||
A cancelled or failed setup resumes from the last finished step (`totk-install.json`).
|
||||
|
||||
## Rebuilding for the mods
|
||||
|
||||
The generated C and the objects stay in the temp folder. The next lift lifts again only the chunks whose inputs
|
||||
changed (the lift cache of `recomp/gen.py`: the patch sites inside a chunk, with their set indices) and rewrites only
|
||||
those whose C changed, and Ninja recompiles only those. A new or edited code cheat costs a few seconds of lift
|
||||
(discovery and a hash of the kept chunks; 7 s for one changed cheat word on 12 cores, against 102 s for the whole lift)
|
||||
and the compile of the chunks that hold its sites, not a full compile, and the shaders stay prepared. A cheat set added
|
||||
or removed before others in the patch file moves their set indices, so the chunks of their sites are lifted too. A
|
||||
change to `recomp/*.py` lifts everything.
|
||||
The generated C and the objects stay in the temp folder, inside the install folder. The next lift lifts again only the
|
||||
chunks whose inputs changed (the lift cache of `recomp/gen.py`: the patch sites inside a chunk, with their set indices)
|
||||
and rewrites only those whose C changed, and Ninja recompiles only those. A new or edited code cheat costs a few seconds
|
||||
of lift (discovery and a hash of the kept chunks; 7 s for one changed cheat word on 12 cores, against 102 s for the
|
||||
whole lift) and the compile of the chunks that hold its sites, not a full compile, and the shaders stay prepared. A
|
||||
cheat set added or removed before others in the patch file moves their set indices, so the chunks of their sites are
|
||||
lifted too. A change to `recomp/*.py` lifts everything.
|
||||
|
||||
`build-cache/rebuild.txt` holds the command that opens the setup window in its rebuild mode on the install folder
|
||||
(`installer/gui.py --rebuild <install folder>`, started through `python -c` so the release folder is on `sys.path`
|
||||
whatever the working folder), one argument per line. When an enabled mod has code cheats or ExeFS patch files the build
|
||||
lacks, `totk.exe` runs it at start and exits (`runtime/cheats.c` `rebuild_if_needed`); the
|
||||
window runs the setup on the folder at once and starts the game again when it succeeds. A failed or cancelled rebuild
|
||||
offers to start the game with the code it has; `build-cache/rebuild.skip` then keeps the same files from starting it
|
||||
again, until "Rebuild the game now" on the Cheats or Mods tab. A command that does not start at all leaves no
|
||||
`rebuild.skip`, so the next start tries it again. `[mods] mods_rebuild = off` turns it off. The rebuild needs the
|
||||
release folder the setup ran from: a moved or deleted release folder means running a setup again. On Linux the command
|
||||
starts the AppImage file itself (`$APPIMAGE --rebuild <install folder>`), because the AppImage's mounted folder is gone
|
||||
once the setup exits; a moved or deleted AppImage means running a setup again. Installs set up by an AppImage before
|
||||
this change hold a command into that mount: running the new setup once on the install folder writes the new one.
|
||||
whatever the working folder), one argument per line. On Windows it names the build kit relative to the install folder
|
||||
(`build-kit\python\pythonw.exe`, `build-kit`, `--rebuild .`): `totk.exe` takes the program from its own folder and
|
||||
starts the command there, so no path of the setup or of the install folder is stored. When an enabled mod has code
|
||||
cheats or ExeFS patch files the build lacks, `totk.exe` runs it at start and exits (`runtime/cheats.c`
|
||||
`rebuild_if_needed`); the window runs the setup on the folder at once and starts the game again when it succeeds. A
|
||||
failed or cancelled rebuild offers to start the game with the code it has; `build-cache/rebuild.skip` then keeps the
|
||||
same files from starting it again, until "Rebuild the game now" on the Cheats or Mods tab. A command that does not start
|
||||
at all leaves no `rebuild.skip`, so the next start tries it again. `[mods] mods_rebuild = off` turns it off. A moved
|
||||
install folder keeps its incremental rebuild: the kit's builds run `tools/build_game.py --portable`, whose Ninja file
|
||||
and deps log name every path relative to the kit (3.5 s to rebuild after a move instead of a full compile). A build with
|
||||
a mod plugin names the plugin's file by its absolute path (`recomp/layout.py`), so after a move the game finds it gone
|
||||
and runs the rebuild once. On Linux the command starts the AppImage file itself (`$APPIMAGE --rebuild <install
|
||||
folder>`), because the AppImage's mounted folder is gone once the setup exits; a moved or deleted AppImage means running
|
||||
a setup again. Installs set up by an AppImage before this change hold a command into that mount: running the new setup
|
||||
once on the install folder writes the new one.
|
||||
|
||||
## Command line
|
||||
|
||||
@@ -148,13 +177,16 @@ python -m installer --base FILE --update FILE --keys FILE --lang CODE --dest DIR
|
||||
resume and update are one rule; output kept from another release is re-hashed first.
|
||||
- Peak space on the install disk is about 36 GiB, not 22: the extraction copies both Program NCAs (16.3 GiB) next to
|
||||
the merged RomFS (15.9 GiB) before it deletes them. The check computes the exact figure.
|
||||
- Window (`python -m installer.gui`, `installer/gui.py` draws, `installer/guilogic.py` decides): form, step list with
|
||||
progress, space line, collapsible log, Cancel (Ctrl+Break to the CLI's process group, then it waits for the exit),
|
||||
finish screen with Open folder. English, Russian, Brazilian Portuguese or Simplified Chinese, chosen from the Windows
|
||||
display language (zh-CN and zh-SG give Chinese; the Traditional Chinese regions give English), switchable in the
|
||||
window; every sentence is an id in `installer/text/<en|ru|pt-BR|zh-Hans>.json`. A Chinese window still starts with
|
||||
English as the game language, because Chinese game text needs the Switch shared fonts, which the setup extracts only
|
||||
from a firmware folder. A folder with
|
||||
- Window (`python -m installer.gui`, `installer/gui.py` draws, `installer/guilogic.py` decides): form (game files and
|
||||
install sections, the explanations under More details, the share notice next to Start) in the Sun Valley ttk theme
|
||||
(`installer/vendor/sv_ttk/`, the platform theme when it does not load), step list with progress, space line,
|
||||
collapsible log, Cancel (Ctrl+Break to the CLI's process group, then it waits for the exit), finish screen with Open
|
||||
folder. English, Russian, Brazilian Portuguese, Simplified Chinese, German, French, Spanish, Italian, Dutch, Japanese
|
||||
or Korean (`guilogic.UI_LANGUAGES`), chosen from the Windows display language (every Chinese, zh-TW and zh-HK
|
||||
included, gives Simplified Chinese; pt-PT and languages without a catalog give English), switchable in the window;
|
||||
every sentence is an id in `installer/text/<lang>.json`. The game language starts as the window's when the game has
|
||||
it; a Chinese or Korean window still starts with English, because that game text needs the Switch shared fonts,
|
||||
which the setup extracts only from a firmware folder. A folder with
|
||||
`totk-install.json` needs only the folder. `--selftest [--shots DIR]` builds every screen in every language and
|
||||
closes itself. The window is not stretched on a display whose scale is the system DPI: `installer/dpi.py` makes the
|
||||
process system DPI aware before Tk starts, Tk then draws the fonts at the display's scale and `dpi.px` sizes the
|
||||
@@ -170,8 +202,9 @@ python -m installer --base FILE --update FILE --keys FILE --lang CODE --dest DIR
|
||||
The unpacked release; `tools/make_release.py` assembles it and `--zip` packs it:
|
||||
|
||||
```
|
||||
TotK-Setup.exe starts python/pythonw.exe -m installer.gui (installer/launcher/launcher.c, no console)
|
||||
installer/ the installer: steps, CLI, window, en/ru/zh-Hans text catalog
|
||||
TotK-Setup.exe starts python/pythonw.exe -m installer.gui (installer/launcher/launcher.c, no console); the
|
||||
rest is what the Kit step copies into the install folder's build-kit/
|
||||
installer/ the installer: steps, CLI, window, text catalogs (text/<lang>.json), Sun Valley theme (vendor/)
|
||||
python/ Python 3.14.9 embeddable + numpy, lz4, cryptography, cffi, pycparser (+ tkinter for the window)
|
||||
recomp/, tools/ the lifter and the build, extraction and shader scripts the steps run (copied from the repo)
|
||||
llvm/ llvm-mingw, x86_64-only subset (Apache-2.0 with LLVM exception; mingw-w64 parts permissive)
|
||||
|
||||
+69
-9
@@ -34,11 +34,27 @@ packs, gameplay and text changes from GameBanana and similar sites, TKMM's merge
|
||||
## Order and switches
|
||||
|
||||
The Mods tab lists every folder in `mods`. Select a mod and press A or Enter to switch it on or off. The top face button
|
||||
or Ctrl+Up moves it up, the left face button or Ctrl+Down moves it down. When two mods change the same file, the
|
||||
higher one wins; the lower mod's row says how many of its files the higher one covers. Changes apply after a restart.
|
||||
or Ctrl+Up moves it up, the left face button or Ctrl+Down moves it down. Changes apply after a restart.
|
||||
|
||||
The menu saves the order and the switches in `totk.ini`, under `[mods]`, by folder name: `mods_order` and
|
||||
`mods_disabled`. A folder the list does not name yet, such as a new or renamed one, goes below the named ones.
|
||||
The order decides every conflict, as in PC mod managers: when two mods change the same game file, the same bytes of the
|
||||
game's data or the same instruction of the game's code, the higher one wins. Moving a mod and restarting is enough; the
|
||||
game is not rebuilt for it. Each row lists what the mod wins and loses, by mod: "3 of its files come from X, which is
|
||||
higher in the list", "It overrides 2 code patch sites of Y, which is lower in the list", and the same for game data.
|
||||
`logs\totk.log` has the same as `mods: X: overrides Y at 2 code sites` and `mods: Y: 2 code sites overridden by X`, and
|
||||
one line per contested code site.
|
||||
|
||||
The menu saves the order and the switches in `totk.ini`, under `[mods]`, by folder name: `mods_order`,
|
||||
`mods_disabled` and `mods_no_code`. A folder the list does not name yet, such as a new or renamed one, goes below the
|
||||
named ones.
|
||||
|
||||
### Mods with code the port cannot run
|
||||
|
||||
Some mods bring code the port cannot run: their own Switch code (a replaced main, or a subsdk plugin the rebuild
|
||||
refused, as it refuses UltraCam's) or a code patch in a form the port cannot apply. Such a mod stays off as a whole, because its other files may expect
|
||||
that code. Under its row the Mods tab then shows **Use <mod> without its code** (off by default). Switched on, the code
|
||||
the port cannot run is left out and the rest of the mod loads after a restart: its game files, cheats and the code
|
||||
patches that work. The mod's row says which part is left out and why. If the game misbehaves with it, switch it off
|
||||
again. `mods_without_code = 1` under `[mods]` holds the switch on for every mod.
|
||||
|
||||
### Mods that change the same files
|
||||
|
||||
@@ -64,17 +80,59 @@ ahead of time, so these patches are built into `totk.exe`:
|
||||
2. Until the rebuild succeeds, the whole mod stays off, its other files included.
|
||||
3. After the rebuild the mod switches on and off from the Mods tab like any other, without another rebuild.
|
||||
|
||||
The rebuild needs the setup folder the game was installed from. When that folder was moved or deleted, run
|
||||
`TotK-Setup.exe` again on the same install folder: it does the same job. `mods_rebuild = off` under `[mods]` in
|
||||
`totk.ini` turns the automatic rebuild off.
|
||||
The rebuild runs from `build-kit` in the game folder, which the setup put there: the setup folder can be deleted
|
||||
and the game folder moved. After a move, a game with a code plugin mod rebuilds once at its next start. A game
|
||||
installed by an older setup (no `build-kit` in its folder) still rebuilds from that setup folder until a newer
|
||||
setup runs once on it.
|
||||
`mods_rebuild = off` under `[mods]` in `totk.ini` turns the automatic rebuild off.
|
||||
|
||||
A code patch over one of the port's own patches (the 60 FPS patch, the resolution patch and the other entries under
|
||||
**Built into the port**) turns that built-in patch off while the mod is on. The mod's row names it.
|
||||
|
||||
When two mods patch the same instruction, the code of the higher one runs there; the other mod's patches run
|
||||
everywhere else. The rebuild builds every mod's patch in, so a new order needs only a restart. Two patch files of one
|
||||
mod that patch the same instruction: the one later by path inside the mod wins, as emulators apply a mod's files in
|
||||
name order, each over the one before. A cheat that changes the same instruction runs instead of both while it is on.
|
||||
|
||||
A patch file may also change the game's data (constants and tables in its `.rodata` and `.data`). Those bytes are
|
||||
stored into the loaded game at start, before it runs. When two mods write the same bytes, the higher one wins,
|
||||
as with files.
|
||||
|
||||
## Code plugins (exefs subsdk)
|
||||
|
||||
Some mods ship their own Switch code as an exlaunch plugin: a file `exefs\subsdk<N>` (The Second Quest's MSFix, Full
|
||||
Inventory Expansion's sort fixer, Quick Weapon Durability). On the Switch the plugin starts with the game and
|
||||
redirects some of the game's instructions into its own code. The port does the same with the plugin's code compiled
|
||||
ahead of time, after the design in [#845](https://github.com/valentderah/totk-pc-recomp/issues/845) by itaskaev2:
|
||||
|
||||
1. The rebuild (the same one as for code patches above) compiles the plugins with the game, then starts the game's
|
||||
code in a service mode that runs only one plugin's start-up (`totk.exe --plugin-init`), twice per plugin, and
|
||||
records which instructions it redirects. Each redirect becomes a code site of the mod, built into `totk.exe`. Each
|
||||
plugin is judged on its own: one that is refused, or whose start-up crashes or never returns, stays off with its
|
||||
reason, and the other plugins are built in.
|
||||
2. At every start each plugin's start-up runs again, before the game's own start-up code, in the same setting: it
|
||||
sees the game's own instructions, as in its service run. Its redirects are compared with the record of the
|
||||
rebuild. When they match, the mod's code sites go on. When they do not, the plugin stays off for this run, the
|
||||
mod's row says why, and the next start runs the rebuild.
|
||||
3. The plugin keeps what its start-up made (its memory, its tables), so its code works as on the Switch. The start
|
||||
costs about 50 ms per plugin; the game runs no differently without a plugin.
|
||||
4. Removing a plugin mod from the mods folder starts the rebuild at the next start, which builds the game without
|
||||
it (half a minute on 12 cores with the lift cache). A plugin mod switched off on the Mods tab only stays off.
|
||||
|
||||
The Mods tab order decides between a plugin and another mod's patch on the same instruction, as for code patches. A
|
||||
plugin site over one of the port's own patches turns that built-in patch off while the mod is on.
|
||||
|
||||
The rebuild refuses a plugin when its start-up or the code its redirects reach needs what the port does not give it:
|
||||
system calls other than the few its start-up needs (memory queries and maps, the clock, debug output), library calls
|
||||
outside a reviewed list (memory and string functions, the heap, text formatting), threads, services or input; a
|
||||
redirect that is not one of exlaunch's hook shapes (inline hook, replace hook, call-site rewrite); or two runs of its
|
||||
start-up that differ in code; or a start-up that crashes the service run or does not return within two minutes. The
|
||||
row then says **Its plugin ... cannot run in the port** with the reason, and the mod stays off; **Use <mod> without its
|
||||
code** uses the rest of it, including its other plugins that were built in. UltraCam stays refused: it hooks the graphics API,
|
||||
reads input and opens sockets.
|
||||
|
||||
`plugin_trace = 1` in `totk.ini` logs the first call into each of a plugin's hooks (`plugins: hook entry ... reached`).
|
||||
|
||||
## Cheats
|
||||
|
||||
A cheat file is part of a mod: `mods\<mod>\cheats\<build id>.txt`, switched cheat by cheat on the Cheats tab. Cheats
|
||||
@@ -113,8 +171,10 @@ keeps its textures at a quarter of the size.
|
||||
| This folder has no romfs, exefs or cheats files. | The archive was unpacked one level too deep (`mods\Mod\Mod\romfs`), or it holds no game files. | Move the folders up so `romfs` sits directly in the mod's folder. |
|
||||
| ... files carry another game version in their names. | The files are named for another update (`.Product.<number>.`) and the game's own files have no such name. They are still served under those names, as on a console, because the game sometimes asks for one; another update's resource size table is the exception and only lends its entries. | Nothing if the mod works. If it does nothing, download its release for your game update. |
|
||||
| Its code patches (exefs) are made for another game version. | The patch files name another update's build id. | Same: get the release for your update. |
|
||||
| This mod brings its own game code (a subsdk plugin or a replaced main). | Mods such as UltraCam ship compiled Switch code. The port cannot load it. | No workaround; the whole mod stays off. |
|
||||
| This mod patches the game code (exefs) in a way the port cannot apply. | The patch writes the game's data, not its code, or changes code in a form the port cannot build. | No workaround; the reason follows on the row. |
|
||||
| This mod brings its own game code (a subsdk plugin or a replaced main). | The mod replaces the game's main code, which the port cannot load. | The whole mod stays off. **Use <mod> without its code** under its row uses the rest of it, which may expect the missing code (see Mods with code the port cannot run). |
|
||||
| Its plugin ... cannot run in the port: ... | The rebuild refused the mod's code plugin; the reason follows (see Code plugins). | The whole mod stays off. **Use <mod> without its code** under its row uses the rest of it. |
|
||||
| Its plugin stays off this time: it started differently from the build. | The plugin redirected other instructions at this start than in the rebuild, for example after the mod was updated in place. | Nothing: the next start runs the rebuild. |
|
||||
| This mod patches the game code (exefs) in a way the port cannot apply. | The patch changes code in a form the port cannot build, or bytes the port cannot change at start. The reason follows on the row. | The whole mod stays off. **Use <mod> without its code** under its row leaves that patch file out and uses the rest of the mod. |
|
||||
| The folder name contains \|. | The mod list uses `\|` between names. | Rename the folder. |
|
||||
|
||||
A mod never stops the game from starting. Whatever the port cannot use is left out and shown on the Mods tab.
|
||||
|
||||
+27
-1
@@ -13,8 +13,10 @@ The built-in table is [recomp/patches-v110.txt](../recomp/patches-v110.txt). The
|
||||
| pooloff | 2 | Widen texture-pool offsets unsigned, covering 2..4 GiB without changing offsets below 2 GiB. Enabled by default; `TOTK_POOL_OFFSET_PATCH=0` retains the original path. |
|
||||
| shadow | 1 | The sun shadow map takes its fixed size from page +92 before rounding. The shadow-resolution setting enables it; `shadow_res=game` leaves the game's sizing. |
|
||||
| cascade | 4 | Read the four sun shadow cascade defaults from page +64..76. Shadow range 100 leaves the original constructor. |
|
||||
| climb | 1 | Climbing speed above 60 fps: the 1.2.1 climb factor in the 1.1.0 climb controller. Follows `TOTK_CLIMB_FIX` and needs the real-time step. |
|
||||
| gears | 2 | The gear rotation check scales its one-frame threshold by the update's frame delta, so shrine gears read as turning above 30 fps. Follows `TOTK_HIGHFPS_FIX`. |
|
||||
|
||||
The table has 12 sets and 50 instruction sites in total. Its existing 889 spin back-edges are unchanged. The new sets use the existing runtime page and settings; no new setting, allocator or renderer path is introduced.
|
||||
The table has 16 sets and 54 instruction sites in total. Its 889 spin back-edges are unchanged. The sets use the existing runtime page and settings; no new setting, allocator or renderer path is introduced.
|
||||
|
||||
The camera sites were cross-checked by normalized instruction-window matching from the local 1.0.0 main. The viewport routine has two matching copies: both are patched. Other sites were checked through their data flow: the equipment timer and its gate, the map clock, the ability clock, the NVN texture storage/package calls, the shadow size publication and the cascade parameter constructor. FOV's s8 is overwritten by the next original instruction; x10 is saved. The cursor sites use the same scratch registers as their 1.2.1 counterparts.
|
||||
|
||||
@@ -39,3 +41,27 @@ python tests/patches_v110_check.py --exefs <local ExeFS directory>
|
||||
Without ExeFS, the test uses synthetic memory and the patch table only. It compares the complete integer/SIMD register state, SP and NZCV of the lifted C and Unicorn for all 17 additions, on and off, at 30/60/120 Hz, including pool offsets immediately below and above 2 GiB and at the end of the 32-bit range. Windows test mappings respect its 64 KiB allocation granularity. With ExeFS it additionally validates every original word and spin target. Extracted images and generated C are local build artifacts, never repository content.
|
||||
|
||||
These checks establish instruction and code-generation contracts. World-scene visual acceptance, texture packs allocating a pool above 2 GiB, physical gyro and comparisons of shadow quality still require gameplay checks.
|
||||
|
||||
## Climbing and gears
|
||||
|
||||
Both sets port their 1.2.1 counterparts in [recomp/patches-v121.txt](../recomp/patches-v121.txt); the comments there explain the formulas.
|
||||
|
||||
**climb**, one site at main+0x19279f0 (1.2.1: main+0x19182cc) in the climb controller's velocity step at main+0x1927948. The site replaces `fmov s1, #1.5` after the shipping factor 1.272 - 0.362 (r - 1), r in s9, s8 = 0.5. The body between prologue and epilogue is word for word the 1.2.1 one: it reads u = max(page +0, r) and gives s0 = max(s0, h), s1 = max(1.5, h). At r >= 1 h stays at or below the shipping factor, so 30 fps and slower keep it bit for bit; at 60 fps the factor becomes 1.4.3's, about 1.8665 instead of 1.453; above 60 fps g(u) takes over. Unlike 1.2.1, the site does not rely on dead registers: a 96-byte stack frame saves x8 and full q5, q6, q7, q16 and q17 and restores them before the original code continues, so only s0 and s1 change. `TOTK_CLIMB_FIX=0` runs the original `fmov`; [frame_step_init](../runtime/frame_rate.c) switches the set off without the real-time step, where the page is not written.
|
||||
|
||||
**gears**, two sites in the ActorCheckRotateModule update at main+0x213eec4 (vtable 0x347e8e8 slot +0x110; 1.2.1: main+0x21350c0). The first, main+0x213eee4, loads the update context's frame delta (x1 + 8) into s12 before the function overwrites x1; the prologue saved d12 at main+0x213eec8, nothing writes s12 before the second site, and callees preserve the low 64 bits of v12. The second, main+0x213f0d4, turns `fdiv s12, s0, s4` into s12 = (s0 / s4) * delta, the RotateStartDeg / 30 threshold scaled by the delta, which the three `fcmp s8, s12` at main+0x213f10c, +0x213f174 and +0x213f1b0 read. It saves full q4 in a 16-byte stack slot and restores it and SP. The set does not read the patch page and works with or without the real-time step; `TOTK_HIGHFPS_FIX=0` keeps both original sites.
|
||||
|
||||
Each original window below occurs once in the 1.1.0 main (addresses and hashes, not game bytes):
|
||||
|
||||
| Window | Length | SHA-256 |
|
||||
| --- | ---: | --- |
|
||||
| +0x19279b0 | 108 bytes | 8262a11c180c734f2692a74e9563140f26d743f0f1f95d31732f975b46c27331 |
|
||||
| +0x213eee4 | 32 bytes | 17487c0fe195655e9a1bcaf49835208bd1ebca86eeef9a2ca0059752f503e378 |
|
||||
| +0x213f0d0 | 28 bytes | d07279a2abea53cffbd8861e95034cd1a5c85edf90f6094c5261ba55da203577 |
|
||||
|
||||
```sh
|
||||
python tests/patches_v110_highfps_check.py
|
||||
python tests/patches_v110_highfps_check.py --cflags=-march=x86-64-v2
|
||||
python tests/patches_v110_highfps_check.py --exefs <local ExeFS directory>
|
||||
```
|
||||
|
||||
The test lifts both sets and runs them against Unicorn on and off, at 30, 60, 120 and 240 Hz and slower steps, with zero and tiny deltas, adjacent ULPs around 0.5 and at each compare threshold, and all 16 NZCV values (3240 cases). It compares all general and full 128-bit SIMD registers, SP, NZCV and the whole scratch memory: only s0/s1 (climb), x1/s12 (gears) and the exact save slots may change. It also compiles [patches.c](../runtime/patches.c) with frame_step_init for the nine combinations of the three switches. With `--exefs` it checks every original word, the shipping constants, the d12 save, the vtable entry and the three compares with their branch targets. These are instruction and switch contracts; climbing and the shrine gears still need checks in the game.
|
||||
@@ -30,6 +30,7 @@ If a PR touches this code, confirm the fix still holds.
|
||||
| lime silhouettes in grass; rectangles in the sky | a target outside the output map must keep its texel; zero-filling it wiped the half-res depth | `vk_pipeline.c` `target_wmask` |
|
||||
| stale grass maps in the far terrain for a second after a hit | write-back of a texture the CPU had rewritten | `vk_texture.c` `write_back` |
|
||||
| cut grass stays standing; fire does not spread (#132) | CPU reads of GPU-rendered textures without an invalidate | `vk_texture.c` `vk_texture_write_back_small`, `nvn_ext.c` `nvn_pool_invalidate` |
|
||||
| gloom damage on clean ground in the Depths with `sync_ahead` | the game read a one-request pixel buffer before the GPU of the frame in flight wrote it | `vk_memory.c` `vk_mem_shadow_read`, from `nvn_ext.c` `nvn_pool_invalidate` |
|
||||
| cloud and fog volumes empty for the session | a one-shot draw skipped instead of waiting for its pipeline | `vk_exec_draw.c` `prepare_draw` |
|
||||
| tile rectangles | storage buffers bound by Ryujinx first-use order, not the c0 slot | `vk_exec_draw.c` `ssbo_slot` |
|
||||
| black dialog background and loading map | 3D targets rejected, the grading LUT never written | `vk_exec.c` `resolve_target` |
|
||||
|
||||
+35
-4
@@ -14,15 +14,25 @@ Many rows below are developer tools that only act together with another setting
|
||||
|
||||
`tests/settings_doc_check.py` fails when a name in `known[]` (`runtime/cfg.c`) is described neither here nor in `totk.ini.example`, or when a default here differs from the code.
|
||||
|
||||
## HUD placement
|
||||
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `hud_width` (default `full`) | `full` places the HUD at the screen's edges; `21:9` or `16:9` constrains it to that centered area on a wider game resolution. A cap that is not narrower than the screen, and 16:9 or taller output, keep the full layout. | Read at start. The Shapes installer step builds the selected cap only for needed screen shapes and button prompts. After a change in the Screen tab an install makes a missing layout in the background; it loads at the next start. If a capped folder is missing the full layout loads with a log message. Explicit overlay overrides and player UI mods keep their precedence. | Safe |
|
||||
|
||||
## Diagnostics and logging
|
||||
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `astc_time` | `1` times the GPU dispatches of each ASTC texture decode and logs the time per block footprint and the largest call. | Adds GPU timestamp queries around every decode; if the queue has no timestamps or no `hostQueryReset`, the log says the decodes are not timed and nothing is measured. | Caution |
|
||||
| `bind_stats` | `1` counts bindings and descriptors per draw of each stage and how much of the bound state changes between draws. | Adds per-draw bookkeeping to the render thread and extra log output; frames get slower. | Caution |
|
||||
| `contact_debug` | `1` draws the contact-shadow factor in grey in place of the picture. | The frame shows a grey debug image while it is set; has no effect when contact shadows are off. | Caution |
|
||||
| `contact_debug` | `1` draws the contact-shadow factor in grey in place of the picture; `2` draws the sun visibility the shadows are scaled by (white in the sun, black in shade and underground). | The frame shows a grey debug image while it is set; has no effect when contact shadows are off. | Caution |
|
||||
| `core_diag` | `1` records why ready guest threads wait for a virtual core and for how long, with a histogram every 60 presents. | Turns on host-call and SVC depth tracking and writes many log lines (one per present over 25 ms); frames get slower. | Caution |
|
||||
| `barrier_merge` (default `0`) | Experimental. `1` keeps a render pass open through the game's Barrier calls that ask only for fragment ordering and texture invalidation, when no draw of the pass can write a storage buffer or image; the next draw that samples a written target gets a by-region barrier in the pass (the feedback layout). In scenes with about a thousand such barriers a frame this cuts the passes from about 1200 to 130 and the GPU time from 24.5 to 7.8 ms. | The game's barrier orders every pixel, the in-pass by-region barrier only the pixel a draw writes: a driver that runs it per screen tile can show flicker or squares at the edges of water, decals or particles. | Caution |
|
||||
| `menu_cursor_log` | `1` logs what the menu cursor code reads at every screen change. | Only adds log lines. | Safe |
|
||||
| `plugin_tick_offset` (default `0`) | Added to every GetSystemTick in the plugin service run (`totk.exe --plugin-init DIR`), so `tools/exefs_plugins.py` can run a plugin's init twice with other ticks and compare the records. | Has no effect outside `--plugin-init`; a plugin's init at the start of the game gets the plain ticks. | Safe |
|
||||
| `plugin_trace` (default `0`) | `1` logs the first call of each entry of a mod plugin's hooks (its callbacks, replace and call targets) as `plugins: hook entry ... reached`. | Each such call goes through a counting step; nothing changes without a mod plugin. | Safe |
|
||||
| `perf_census` (default `1`) | With `TOTK_TRACE=perf` and the import memory mode (`TOTK_MEMORY=import`, the automatic mode on an integrated GPU; the mirror mode of a discrete GPU has its own `mem:` lines instead of the census), `0` turns off the dirty census: the `mem: dirty` lines that count, at every submit, the pages the CPU wrote in the pools the replay binds as buffers. | The census queries the write watch at every submit, 3.5-5 ms of the replay thread a frame on a Steam Deck; with `0` a perf trace measures the frame without that cost, and `tools/perf_summary.py` prints no dirty lines. | Safe |
|
||||
| `perf_slow_ms` (default `50`) | Frames at least this many milliseconds long get a `perf: slow frame` log line with the time blocked per cause. | Changes how many frames are logged; a small value fills the log. | Safe |
|
||||
| `replay_check` | `1` reads every texture read-back a second time after a full drain of the replay queue and compares the two. | Stalls the replay queue at every read-back, so frames get much slower; mismatches are only counted and logged. | Caution |
|
||||
| `resolve_check` | `1` compares every cached pool lookup with the locked lookup and stops on a difference. | Slows every pool lookup; the game stops if the two ever differ. | Caution |
|
||||
@@ -79,6 +89,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `swkbd_test` | `ok` or `cancel` opens the keyboard window and presses OK or Cancel on the first timer tick. | The keyboard window closes by itself. | Caution |
|
||||
| `test_oom` | `<site>:<n>[,...]` fails the first n allocations at a site: `commit` (guest memory), `staging` (upload buffers), `image` (texture images), `chunk` (draw data buffers). | Each forced failure takes the out-of-memory path: a memory release, a wait of 10 ms per retry and log lines; a large n stalls up to 30 s and then ends the game. | Caution |
|
||||
| `test_pad` | `<lx>,<ly>,<rx>,<ry>` attaches a virtual gamepad whose sticks rest at these raw SDL axis values (-32768 to 32767). | The game sees a controller with that drift or deflection; a malformed value is logged and ignored. | Caution |
|
||||
| `test_pad_rumble_ms` | `<n>` gives the `test_pad` gamepad rumble, and each rumble write to it takes n ms, as a slow Bluetooth write does. | Only with `test_pad`; checks that a slow rumble write does not hold up the game thread. | Caution |
|
||||
| `test_prepare_shaders` | `1` translates every recorded shader on all usable CPUs during start. | Start takes longer and fills the shader cache folder; the CPU is fully used while it runs. | Caution |
|
||||
|
||||
## Input
|
||||
@@ -86,6 +97,9 @@ Many rows below are developer tools that only act together with another setting
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `bind_<button>` | Remaps one Switch button or stick direction to `pad:<name>` or `key:<name>` entries; covers `bind_a`, `bind_b`, `bind_x`, `bind_y`, `bind_l`, `bind_r`, `bind_zl`, `bind_zr`, `bind_plus`, `bind_minus`, `bind_left`, `bind_up`, `bind_right`, `bind_down`, `bind_lclick`, `bind_rclick`, `bind_lstick_left`, `bind_lstick_up`, `bind_lstick_right`, `bind_lstick_down`, `bind_rstick_left`, `bind_rstick_up`, `bind_rstick_right`, `bind_rstick_down` and `bind_shake`. | A line replaces every default of that button; button prompts in the game still show the default layout. The Controls tab of the menu writes these lines; `docs/controls.md` lists the entry names. | Safe |
|
||||
| `quicksave` (default `0`) | `1`: `quicksave_key` makes one of the game's autosaves at once and keeps a copy as the quick save (`<profile>/quicksave`), `quickload_key` loads that copy (`runtime/quicksave.c`, game 1.4.3, keyboard and mouse keys only; `docs/controls.md`, "Quick save"). | No menu shows; a line at the top of the picture says *Game saved* or why nothing was saved. Quick save takes one of the game's autosave slots and so replaces the oldest autosave, as the game's own autosaves do (the manual save stays); quick load (about 5 s, the picture held while it runs the game's load list underneath) reloads the quick save, losing the progress since. | Save risk |
|
||||
| `quicksave_key` (default `f6`) | The key of quick save with `quicksave = 1`: a key name of the remapping list (`docs/controls.md`, "Remapping") or `none`; an unknown name is logged and `f6` is used. | While `quicksave = 1` the key reaches no binding. | Safe |
|
||||
| `quickload_key` (default `f7`) | The key of quick load with `quicksave = 1`, as `quicksave_key`; an unknown name is logged and `f7` is used, the same key as `quicksave_key` leaves loading without a key. | While `quicksave = 1` the key reaches no binding; it reloads the quick save, losing the progress since. | Safe |
|
||||
|
||||
## Paths and files
|
||||
|
||||
@@ -96,7 +110,9 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `menu_font_fontconfig` (default `1`) | On Linux, `1` asks fontconfig which font file draws each menu language's name, and `0` keeps the fixed distribution paths (`/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc` and four more). The menu merges that file into its font atlas. | `0` is for a system whose fontconfig resolves to a font the menu's parser cannot read; the log then says `menu: system font ... left out`. Has no effect on Windows, where the file names are fixed, and none on a language the ASCII font already draws. The atlas is rebuilt when the window size or the menu language changes. `TOTK_MENU_FONT` names a file directly and wins over both. | Safe |
|
||||
| `mods_dir` (default `mods`) | Folder that holds one subfolder per player mod, beside `totk.exe`. | Mods found there replace game files; see `docs/mods.md`. | Caution |
|
||||
| `mods_disabled` | Names of mods that are switched off, separated by `\|`. | Listed mods are not applied; the Mods tab writes this line. | Safe |
|
||||
| `mods_order` | Mod names, top first, separated by `\|`; the top mod wins a file that two mods replace. | Changes which mod's file the game gets; unlisted mods go below the listed ones, by name. | Safe |
|
||||
| `mods_no_code` | Names of mods used without their code part, separated by `\|`; the Mods tab's switch "Use ... without its code" writes it. | A listed mod's code modules and the ExeFS patch files the port cannot apply are left out and the rest of the mod loads, where otherwise the whole mod stays off. Its files may expect the missing code. | Caution |
|
||||
| `mods_order` | Mod names, top first, separated by `\|`; the top mod wins a file, a byte of game data or an instruction of game code that two mods change. | Changes which mod's file, data or code the game gets, at the next start; unlisted mods go below the listed ones, by name. | Safe |
|
||||
| `mods_without_code` (default `0`) | `1` uses every mod without its code part, as if `mods_no_code` named them all. | See `mods_no_code`. | Caution |
|
||||
| `pipeline_cache` | Path of the Vulkan pipeline cache file (default `pipeline-cache.bin` beside `totk.exe`). | Moves the cache; a new path starts empty and pipelines are built again. | Caution |
|
||||
| `profile_dir` | Folder of the game profile, which holds the user account id that save data is named after; the default is a `profile` folder beside `totk.exe`, else the build-time path. | Another folder means a different set of saves. | Save risk |
|
||||
| `romfs` | Folder of the game's RomFS (with `romfs.bin`); a relative path is relative to `totk.exe`'s folder. | Without it, a `romfs` folder next to `totk.exe` is used, else the build-time path; a missing image stops the start with a message. | Save risk |
|
||||
@@ -128,6 +144,13 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `dyn_delta` (default `1`) | Records only the pipeline dynamic states (cull mode, depth and stencil tests, vertex input, blend enables, equations and write masks, ...) whose values changed since the last draw in the command buffer, also across pipeline changes; `0` records the full set at every change of pipeline state, as before; `ab` alternates with the `ab` blocks. | Fewer commands per pipeline change on the render and recorder threads; a driver that loses dynamic state across pipeline binds would draw with stale state. `TOTK_TRACE=perf` prints the calls and commands per submission. | Caution |
|
||||
| `feedback` | `0` samples a target that an earlier draw of the same pass wrote with no barrier; `restart` ends and restarts the pass behind a full barrier; otherwise the feedback-loop layout is used when the GPU supports it. | `0` brings back the old behaviour that the barrier fixed, so the picture can break in passes that read a target they draw into; `restart` costs extra passes. | Risky |
|
||||
| `flush_span` (default `0`) | `1` copies one span from the lowest to the highest flushed address of a pool, as an older version did. | Copies far more data to the GPU in crowded towns: an estimated 30-50 ms of GPU time per large copy over PCIe 3.0 x8. | Caution |
|
||||
| `frame_gen` (default `off`) | The frame generator: `off`, or `fsr3`, which brings up AMD FSR 3 frame interpolation and optical flow (FidelityFX SDK 1.1.4) at start; with DLSS off the replay follows the scene and records the motion vectors (the camera's and the moving objects', `fg_objects`), the picture before the HUD and the interpolation of a frame between each two the game draws (`runtime/vk_fg.cpp`). Each frame then goes out as two presents: the generated picture once the GPU has drawn the frame (a timeline wait, not before the pacer's time), the game's half the smoothed interval later (`runtime/vk_backend.c` `present_pair`); `fps_limit` counts the pictures shown and the game draws half, 30 at least (`runtime/frame_rate.c` `frame_step_cap_ns`). Off with DLSS or FSR 3.1 (`scene_upscaler`), `replay_workers` above 0, `sync_ahead = 1` or HDR output, and while a menu background or a loading or event fade is open; the game then draws at the whole limit. The swapchain gets one image more. Applies at once: turned on in the menu, the contexts are made at the next frame (a hitch of about 0.1 s once); turned off, they stay until exit. | The controls answer at the drawn rate, about half a frame later. Costs about 1.5 ms of GPU and 0.6 ms of the replay thread per drawn frame at 1080p (RX 9070, 7900X on 4 cores: 94 drawn without it, 86 drawn and 169 shown with it, no limit). For displays of 120 Hz and more. | Caution |
|
||||
| `fg_test` | Frame generation checks: `1` presents the generated frame in place of the game's, `2` the picture before the HUD. Read at start. | Shows the frames out of their order: for checks only. | Caution |
|
||||
| `fg_debug` | `1`: the generated frames hold the SDK's debug view (motion fields, optical flow, disocclusion). Read at start. | For checks only. | Caution |
|
||||
| `fg_objects` (default `1`) | Frame generation's motion vectors get the per-object pass DLSS uses over the camera's: the moving scene draws (characters, enemies, objects) are drawn again with last frame's blocks (`runtime/vk_exec_draw.c` `vk_mvobj_execute`, `runtime/vk_mvprev.c`). `0`: the camera's motion alone; Link, whom the camera follows, then carries the world's motion and the generated pictures show him twice. Read at start. `dlaa_objmv = 0` also turns the object pass off. | About 0.04 ms of GPU and 0.8 ms of the replay thread per drawn frame (RX 9070, 7900X on 4 cores, field, 1080p: 85.6 drawn with `0`, 80.0 with `1`), half of it the host copy of the uniform snapshot the object pass reads. | Safe |
|
||||
| `fg_shot` | Frame generation shots: a present number, or `w<seconds>` of world time; the window texture, the generated frame and the picture before the HUD of three frames from there go to `fg_shot_dir` as `fg_<present>_<real\|gen\|hudless>.png`. | Writes PNGs. | Safe |
|
||||
| `fg_shot_dir` | Folder for the `fg_shot` PNGs (default the working folder). | Only moves the output. | Safe |
|
||||
| `fg_times` (default `1`) | `0` turns off the GPU timestamps of frame generation's steps; every 600 generated frames a log line gives their GPU times and the replay thread's recording time (median, p99). | Timestamps cost next to nothing. | Safe |
|
||||
| `shadow_snap` (default `1`) | Shadow storage (Linux, Wine): `1` syncs the pools from per-submission write-watch snapshots, each 2 MiB region queried at most once per submission and shared with the texture checks; `0` queries each pool at every part of a submission, as before. | `1` cut the replay thread's write tracking from about 4.4 to 1.3 ms a frame on a Steam Deck; `0` is for comparison runs. Under Wine/Proton the default is `0` until it has been measured there; `1` turns it on. No effect where shadow storage is off (Windows by default). | Caution |
|
||||
| `freeze_idle` (default `60`) | Number of submissions a 2 MiB region stays unwritten before it is made read-only; `0` turns the freeze off. | A larger value keeps more regions writable and costs more write tracking; a write to a frozen region costs about 60 microseconds. | Caution |
|
||||
| `gpl_draw_build` (default `1`) | `0` leaves the missing shader libraries of a waiting draw to its background job instead of building them in parallel at once. | Draws whose pipeline is not ready are skipped meanwhile, until the job finishes. | Caution |
|
||||
@@ -150,15 +173,18 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `vk_no_float64` (default `0`) | `1` clears the 64-bit float feature, so the translator lowers FP64 to FP32. | Shaders change, so the shader cache entries for it are made again; precision of FP64 shaders drops. | Caution |
|
||||
| `vk_ssbo_align` (default unset) | Power of two that storage buffer offsets are treated as needing, to test the unaligned path. | The translator and the draw code round storage offsets down to it; shaders are translated again. | Caution |
|
||||
| `vk_subgroup` (default `32`) | Subgroup size to pin where the driver allows it. | A value other than 32 changes what the translator is told about the GPU, and shaders are translated again. | Caution |
|
||||
| `volume_mask_bias` (default `1`) | `0` leaves the game's water volume mask draws (a volume's front faces tested LEQUAL without depth writes, blended ONE/ONE with reverse subtract) without the depth bias toward the viewer that `vk_pipeline.c` gives them; `ab` alternates with `TOTK_AB`. | Puddles and still water then flicker again where the volume's top face lies on the water surface; a test setting. | Caution |
|
||||
| `vram_headroom` (default `1`) | `0` turns off the spare half-block of video memory that a background thread keeps per memory type. | Texture allocations on the render thread can wait for a new block again. | Caution |
|
||||
| `vs_outs` | `all` declares all 32 vertex shader output locations; otherwise only the union of the paired fragment inputs. | Larger vertex shaders and new pipelines; unwritten outputs read the same as before. | Caution |
|
||||
| `wb_eager` (default `1`) | With `sync_ahead` on, `1` copies small GPU-drawn targets that the game reads back to CPU-readable memory at the end of the frame that drew them, so the write-back at a fence wait does not wait for the GPU; `0` waits as before; `check` reads both ways and compares. Without `sync_ahead` it does nothing. | With `0` the game thread stalls about every ninth frame while the copy queues behind the frame on the GPU, which takes back part of the frame-ahead gain. `check` is slow and for testing. | Caution |
|
||||
| `wb_exact` (default `1`) | `0` decides write-back of GPU-written textures by page only. | A target that shares a page with data the CPU writes can go unwritten, so a name label next to the reticle can blink. | Caution |
|
||||
| `wb_merge` (default `1`) | `0` copies GPU-written ranges back as plain copies instead of writing word by word the words that changed. | In mirror memory mode the GPU's copy can overwrite words the CPU wrote, which breaks effects such as falling rain and waterfall splashes. | Caution |
|
||||
| `wb_merge` (default `1`) | `0` copies GPU-written ranges back as plain copies instead of writing word by word the words that changed; with `shadow = 1` it also leaves ranges the GPU has yet to write back out of the copy into the shadow. | In mirror memory mode, and with `shadow = 1`, the GPU's copy can overwrite words the CPU wrote, which breaks effects such as falling rain and waterfall splashes. | Caution |
|
||||
|
||||
## Motion vectors and DLSS
|
||||
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `dlaa_cam_jitter` (default `1`) | Game 1.4.3: `1` puts the jitter fed to DLSS into the game's camera (the projection's centre terms and the view-projection, where the game copies them into its camera blocks); `0` moves the viewport of the scene's draws instead, as on the other game versions. Needs `ubo_snapshot`. | With `0`, water seen at a low angle flickers with DLAA: the game's full-screen passes rebuild positions with a camera the scene was not drawn with; a test setting. | Caution |
|
||||
| `dlaa_jitter` (default `1`) | `0` turns off the camera jitter fed to DLSS. | DLSS gets no jitter between frames; a test setting. | Caution |
|
||||
| `dlaa_maskdebug` (default `0`) | `1` shows the reactive mask in place of the picture. | The frame shows a debug image while it is set. | Caution |
|
||||
| `dlaa_mv` (default `1`) | `0` sends zero motion vectors to DLSS. | DLSS sees no motion, so moving content can smear; a test setting. | Caution |
|
||||
@@ -166,6 +192,8 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `dlaa_survey` (default `0`) | `1` logs what is drawn into the light target that DLSS reads. | Adds log output and per-draw work. | Caution |
|
||||
| `dlaa_times` (default `0`) | `1` times the DLSS passes on the GPU. | Adds GPU timestamps and log lines. | Caution |
|
||||
| `dlss_reactive` (default `0`) | `1` builds a reactive mask for DLSS where it ran. | Changes how DLSS blends moving areas; a test setting. | Caution |
|
||||
| `fsr3_debug` (default `0`) | With `scene_upscaler = fsr3`: `1` creates the FSR 3.1 context with the SDK's input checks, whose warnings go to the log (the first 32). | Adds checks to every FSR 3.1 dispatch and log lines. | Caution |
|
||||
| `fsr3_view` (default `0`) | With `scene_upscaler = fsr3`: `1` shows FSR 3.1's own debug view of its inputs and state in place of the picture. | The frame shows a debug image while it is set. | Caution |
|
||||
| `mv_check` | Frame interval; every that many DLSS frames copies the light target and motion images to host memory and logs how well the vectors explain the picture. | Costs a GPU-to-host copy and a comparison on the completion thread at each interval. | Caution |
|
||||
| `mv_survey` (default `0`) | `1` notes the uniform blocks of each scene draw and compares them with those of earlier frames. | Adds per-draw work and log output. | Caution |
|
||||
| `mvobj_all` (default `0`) | `1` also lists draws for object motion that read no object blocks (terrain and grass). | More draws are checked and listed, which costs time. | Caution |
|
||||
@@ -180,7 +208,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `mvprev_grow` (default `1`) | `0` keeps only three banks in the previous-frame tables. | Object motion that depends on the other banks is no longer tracked. | Caution |
|
||||
| `mvprev_skip` | Hex bank mask of banks left out of the previous-frame copy, replacing the default. | Different banks are tracked, which changes object motion. | Caution |
|
||||
| `mvprev_trust` | Hex bank mask of banks whose found previous-frame copy is taken without the check. | A copy that does not match is used anyway, which can give wrong motion. | Caution |
|
||||
| `reflex` (default `off`) | `off`, `on`, or `boost`; enables NVIDIA Reflex Low Latency (`VK_NV_low_latency2`) to reduce system input latency. Read at start. | On NVIDIA GPUs supporting the extension, coordinates simulation and presentation cadence to lower latency; `boost` keeps GPU clocks high in CPU-bound scenes. Has no effect on non-NVIDIA GPUs. | Safe |
|
||||
| `reflex` (default `off`) | `off`, `on`, or `boost`; enables NVIDIA Reflex Low Latency (`VK_NV_low_latency2`) to reduce system input latency. Read at start. | On NVIDIA GPUs supporting the extension, coordinates simulation and presentation cadence to lower latency, holding frames to the frame limit the pacer uses (`fps_limit`, the monitor's rate for `display`); `boost` keeps GPU clocks high in CPU-bound scenes. Has no effect on non-NVIDIA GPUs. | Safe |
|
||||
|
||||
## Scheduling and host
|
||||
|
||||
@@ -212,10 +240,13 @@ These names are code patch sets built into the generated game code (`recomp/patc
|
||||
| --- | --- | --- | --- |
|
||||
| `ability_guard` (default `1`) | Patch set that checks the target a Recall or Ultrahand pick hands to the game (1.4.3 main+0x1bd01c4, 1.2.1 main+0x1622bf0) and drops it for that frame where the game's own code would fault on it: the holder, the actor or its component unreadable, or the word the game's reference writes not writable (`runtime/ov_ability.c`). Every other target goes on unchanged; a target that fails UltraTears' live-actor test is only logged (`ability: target kept although ...`). | `0` runs the game's code as shipped: the random crash reading `0xffffffffffffffff` during an ability pick can return. | Risky |
|
||||
| `aspect_patch` (default `0`) | Patch set that feeds the camera the output's aspect ratio when it is not 16:9. | The resolution code switches this set on or off itself at start, so a value here is replaced; the code does not settle what a manual value does. | Unknown |
|
||||
| `audio_drain_fix` (default `1`) | Patch set that sends the game's audio thread back to its command ring after each list (1.2.1 main+0x883780, 1.4.3 main+0x149244), so it takes every queued list per 5 ms audio frame instead of one (#337). Game 1.1.0 has no site and keeps the game's code. | `0` runs the game's code as shipped: above about 200 game updates a second the ring fills, and the game's guard (1.2.1 main+0x9bcdc4) switches the sound commands off until the game is restarted once 300 updates in a row find it full. The guard starts over whenever two audio frames fall between two updates, so by the code it fires only while the audio frames come evenly, 5 ms apart: with `audio = none`, or while the audio device takes nothing and the mixer keeps time by its own timer. The guard's count and the switch have not been read in a run. With a device playing the game kept its sound in every run on Linux with PipeWire and 1024-frame device periods, where the frames come in bursts after each period; on Windows the bursts are read from the code (`gap_ns = 0` in `runtime/audren.c`), not measured; a device with periods of 240 frames or less was not tried and may pace as evenly as the timer. The set acts only when more than one list is queued, so below that rate it seldom changes anything. Measured at `fps_limit = 240` (Linux, PipeWire), seconds with sound with `0` and with `1`. On 1.2.1: without a device 6 of 119 and 111 of 119; with a device 111 of 119 and 112 of 119; with the game's stream paused for 5 s from outside (`pw-cli`, not a real device stalling) 4 of 120 (silent from the pause on, also after the device resumed) and 113 of 119; a pause of 2 s silenced the game with `0`, a pause of 1 s did not. On 1.4.3: without a device 3 of 119 and 113 of 120; with a device 111 of 119 with `0`; with the stream paused for 5 s, in 60 s runs, 3 of 59 and 51 of 59; a pause of 2 s with `0`, 4 of 59. | Safe |
|
||||
| `fixed_res_patch` (default `0`) | Patch set that holds the game's dynamic resolution at 100 percent (the scene tier). | The resolution code switches this set from `dynamic_res` (on at `0`); a manual value is replaced. | Unknown |
|
||||
| `freecam_patch` (default `0`) | Patch set of the hook in the camera component update behind the free camera (`freecam_pad`, `freecam_key`) on game 1.4.3; the *Free camera* row of the Controls tab. Read at start. | `1` puts the hook in the camera update: while the free camera is off it runs the game's own load and one compare. `0` runs the game's code as shipped: the combo and the key do nothing and the game gets the combo's buttons. | Safe |
|
||||
| `fov_patch` (default `0`) | Patch set that scales the camera's vertical view angle by the field-of-view setting. | The resolution code switches this set itself whenever the field of view is not 100 percent; a manual value is replaced. | Unknown |
|
||||
| `mouse_direct_patch` (default `1`) | Patch set of the hooks in the game's camera code behind `mouse_mode = direct` on game 1.4.3. | `0` stops `mouse_mode = direct` from taking effect; other mouse modes are unaffected. | Safe |
|
||||
| `optref_guard` (default `1`) | Patch set that treats a negative value in the optional reference at object +0x6b0 (1.4.3 main+0x1bd01c0, 1.2.1 main+0x1622bec) as absent instead of loading through it (#1005). | `0` runs the game's code as shipped: the random crash reading `0xffffffffffffffff` after minutes to hours of play can return. | Risky |
|
||||
| `patch_output` (default `0`) | Patch set that makes the game use the configured output size for its swapchain and display configuration. | The resolution code switches this set whenever the output differs from the base size; a manual value is replaced. | Unknown |
|
||||
| `patch_scene` (default `0`) | Patch set that makes the game use the configured scene render size. | The resolution code switches this set from the render size setting; a manual value is replaced. | Unknown |
|
||||
| `report_guard` (default `1`) | Patch set on 1.4.3 only: in the model scene's report loop (main+0xa22d8, main+0xa2310) an object whose report handle is negative or whose row index is 0x8000 or more gets coverage 0 for that frame and its handle reset, the path the game takes after every read, instead of reading past the report rows. On valid rows the game's code runs unchanged. | `0` runs the game's code as shipped: a bad row index reads far past the rows and crashes, the class Weeping of the Empire met while using Ultrahand and aiming. | Risky |
|
||||
| `shutter_fix` (default `1`) | Patch set on 1.4.3 only (set `shutter`, main+0x25e55d0): the speed the AI node QueryBlackboardGetF32FromActorForOunce returns is scaled by 1 + 0.065 x (1 - frame ratio)^2 when the actor's shouldUseOunceSpeed flag is set, which only the two launchers of Tenbez Shrine (Dungeon034) set (#1215). Every other actor gets its value unchanged; 1.0 at 30 fps and below. | `0` runs the game's code: above about 45 fps the ball leaves the launcher too slowly and stays on the rim of the other launcher or falls into the pit. Measured: on dev at 60 fps the ball stuck from the first shots; with the set at 60 and 120 fps it went back and forth as at 30. | Safe |
|
||||
@@ -42,6 +42,8 @@ do one run with it and one without (`set TOTK_VK_VALIDATION=`).
|
||||
If the game stops with a lost device (the log says `device lost` or `VK_ERROR_DEVICE_LOST`), the lines starting with
|
||||
`vk: pass marks` name the render pass or dispatch the GPU was running. AMD GPUs write them by default. On an NVIDIA GPU,
|
||||
`set TOTK_PASS_CRUMBS=1` (or GPU pass marks: On in the Advanced tab) before the run that reproduces the crash.
|
||||
`set TOTK_ADDR_REPORT=1` adds `vk: fault address` lines naming the image or buffer at the faulting address; it slows
|
||||
the game down over a session, so use it only for that run.
|
||||
|
||||
The game keeps running behind other windows (`assume_focus = 0` in `totk.ini` pauses it instead). Shaders the preparation did not cover compile on first use, so
|
||||
the first minutes of play can stutter.
|
||||
|
||||
+7
-17
@@ -12,7 +12,6 @@ line, 3 cancelled (Ctrl+C or Ctrl+Break).
|
||||
Windows with an NVIDIA RTX GPU (steps.py, Dlss).
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
@@ -22,7 +21,7 @@ from . import layout as layouts
|
||||
from . import state as statefile
|
||||
from .events import Reporter
|
||||
from .runner import Context, run_steps
|
||||
from .steps import all_steps, migrate_state
|
||||
from .steps import adopt_old_temp, all_steps, migrate_state
|
||||
|
||||
EXIT = {'ok': 0, 'failed': 1, 'cancelled': 3}
|
||||
|
||||
@@ -33,17 +32,6 @@ class Parser(argparse.ArgumentParser):
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
# The temp folder inside the install folder when the layout names none (the Linux release); the check step does not
|
||||
# count it when it requires an empty install folder
|
||||
TEMP_IN_DEST = '.setup-temp'
|
||||
|
||||
|
||||
def temp_folder(base, dest):
|
||||
"""One temp folder per install folder, so two installs never share generated files."""
|
||||
tag = hashlib.sha256(str(dest).lower().encode()).hexdigest()[:8]
|
||||
return base / f'{dest.name or "root"}-{tag}'
|
||||
|
||||
|
||||
def cancel(signum, frame):
|
||||
raise KeyboardInterrupt
|
||||
|
||||
@@ -58,8 +46,8 @@ def main(argv=None):
|
||||
ap.add_argument('--lang', help='game language, a Switch language code (en-US, en-GB, ja, de, ru, ...)')
|
||||
ap.add_argument('--dest', type=Path, required=True, help='install folder')
|
||||
ap.add_argument('--root', type=Path, help='release folder or repository (default: the folder above installer/)')
|
||||
ap.add_argument('--temp', type=Path, help='temp folder (default: temp/ of the release on Windows, .setup-temp in '
|
||||
'the install folder on Linux, build/install-temp in a repository)')
|
||||
ap.add_argument('--temp', type=Path, help='temp folder (default: build-cache/work in the install folder on Windows, '
|
||||
'.setup-temp there on Linux, build/install-temp in a repository)')
|
||||
ap.add_argument('--verify', action='store_true', help='hash every kept file, also those this release made')
|
||||
ap.add_argument('--dlss', action='store_true', help="download NVIDIA's nvngx_dlss.dll (NVIDIA RTX SDK license) next "
|
||||
'to the game, for dlaa and the DLSS modes')
|
||||
@@ -72,10 +60,12 @@ def main(argv=None):
|
||||
signal.signal(getattr(signal, name), cancel)
|
||||
layout = layouts.find(args.root)
|
||||
dest = args.dest.resolve()
|
||||
base = args.temp or layout.temp
|
||||
temp = temp_folder(base.resolve(), dest) if base else dest / TEMP_IN_DEST
|
||||
temp = layouts.temp_for(layout, dest, args.temp)
|
||||
adopted = adopt_old_temp(layout, dest, temp)
|
||||
log = temp / 'logs' / time.strftime('install-%Y%m%d-%H%M%S.log')
|
||||
rep = Reporter(log_path=log)
|
||||
if adopted:
|
||||
rep.log(adopted)
|
||||
t0 = time.monotonic()
|
||||
try:
|
||||
state = statefile.load(dest)
|
||||
|
||||
+135
-38
@@ -3,11 +3,11 @@
|
||||
A front end over the CLI (docs/installer.md): it collects the game files, the keys file path, the optional firmware
|
||||
folder, the game language and the install folder, runs `python -m installer ...` as a subprocess and shows its JSON
|
||||
events. Decisions live in guilogic.py; this file only draws. The window text is in
|
||||
installer/text/<en|ru|pt-BR|zh-Hans>.json under "ui.*" and "launcher.*" ids. On Windows the window follows the
|
||||
installer/text/<lang>.json under "ui.*" and "launcher.*" ids. On Windows the window follows the
|
||||
display's DPI (installer/dpi.py): fonts and paddings grow with the scale, so Windows does not stretch it.
|
||||
|
||||
--selftest [--shots DIR] build every screen in every language and close by itself (PNG per screen with --shots)
|
||||
--lang en|ru|pt-BR|zh-Hans window language (default: the Windows display language)
|
||||
--lang en|ru|pt-BR|zh-Hans|de|fr|es|it|nl|ja|ko window language (default: the Windows display language)
|
||||
--rebuild DIR rebuild the install folder DIR for its mods (totk.exe starts this, build-cache/rebuild.txt):
|
||||
the run starts at once with that folder, and the game starts again when it succeeds
|
||||
"""
|
||||
@@ -28,6 +28,7 @@ dpi.enable()
|
||||
|
||||
import tkinter as tk # noqa: E402 (after dpi.enable, see above)
|
||||
from tkinter import filedialog, messagebox, ttk # noqa: E402
|
||||
from tkinter import font as tkfont # noqa: E402
|
||||
|
||||
try:
|
||||
from PIL import ImageGrab # only the screenshots of --selftest --shots need it; the release has no PIL
|
||||
@@ -43,11 +44,15 @@ from .guilogic import (DONE, FAILED, PENDING, RUNNING, SKIPPED, UI_LANGUAGE_LABE
|
||||
POLL_MS = 100
|
||||
GLYPH = {PENDING: '\u25cb', RUNNING: '\u25b6', DONE: '\u2714', SKIPPED: '\u2013', FAILED: '\u2716'}
|
||||
COLOR = {PENDING: '#808080', RUNNING: '#1a5fb4', DONE: '#26a269', SKIPPED: '#808080', FAILED: '#c01c28'}
|
||||
HEADING = '#303030' # section titles, the details link and the update line: dark grey, no accent colour
|
||||
MUTED = '#6b6b6b' # secondary text: the details and the footer notice
|
||||
# The window's pixels at 100%: Tk scales the fonts by itself (tk scaling), these through installer/dpi.py.
|
||||
PAD = dpi.px(14) # padding of the window and its frames
|
||||
WRAP = dpi.px(620) # wrap width of the long labels
|
||||
|
||||
RECENT_WAIT = 1.5 # seconds the window waits for the recorded paths
|
||||
# Sun Valley, the Windows 11 look for ttk (sv-ttk 2.6.1, MIT, unmodified; THIRD_PARTY_NOTICES.md)
|
||||
SUN_VALLEY = Path(__file__).resolve().parent / 'vendor' / 'sv_ttk' / 'sv.tcl'
|
||||
|
||||
|
||||
def load_recent(wait=RECENT_WAIT):
|
||||
@@ -69,6 +74,46 @@ def fix_tcl_paths():
|
||||
os.environ[var] = str(tcl / lib)
|
||||
|
||||
|
||||
def use_sun_valley(root, ui_font):
|
||||
"""Switch the window to the light Sun Valley theme; False leaves the platform theme when it does not load.
|
||||
|
||||
The theme sizes its fonts in pixels, which Tk does not scale with the display; they are turned into points (96 DPI
|
||||
pixels * 0.75) so they grow with tk scaling like the rest of the window. Its Segoe UI Variable families exist on
|
||||
Windows 11 only; elsewhere the fonts take `ui_font`, bold where the theme asked for Semibold. The theme's images
|
||||
(check boxes, button and field borders) stay at their 100% pixel size.
|
||||
|
||||
sv.tcl answers <<ThemeChanged>> with configure_colors, whose tk_setPalette writes the theme's text and background
|
||||
colour into every widget and into the option database, over the colours of our label styles (errors, notices,
|
||||
muted text). The binding is dropped before the switch and the ttk half of configure_colors is done here."""
|
||||
try:
|
||||
root.tk.call('source', str(SUN_VALLEY))
|
||||
root.bind_class('Tk', '<<ThemeChanged>>', '')
|
||||
style = ttk.Style(root)
|
||||
style.theme_use('sun-valley-light')
|
||||
c = {k: root.tk.call('set', f'ttk::theme::sv_light::colors(-{k})') for k in ('fg', 'bg', 'disfg', 'selfg', 'selbg')}
|
||||
style.configure('.', background=c['bg'], foreground=c['fg'], troughcolor=c['bg'], focuscolor=c['selbg'],
|
||||
selectbackground=c['selbg'], selectforeground=c['selfg'], insertwidth=1, insertcolor=c['fg'],
|
||||
fieldbackground=c['bg'], font='SunValleyBodyFont', borderwidth=0, relief='flat')
|
||||
style.map('.', foreground=[('disabled', c['disfg'])])
|
||||
root.configure(background=c['bg'])
|
||||
for cls in ('TEntry', 'TCombobox'): # config_entry_font sets this only on fields that exist at the switch
|
||||
root.option_add(f'*{cls}.font', 'SunValleyBodyFont')
|
||||
except (tk.TclError, OSError):
|
||||
return False
|
||||
families = set(root.tk.splitlist(root.tk.call('font', 'families')))
|
||||
for name in root.tk.splitlist(root.tk.call('font', 'names')):
|
||||
if not str(name).startswith('SunValley'):
|
||||
continue
|
||||
f = tkfont.nametofont(str(name), root=root)
|
||||
size = int(f.cget('size'))
|
||||
if size < 0:
|
||||
f.configure(size=round(-size * 0.75))
|
||||
family = f.cget('family')
|
||||
if family not in families:
|
||||
f.configure(family=ui_font, weight='bold' if 'Semibold' in family else 'normal')
|
||||
return True
|
||||
|
||||
|
||||
class App:
|
||||
def __init__(self, root, ui_lang, layout, run_args=None, rebuild=None):
|
||||
self.root, self.layout = root, layout
|
||||
@@ -102,11 +147,21 @@ class App:
|
||||
root.protocol('WM_DELETE_WINDOW', self.on_close)
|
||||
self.ui_font = 'Segoe UI' if os.name == 'nt' else 'DejaVu Sans'
|
||||
self.mono_font = 'Consolas' if os.name == 'nt' else 'DejaVu Sans Mono'
|
||||
self.sun_valley = use_sun_valley(root, self.ui_font)
|
||||
# A read-only combobox selects its text when a value is picked (ttk::combobox::SelectEntry), which draws the
|
||||
# value as highlighted text; the pick clears that selection once ttk has made it
|
||||
root.bind_class('TCombobox', '<<ComboboxSelected>>',
|
||||
lambda e: e.widget.after_idle(e.widget.selection_clear), add='+')
|
||||
style = ttk.Style(root)
|
||||
style.configure('Title.TLabel', font=(self.ui_font, 15, 'bold'))
|
||||
style.configure('Notice.TLabel', background='#fff3cd', foreground='#664d03', padding=dpi.px(8))
|
||||
style.configure('Err.TLabel', foreground='#c01c28')
|
||||
style.configure('Version.TLabel', foreground='#808080')
|
||||
style.configure('Section.TLabel', foreground=HEADING, font=(self.ui_font, 10, 'bold'))
|
||||
style.configure('Muted.TLabel', foreground=MUTED)
|
||||
style.configure('Link.TLabel', foreground=HEADING)
|
||||
style.configure('Status.TLabel', foreground=HEADING)
|
||||
style.configure('Main.TButton', padding=(dpi.px(16), dpi.px(4))) # Start: the native button, larger
|
||||
|
||||
top = ttk.Frame(root, padding=(PAD, PAD, PAD, 0))
|
||||
top.pack(fill='x')
|
||||
@@ -179,7 +234,7 @@ class App:
|
||||
code = self.selected_lang()
|
||||
self.retext()
|
||||
self.vars['lang'].set(self.lang_label(code))
|
||||
self.fit()
|
||||
self.fit(shrink=True)
|
||||
|
||||
def lang_label(self, code):
|
||||
return self.cat('lang.' + code)
|
||||
@@ -205,81 +260,117 @@ class App:
|
||||
f.pack_forget()
|
||||
self.frames[name].pack(fill='both', expand=True)
|
||||
self.screen = name
|
||||
self.fit()
|
||||
self.fit(shrink=True)
|
||||
|
||||
def fit(self):
|
||||
"""Size the window to its largest screen (an unpacked frame still reports the size its children ask for), so
|
||||
a screen or language switch neither cuts text nor moves the buttons. The window only grows: opening the log
|
||||
makes it taller, and a size the user dragged it to stays. Every text change that can add lines calls it again,
|
||||
or pack takes the missing height from the button bars."""
|
||||
def fit(self, shrink=False):
|
||||
"""Size the window: the width of the widest screen (an unpacked frame still reports the size its children ask
|
||||
for), so a screen or language switch does not move the buttons sideways, and the height of the shown screen,
|
||||
so no screen carries the empty band of a taller one. Every text change that can add lines calls it again, or
|
||||
pack takes the missing height from the button bars. Without `shrink` the window only grows and a size the user
|
||||
dragged it to stays; a screen or language switch and closing the details or the log shrink it to fit."""
|
||||
self.root.update_idletasks()
|
||||
sizes = [(f.winfo_reqwidth(), f.winfo_reqheight()) for f in self.frames.values()]
|
||||
widths = [f.winfo_reqwidth() for f in self.frames.values()]
|
||||
shown = self.frames[self.screen] if self.screen else max(self.frames.values(), key=lambda f: f.winfo_reqheight())
|
||||
chrome = self.root.winfo_reqheight() - self.body.winfo_reqheight() # the title row above the body
|
||||
w = max(self.root.winfo_reqwidth(), max(s[0] for s in sizes) + 2 * PAD)
|
||||
h = chrome + max(s[1] for s in sizes) + 2 * PAD
|
||||
if (w, h) == self.fitted: # refresh_run calls it on every poll: leave the window alone while nothing grew
|
||||
w = max(self.root.winfo_reqwidth(), max(widths) + 2 * PAD)
|
||||
h = chrome + shown.winfo_reqheight() + 2 * PAD
|
||||
# refresh_run calls it on every poll: leave the window alone while nothing grew
|
||||
if (w, h) == self.fitted and (not shrink or self.root.winfo_height() == h):
|
||||
return
|
||||
self.fitted = (w, h)
|
||||
self.root.minsize(w, h)
|
||||
self.root.geometry(f'{max(w, self.root.winfo_width())}x{max(h, self.root.winfo_height())}')
|
||||
self.root.geometry(f'{max(w, self.root.winfo_width())}x{h if shrink else max(h, self.root.winfo_height())}')
|
||||
|
||||
def notice(self, parent):
|
||||
w = ttk.Label(parent, style='Notice.TLabel', wraplength=WRAP, justify='left')
|
||||
self.bind_text(w, 'text', 'ui.notice')
|
||||
return w
|
||||
|
||||
def section(self, grid, row, id, top):
|
||||
"""A section title across the form grid with a rule after it."""
|
||||
head = ttk.Frame(grid)
|
||||
head.grid(row=row, column=0, columnspan=3, sticky='ew', pady=(top, dpi.px(2)))
|
||||
self.label(head, id, style='Section.TLabel').pack(side='left')
|
||||
ttk.Separator(head).pack(side='left', fill='x', expand=True, padx=(dpi.px(8), 0), pady=(dpi.px(2), 0))
|
||||
|
||||
def build_form(self):
|
||||
f = ttk.Frame(self.body)
|
||||
gap = dpi.px(4) # between the form's rows
|
||||
bar = ttk.Frame(f) # packed first so pack shrinks the text above it, never the buttons
|
||||
# The footer goes first so pack shrinks the text above it, never the button. The notice sits next to Start,
|
||||
# where the player looks before the build begins, in quiet text instead of a banner over the form.
|
||||
bar = ttk.Frame(f)
|
||||
bar.pack(side='bottom', fill='x', pady=(dpi.px(12), 0))
|
||||
self.start_button = self.button(bar, 'ui.start', self.start)
|
||||
self.start_button.pack(side='right')
|
||||
self.start_button = self.button(bar, 'ui.start', self.start, style='Main.TButton')
|
||||
self.start_button.pack(side='right', anchor='s')
|
||||
self.label(bar, 'ui.notice', style='Muted.TLabel', wraplength=dpi.px(470),
|
||||
justify='left').pack(side='left', anchor='w', padx=(0, dpi.px(12)))
|
||||
ttk.Separator(f).pack(side='bottom', fill='x', pady=(dpi.px(10), 0))
|
||||
# The status lines sit on the footer: a window taller than the form leaves its spare height above them
|
||||
self.form_error = ttk.Label(f, style='Err.TLabel', wraplength=WRAP, justify='left')
|
||||
self.form_error.pack(side='bottom', anchor='w', pady=(dpi.px(4), 0))
|
||||
self.update_hint = ttk.Label(f, style='Status.TLabel', wraplength=WRAP, justify='left')
|
||||
self.update_hint.pack(side='bottom', anchor='w', pady=(dpi.px(8), 0))
|
||||
self.form_intro = self.label(f, 'ui.intro', wraplength=WRAP, justify='left')
|
||||
self.form_intro.pack(anchor='w', pady=(0, dpi.px(8)))
|
||||
self.notice(f).pack(fill='x', pady=(0, dpi.px(10)))
|
||||
self.form_intro.pack(anchor='w', pady=(0, dpi.px(4)))
|
||||
grid = ttk.Frame(f)
|
||||
grid.pack(fill='x')
|
||||
grid.columnconfigure(1, weight=1)
|
||||
self.section(grid, 0, 'ui.section_files', dpi.px(6))
|
||||
rows = (('base', 'ui.base', 'ui.pick_game'), ('update', 'ui.update', 'ui.pick_update'),
|
||||
('keys', 'ui.keys', 'ui.pick_keys'))
|
||||
self.form_rows = {}
|
||||
for i, (name, label_id, pick_id) in enumerate(rows):
|
||||
for i, (name, label_id, pick_id) in enumerate(rows, start=1):
|
||||
lab = self.label(grid, label_id)
|
||||
lab.grid(row=i, column=0, sticky='w', pady=gap, padx=(0, dpi.px(10)))
|
||||
lab.grid(row=i, column=0, sticky='w', pady=gap, padx=(0, dpi.px(12)))
|
||||
ttk.Entry(grid, textvariable=self.vars[name]).grid(row=i, column=1, sticky='ew', pady=gap)
|
||||
b = self.button(grid, 'ui.browse', lambda n=name, p=pick_id: self.pick_file(n, p))
|
||||
b.grid(row=i, column=2, padx=(dpi.px(8), 0))
|
||||
self.form_rows[name] = lab
|
||||
i = len(rows)
|
||||
self.label(grid, 'ui.firmware').grid(row=i, column=0, sticky='w', pady=gap)
|
||||
i = len(rows) + 1
|
||||
self.label(grid, 'ui.firmware').grid(row=i, column=0, sticky='w', pady=gap, padx=(0, dpi.px(12)))
|
||||
ttk.Entry(grid, textvariable=self.vars['firmware']).grid(row=i, column=1, sticky='ew', pady=gap)
|
||||
self.button(grid, 'ui.browse', self.pick_firmware).grid(row=i, column=2, padx=(dpi.px(8), 0))
|
||||
i += 1
|
||||
self.label(grid, 'ui.game_language').grid(row=i, column=0, sticky='w', pady=gap)
|
||||
self.section(grid, i + 1, 'ui.section_install', dpi.px(12))
|
||||
i += 2
|
||||
self.label(grid, 'ui.game_language').grid(row=i, column=0, sticky='w', pady=gap, padx=(0, dpi.px(12)))
|
||||
self.lang_box = ttk.Combobox(grid, textvariable=self.vars['lang'], state='readonly', width=30)
|
||||
self.lang_box.grid(row=i, column=1, sticky='w', pady=gap)
|
||||
self.lang_touched = False
|
||||
self.lang_box.bind('<<ComboboxSelected>>', lambda _e: setattr(self, 'lang_touched', True))
|
||||
self.fill_languages()
|
||||
self.label(grid, 'ui.dest').grid(row=i + 1, column=0, sticky='w', pady=gap)
|
||||
self.label(grid, 'ui.dest').grid(row=i + 1, column=0, sticky='w', pady=gap, padx=(0, dpi.px(12)))
|
||||
ttk.Entry(grid, textvariable=self.vars['dest']).grid(row=i + 1, column=1, sticky='ew', pady=gap)
|
||||
self.button(grid, 'ui.browse', self.pick_dest).grid(row=i + 1, column=2, padx=(dpi.px(8), 0))
|
||||
self.label(f, 'ui.compressed_help', wraplength=WRAP, justify='left').pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
self.label(f, 'ui.firmware_help', wraplength=WRAP, justify='left').pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
# On by default and named with its source and licence: the player sees what is downloaded and can untick it
|
||||
# On by default and named with its source and licence: the player sees what is downloaded and can untick it.
|
||||
# The source and licence line is the first one under More details.
|
||||
self.dlss_var = tk.BooleanVar(value=True)
|
||||
dlss = ttk.Checkbutton(f, variable=self.dlss_var)
|
||||
self.bind_text(dlss, 'text', 'ui.dlss')
|
||||
dlss.pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
self.label(f, 'ui.dlss_help', wraplength=WRAP, justify='left').pack(anchor='w', padx=(dpi.px(22), 0))
|
||||
self.update_hint = ttk.Label(f, wraplength=WRAP, justify='left')
|
||||
self.update_hint.pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
self.form_error = ttk.Label(f, style='Err.TLabel', wraplength=WRAP, justify='left')
|
||||
self.form_error.pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
self.label(f, 'ui.keys_private', wraplength=WRAP, justify='left').pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
dlss.pack(anchor='w', pady=(dpi.px(12), 0))
|
||||
# The explanations stay out of the way until asked for: a link opens them under it
|
||||
self.details_toggle = ttk.Label(f, style='Link.TLabel', cursor='hand2', takefocus=True)
|
||||
self.bind_text(self.details_toggle, 'text', 'ui.more_details')
|
||||
for seq in ('<Button-1>', '<Return>', '<space>'):
|
||||
self.details_toggle.bind(seq, lambda _e: self.toggle_details())
|
||||
self.details_toggle.pack(anchor='w', pady=(dpi.px(8), 0))
|
||||
self.details = ttk.Frame(f) # packed after the link when open; no holder frame, as an emptied Tk frame keeps
|
||||
# the height its last child gave it
|
||||
for id in ('ui.dlss_help', 'ui.formats_help', 'ui.compressed_help', 'ui.firmware_help', 'ui.keys_private'):
|
||||
self.label(self.details, id, style='Muted.TLabel', wraplength=WRAP - dpi.px(16),
|
||||
justify='left').pack(anchor='w', pady=(dpi.px(6), 0))
|
||||
self.details_open = False
|
||||
return f
|
||||
|
||||
def toggle_details(self):
|
||||
self.details_open = not self.details_open
|
||||
if self.details_open:
|
||||
self.details.pack(after=self.details_toggle, fill='x', padx=(dpi.px(16), 0))
|
||||
else:
|
||||
self.details.pack_forget()
|
||||
self.bound = [b for b in self.bound if b[0] is not self.details_toggle]
|
||||
self.bind_text(self.details_toggle, 'text', 'ui.fewer_details' if self.details_open else 'ui.more_details')
|
||||
self.fit(shrink=not self.details_open)
|
||||
|
||||
def build_run(self):
|
||||
f = ttk.Frame(self.body)
|
||||
bar = ttk.Frame(f)
|
||||
@@ -530,7 +621,7 @@ class App:
|
||||
self.log_frame.pack_forget()
|
||||
self.bound = [b for b in self.bound if b[0] is not self.log_toggle]
|
||||
self.bind_text(self.log_toggle, 'text', 'ui.hide_log' if self.log_open else 'ui.show_log')
|
||||
self.fit()
|
||||
self.fit(shrink=not self.log_open)
|
||||
|
||||
def clear_log(self):
|
||||
self.log_entries = []
|
||||
@@ -596,6 +687,7 @@ class App:
|
||||
self.open_button.state(['!disabled'])
|
||||
else:
|
||||
self.open_button.state(['disabled' if not Path(m.dest or '.').is_dir() else '!disabled'])
|
||||
self.fit() # an error text can be longer than the screen it replaces
|
||||
|
||||
def start_game(self):
|
||||
"""Starts the game of the install folder and closes the window."""
|
||||
@@ -687,6 +779,9 @@ def selftest(layout, shots=None):
|
||||
app.start() # missing files: shows the problems
|
||||
steps.append(app.form_error.cget('text'))
|
||||
shot(f'form-{tag}')
|
||||
app.toggle_details()
|
||||
shot(f'form-details-{tag}')
|
||||
app.toggle_details()
|
||||
app.model = Model()
|
||||
app.clear_log()
|
||||
app.build_step_rows(app.model.steps)
|
||||
@@ -746,7 +841,9 @@ def main(argv=None):
|
||||
return selftest(layout, args.shots)
|
||||
fix_tcl_paths()
|
||||
root = tk.Tk()
|
||||
App(root, args.lang or windows_ui_language(), layout, rebuild=args.rebuild)
|
||||
# resolved now: the game starts the build kit's rebuild with the install folder as '.' and the working folder
|
||||
rebuild = args.rebuild.resolve() if args.rebuild else None
|
||||
App(root, args.lang or windows_ui_language(), layout, rebuild=rebuild)
|
||||
root.mainloop()
|
||||
return 0
|
||||
|
||||
|
||||
+35
-22
@@ -24,17 +24,22 @@ from . import state as statefile
|
||||
from .events import render
|
||||
|
||||
TEXT = Path(__file__).resolve().parent / 'text'
|
||||
UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans')
|
||||
UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans', 'de', 'fr', 'es', 'it', 'nl', 'ja', 'ko')
|
||||
# what the language switch in the window's corner shows for each
|
||||
UI_LANGUAGE_LABELS = {'en': 'English', 'ru': 'Русский', 'pt-BR': 'Português (Brasil)', 'zh-Hans': '简体中文'}
|
||||
STEP_ORDER = ('check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', 'cleanup')
|
||||
UI_LANGUAGE_LABELS = {'en': 'English', 'ru': 'Русский', 'pt-BR': 'Português (Brasil)', 'zh-Hans': '简体中文',
|
||||
'de': 'Deutsch', 'fr': 'Français', 'es': 'Español', 'it': 'Italiano', 'nl': 'Nederlands',
|
||||
'ja': '日本語', 'ko': '한국어'}
|
||||
STEP_ORDER = ('check', 'kit', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss',
|
||||
'cleanup')
|
||||
# message parameter -> catalog id prefix of the names that replace its raw values
|
||||
PARAM_NAMES = {'lang': 'lang.', 'known': 'lang.', 'step': 'step.', 'input': 'param.input.'}
|
||||
LANG_RU = 0x19 # primary language id of Russian in a Windows LANGID
|
||||
LANG_PT_BR = 0x0416 # Portuguese (Brazil), the whole LANGID: Portugal's Portuguese stays English
|
||||
# Windows LANGIDs that write Simplified Chinese: zh-CN, zh-SG. zh-TW, zh-HK and zh-MO write Traditional Chinese, which
|
||||
# the window does not have.
|
||||
LANGIDS_ZH_HANS = (0x0804, 0x1004)
|
||||
# primary language id in a Windows LANGID -> window language, for the languages whose every region gets the same text.
|
||||
# Every Chinese gets Simplified Chinese: the setup has no Traditional Chinese text, as the in-game menu has none.
|
||||
PRIMARY_LANGS = {0x04: 'zh-Hans', 0x19: 'ru', 0x07: 'de', 0x0c: 'fr', 0x0a: 'es', 0x10: 'it', 0x13: 'nl', 0x11: 'ja',
|
||||
0x12: 'ko'}
|
||||
# window language -> the game language the form starts with (default_game_language)
|
||||
GAME_LANGUAGE_FOR_UI = {'ru': 'ru', 'de': 'de', 'fr': 'fr', 'es': 'es', 'it': 'it', 'nl': 'nl', 'ja': 'ja'}
|
||||
|
||||
|
||||
def load_texts(lang):
|
||||
@@ -83,11 +88,10 @@ def flat(value):
|
||||
|
||||
def windows_ui_language():
|
||||
"""The window language for the display language: the Windows one (ui_language_for_langid); elsewhere LC_ALL,
|
||||
LC_MESSAGES or LANG ('ru', 'pt_BR', 'zh_CN' or 'zh_SG', else English)."""
|
||||
LC_MESSAGES or LANG (ui_language_for_locale)."""
|
||||
if os.name != 'nt':
|
||||
loc = (os.environ.get('LC_ALL') or os.environ.get('LC_MESSAGES') or os.environ.get('LANG') or '').lower()
|
||||
return ('ru' if loc.startswith('ru') else 'pt-BR' if loc.startswith(('pt_br', 'pt-br'))
|
||||
else 'zh-Hans' if loc.startswith(('zh_cn', 'zh-cn', 'zh_sg', 'zh-sg', 'zh_hans', 'zh-hans')) else 'en')
|
||||
return ui_language_for_locale(os.environ.get('LC_ALL') or os.environ.get('LC_MESSAGES')
|
||||
or os.environ.get('LANG') or '')
|
||||
try:
|
||||
langid = ctypes.windll.kernel32.GetUserDefaultUILanguage()
|
||||
except (AttributeError, OSError):
|
||||
@@ -95,23 +99,32 @@ def windows_ui_language():
|
||||
return ui_language_for_langid(langid)
|
||||
|
||||
|
||||
def ui_language_for_locale(loc):
|
||||
"""The window language for a POSIX locale such as 'de_AT.UTF-8': its language, Brazilian Portuguese only for
|
||||
pt_BR, Simplified Chinese for every Chinese, else English."""
|
||||
loc = loc.lower().replace('-', '_')
|
||||
if loc.startswith('pt_br'):
|
||||
return 'pt-BR'
|
||||
lang = loc.split('_')[0].split('.')[0]
|
||||
if lang == 'zh':
|
||||
return 'zh-Hans'
|
||||
return lang if lang in PRIMARY_LANGS.values() else 'en'
|
||||
|
||||
|
||||
def ui_language_for_langid(langid):
|
||||
"""'ru' for a Russian Windows LANGID, 'pt-BR' for Brazilian Portuguese, 'zh-Hans' for a Simplified Chinese one,
|
||||
else 'en'."""
|
||||
if langid & 0x3ff == LANG_RU:
|
||||
return 'ru'
|
||||
"""The window language for a Windows LANGID: by its primary language (PRIMARY_LANGS), Brazilian Portuguese only
|
||||
for pt-BR (Portugal's stays English), else 'en'."""
|
||||
if langid == LANG_PT_BR:
|
||||
return 'pt-BR'
|
||||
if langid in LANGIDS_ZH_HANS:
|
||||
return 'zh-Hans'
|
||||
return 'en'
|
||||
return PRIMARY_LANGS.get(langid & 0x3ff, 'en')
|
||||
|
||||
|
||||
def default_game_language(ui):
|
||||
"""The game language the form starts with. A Chinese window still starts with English: Chinese game text needs
|
||||
the Switch shared fonts (ini.NEED_SHARED_FONTS), which the setup extracts only from a firmware folder, and the game
|
||||
stops when they are missing; the player can still pick Chinese."""
|
||||
return 'ru' if ui == 'ru' else 'en-US'
|
||||
"""The game language the form starts with: the window's own when the game has it. A Chinese or Korean window
|
||||
still starts with English: that game text needs the Switch shared fonts (ini.NEED_SHARED_FONTS), which the setup
|
||||
extracts only from a firmware folder, and the game stops when they are missing; the player can still pick it.
|
||||
The game has no Brazilian Portuguese, so that window starts with English too."""
|
||||
return GAME_LANGUAGE_FOR_UI.get(ui, 'en-US')
|
||||
|
||||
|
||||
def gib(n):
|
||||
|
||||
@@ -12,26 +12,33 @@
|
||||
|
||||
#include "launcher_text.h"
|
||||
|
||||
#define LANGID_RUSSIAN 0x19 /* primary language id */
|
||||
#define LANGID_PT_BR 0x0416 /* the whole LANGID: Portugal's Portuguese stays English */
|
||||
#define PATH_CHARS (MAX_PATH * 2)
|
||||
|
||||
/* The language of the window (installer/guilogic.py ui_language_for_langid): Russian, Simplified Chinese (zh-CN and
|
||||
zh-SG; the Traditional Chinese regions get English, as the window has no Traditional Chinese), else English. */
|
||||
/* The language of the window (installer/guilogic.py ui_language_for_langid): Brazilian Portuguese by the whole LANGID,
|
||||
the rest by the primary language (every Chinese gets Simplified Chinese), else English. */
|
||||
static void fail(void)
|
||||
{
|
||||
static const struct { WORD primary; const wchar_t *title, *text; } by_primary[] = {
|
||||
{ LANG_RUSSIAN, LAUNCHER_TITLE_RU, LAUNCHER_PYTHON_MISSING_RU },
|
||||
{ LANG_GERMAN, LAUNCHER_TITLE_DE, LAUNCHER_PYTHON_MISSING_DE },
|
||||
{ LANG_FRENCH, LAUNCHER_TITLE_FR, LAUNCHER_PYTHON_MISSING_FR },
|
||||
{ LANG_SPANISH, LAUNCHER_TITLE_ES, LAUNCHER_PYTHON_MISSING_ES },
|
||||
{ LANG_ITALIAN, LAUNCHER_TITLE_IT, LAUNCHER_PYTHON_MISSING_IT },
|
||||
{ LANG_DUTCH, LAUNCHER_TITLE_NL, LAUNCHER_PYTHON_MISSING_NL },
|
||||
{ LANG_JAPANESE, LAUNCHER_TITLE_JA, LAUNCHER_PYTHON_MISSING_JA },
|
||||
{ LANG_KOREAN, LAUNCHER_TITLE_KO, LAUNCHER_PYTHON_MISSING_KO },
|
||||
{ LANG_CHINESE, LAUNCHER_TITLE_ZH_HANS, LAUNCHER_PYTHON_MISSING_ZH_HANS },
|
||||
};
|
||||
LANGID ui = GetUserDefaultUILanguage();
|
||||
int russian = (ui & 0x3ff) == LANGID_RUSSIAN, brazilian = ui == LANGID_PT_BR;
|
||||
int chinese = ui == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) ||
|
||||
ui == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SINGAPORE);
|
||||
MessageBoxW(NULL,
|
||||
russian ? LAUNCHER_PYTHON_MISSING_RU
|
||||
: brazilian ? LAUNCHER_PYTHON_MISSING_PT_BR
|
||||
: chinese ? LAUNCHER_PYTHON_MISSING_ZH_HANS
|
||||
: LAUNCHER_PYTHON_MISSING_EN,
|
||||
russian ? LAUNCHER_TITLE_RU : brazilian ? LAUNCHER_TITLE_PT_BR : chinese ? LAUNCHER_TITLE_ZH_HANS
|
||||
: LAUNCHER_TITLE_EN,
|
||||
MB_OK | MB_ICONERROR);
|
||||
const wchar_t *title = LAUNCHER_TITLE_EN, *text = LAUNCHER_PYTHON_MISSING_EN;
|
||||
if (ui == LANGID_PT_BR) {
|
||||
title = LAUNCHER_TITLE_PT_BR; text = LAUNCHER_PYTHON_MISSING_PT_BR;
|
||||
} else {
|
||||
for (size_t i = 0; i < sizeof by_primary / sizeof by_primary[0]; i++)
|
||||
if (PRIMARYLANGID(ui) == by_primary[i].primary) { title = by_primary[i].title; text = by_primary[i].text; }
|
||||
}
|
||||
MessageBoxW(NULL, text, title, MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR command_line, int show)
|
||||
|
||||
+46
-6
@@ -16,7 +16,13 @@ Release (docs/installer.md "Release layout"), root = the unpacked folder:
|
||||
without one the game is built at -O1
|
||||
totk.ini.example
|
||||
VERSION the release version, one line
|
||||
temp/ the default temp folder (created)
|
||||
|
||||
Build kit (Windows release): the setup copies the release folder without TotK-Setup.exe into <install>/build-kit
|
||||
(KIT_ITEMS, steps.py Kit) and runs every later step from it, so the game's rebuild for its mods
|
||||
(build-cache/rebuild.txt, relative to the install folder) needs neither the setup folder nor its path: the setup can be
|
||||
deleted and the install folder moved. The kit is a release folder itself (release_layout). The temp folder with the
|
||||
rebuild's working state (gen/, build/, the lift cache) is <install>/build-cache/work (TEMP_IN_DEST), so it moves
|
||||
with the install and survives a newer setup's kit.
|
||||
|
||||
Linux release (the AppImage's folder, docs/installer.md "Linux release"): python/bin/python3 (python-build-standalone,
|
||||
with tkinter), llvm/ with clang, lld and llvm-ar plus llvm/sysroot (the glibc headers and libraries the game links
|
||||
@@ -26,9 +32,11 @@ Dev mode, root = a repository checkout (no python/python.exe): build/py314-embed
|
||||
Python the release ships, with the same packages), else this Python; toolchain/llvm-mingw-*/ and toolchain/deps-mingw;
|
||||
runtime/ as the sources with build/install-rtlib/libtotkrt.a and libtotkrt-v2.a (tools/build_game.py --make-runtime-lib
|
||||
--out build/install-rtlib, once per --cpu); MSYS2 UCRT64 ninja.exe; toolchain/hactool; build/xlate/totk_xlate.exe; the shader list from
|
||||
refs/MacNativeGames; build/pgo/pgo-<v>.profdata when there is one; build/install-temp. The version is VERSION with -dev and the commit: 0.1.0-dev+973c626. On Linux,
|
||||
dev mode takes clang, lld and ninja from PATH and the system's libraries (no deps folder, no SDL3 copy).
|
||||
refs/MacNativeGames; build/pgo/pgo-<v>.profdata when there is one; build/install-temp/<install name>-<hash>. The
|
||||
version is VERSION with -dev and the commit: 0.1.0-dev+973c626. Dev mode and the Linux release install no build kit:
|
||||
the repository, or the AppImage file, is what the rebuild runs. On Linux, dev mode takes clang, lld and ninja from PATH and the system's libraries (no deps folder, no SDL3 copy).
|
||||
"""
|
||||
import hashlib
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -40,6 +48,14 @@ WIN = os.name == 'nt'
|
||||
EXE = '.exe' if WIN else ''
|
||||
UCRT = Path(r'C:\msys64\ucrt64\bin')
|
||||
SUPPORTED = ('1.2.1', '1.4.3', '1.1.0') # updates the installer builds; the check identifies the player's by hash
|
||||
KIT = 'build-kit' # the build kit's folder in the install folder
|
||||
# What the build kit holds of a release folder (tools/make_release.py writes them): all but TotK-Setup.exe. licenses/
|
||||
# and THIRD_PARTY_NOTICES.md go along with the binaries they cover.
|
||||
KIT_ITEMS = ('python', 'llvm', 'runtime', 'bin', 'recomp', 'tools', 'data', 'installer', 'licenses',
|
||||
'THIRD_PARTY_NOTICES.md', 'totk.ini.example', 'VERSION')
|
||||
# The temp folder inside the install folder, for a layout that names none (every release); the check step does not
|
||||
# count it when it requires an empty install folder. Linux keeps the name its installs already use.
|
||||
TEMP_IN_DEST = Path('build-cache', 'work') if WIN else Path('.setup-temp')
|
||||
|
||||
|
||||
def version_tag(version):
|
||||
@@ -139,9 +155,10 @@ def release_layout(root):
|
||||
dlls=(root / 'bin' / 'SDL3.dll', root / 'bin' / 'libopus-0.dll') if WIN else (root / 'bin' / 'libSDL3.so.0',),
|
||||
shader_list=root / 'data' / 'shader_list.tsv', ini_example=root / 'totk.ini.example',
|
||||
pgo_dir=root / 'data' if WIN else None,
|
||||
# Linux: None, the install folder's .setup-temp (installer/cli.py): the AppImage is mounted read-only, and on
|
||||
# a Steam Deck /home is often too full for the generated C while the install folder is on the SD card
|
||||
temp=root / 'temp' if WIN else None,
|
||||
# None: the install folder's TEMP_IN_DEST (temp_for). Windows: the rebuild's working state stays with the install
|
||||
# and its build kit. Linux: the AppImage is mounted read-only, and on a Steam Deck /home is often too full for
|
||||
# the generated C while the install folder is on the SD card
|
||||
temp=None,
|
||||
sysroot=None if WIN else root / 'llvm' / 'sysroot')
|
||||
|
||||
|
||||
@@ -191,3 +208,26 @@ def find(root=None):
|
||||
"""The layout of root (default: the folder above this package)."""
|
||||
root = Path(root or Path(__file__).resolve().parent.parent).resolve()
|
||||
return release_layout(root) if is_release(root) else dev_layout(root)
|
||||
|
||||
|
||||
def uses_kit(layout):
|
||||
"""True when the setup installs a build kit (Windows release); dev mode and the Linux AppImage run from where they
|
||||
are."""
|
||||
return WIN and not layout.dev
|
||||
|
||||
|
||||
def kit_folder(dest):
|
||||
return Path(dest) / KIT
|
||||
|
||||
|
||||
def temp_folder(base, dest):
|
||||
"""One temp folder per install folder below a shared base (dev mode, --temp), so two installs never share
|
||||
generated files."""
|
||||
tag = hashlib.sha256(str(dest).lower().encode()).hexdigest()[:8]
|
||||
return base / f'{dest.name or "root"}-{tag}'
|
||||
|
||||
|
||||
def temp_for(layout, dest, override=None):
|
||||
"""The temp folder of a run on dest: below --temp or the layout's, else TEMP_IN_DEST in the install folder."""
|
||||
base = override or layout.temp
|
||||
return temp_folder(Path(base).resolve(), dest) if base else dest / TEMP_IN_DEST
|
||||
@@ -49,6 +49,10 @@ class Step:
|
||||
"""Do the work. Returns fields to record with the step."""
|
||||
return {}
|
||||
|
||||
def settle(self, ctx):
|
||||
"""After the step ran or was skipped: a step whose output the later steps run from (the build kit) points the
|
||||
context at it."""
|
||||
|
||||
|
||||
class Context:
|
||||
def __init__(self, layout, dest, temp, reporter, options, state=None, verify=False):
|
||||
@@ -121,6 +125,7 @@ def run_steps(steps, ctx):
|
||||
for s in steps:
|
||||
if not ctx.runs[s.id]:
|
||||
rep.step(s.id, 'skipped', reason=ctx.reasons[s.id])
|
||||
s.settle(ctx)
|
||||
continue
|
||||
current = s.id
|
||||
rep.step(s.id, 'started')
|
||||
@@ -133,6 +138,7 @@ def run_steps(steps, ctx):
|
||||
ctx.save() # the first save, after the check, creates the install folder
|
||||
rep.step(s.id, 'done', seconds=seconds)
|
||||
current = None
|
||||
s.settle(ctx)
|
||||
ctx.state['release'] = ctx.layout.release
|
||||
ctx.save()
|
||||
return 'ok'
|
||||
|
||||
+16
-6
@@ -140,16 +140,26 @@ def ini_value(text, name):
|
||||
return value
|
||||
|
||||
|
||||
# The pad prompts' folder suffixes (make_romfs_patches.py --prompts), each written at 16:9 on every install
|
||||
# (steps.Prepare): the Xbox and PlayStation ones, for the Nintendo pad layout and for xbox and auto
|
||||
PAD_PROMPTS = ('xbox', 'xbox-label', 'playstation', 'playstation-xbox')
|
||||
# Every prompts folder suffix: the pad ones and the keyboard and mouse one (steps.PcPrompts)
|
||||
PROMPTS_STYLES = PAD_PROMPTS + ('pc',)
|
||||
|
||||
|
||||
def prompts_style(text):
|
||||
"""The prompts' folder suffix the settings select, as runtime/input_map.c input_prompts_pick and
|
||||
input_prompts_folder pick it at start: 'pc', 'xbox' (Nintendo pad layout), 'xbox-label' (any other) or None for the
|
||||
game's own prompts, the default without a totk.ini."""
|
||||
p, layout = ini_value(text, 'prompts'), (ini_value(text, 'pad_layout') or '').lower()
|
||||
if p and p.lower() == 'pc':
|
||||
input_prompts_folder pick it at start: 'pc', 'xbox' or 'playstation' (Nintendo pad layout), 'xbox-label' or
|
||||
'playstation-xbox' (any other), or None for the game's own prompts, the default without a totk.ini."""
|
||||
p, layout = (ini_value(text, 'prompts') or '').lower(), (ini_value(text, 'pad_layout') or '').lower()
|
||||
if p == 'pc':
|
||||
return 'pc'
|
||||
if not (p.lower() == 'xbox' if p else layout == 'xbox_prompts'):
|
||||
nintendo = layout in ('nintendo', 'xbox_prompts')
|
||||
if p in ('playstation', 'ps'):
|
||||
return 'playstation' if nintendo else 'playstation-xbox'
|
||||
if not (p == 'xbox' if p else layout == 'xbox_prompts'):
|
||||
return None
|
||||
return 'xbox' if layout in ('nintendo', 'xbox_prompts') else 'xbox-label'
|
||||
return 'xbox' if nintendo else 'xbox-label'
|
||||
|
||||
|
||||
def wanted(dest, screens=None):
|
||||
|
||||
+330
-59
@@ -1,5 +1,5 @@
|
||||
"""The ten setup steps of docs/installer.md: check, fonts, extract, lift, compile, prepare, pc_prompts, shapes, dlss,
|
||||
cleanup.
|
||||
"""The eleven setup steps of docs/installer.md: check, kit, fonts, extract, lift, compile, prepare, pc_prompts, shapes,
|
||||
dlss, cleanup.
|
||||
|
||||
Extraction runs in this process through tools/extract.py (the package's sibling tools/, which ships with it); fonts
|
||||
runs the vendored extract_shared_fonts.py on the firmware folder; lift, compile and prepare run the bundled Python on
|
||||
@@ -11,18 +11,21 @@ Install folder: exefs/, romfs/ (romfs.bin, index.json), profile/, shared-fonts/
|
||||
and its DLLs, nvngx_dlss.dll (with --dlss), romfs-index.bin, romfs-patches/, romfs-patches-xbox/,
|
||||
romfs-patches-xbox-label/, romfs-patches-pc/, romfs-patches-<w>x<h>/ and romfs-patches-<style>-<w>x<h>/ (for the
|
||||
screen shapes and the prompts style this player needs, installer/screens.py), totk_xlate.exe, the
|
||||
shader state of totk.exe --prepare-shaders, totk.ini, totk-install.json.
|
||||
Temp folder (<temp>/<dest name>-<hash>): check/ (ExeFS of both inputs, the host check), unpacked/ (the NSP of an NSZ
|
||||
or XCZ input until the extraction is done), gen/ (C), build/ (objects), logs/. The cleanup keeps gen/, build/ and
|
||||
shader state of totk.exe --prepare-shaders, totk.ini, totk-install.json, and on Windows build-kit/ (Kit): the release
|
||||
folder the steps after the kit step run from, and the game's rebuild with them.
|
||||
Temp folder (build-cache/work in the install folder on Windows, .setup-temp there on Linux, <temp>/<dest name>-<hash>
|
||||
with --temp or in a repository; installer/layout.py temp_for): check/ (ExeFS of both inputs, the host check),
|
||||
unpacked/ (the NSP of an NSZ or XCZ input until the extraction is done), gen/ (C), build/ (objects), logs/. The cleanup keeps gen/, build/ and
|
||||
logs/: the next run lifts into the same gen/, where recomp/gen.py lifts again only the chunks whose inputs changed (its
|
||||
lift cache, gen/<mod>/lift_cache.json) and rewrites only those whose C changed, and Ninja in build/ recompiles only
|
||||
those. A change of the mods' code cheats then costs a few seconds of lift and the chunks holding its sites, not a full
|
||||
lift or compile.
|
||||
|
||||
Install folder build-cache/: cheats.status (tools/cheats.py), exefs.status and exefs.data (tools/exefs_patches.py) and
|
||||
Install folder build-cache/: cheats.status (tools/cheats.py), exefs.status and exefs.data (tools/exefs_patches.py),
|
||||
plugins.status (tools/exefs_plugins.py; plugins.stale is the game's list of plugins whose start differed) and
|
||||
rebuild.txt, the command that starts this setup in its rebuild mode on the install folder (installer/gui.py --rebuild),
|
||||
one argument per line; totk.exe runs it at start when an enabled mod has code cheats the build lacks
|
||||
(runtime/cheats.c).
|
||||
one argument per line, relative to the install folder for the build kit; totk.exe runs it at start when an enabled mod
|
||||
has code cheats the build lacks (runtime/cheats.c).
|
||||
"""
|
||||
import hashlib
|
||||
import http.client
|
||||
@@ -39,6 +42,7 @@ import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
from . import ini, screens
|
||||
from . import layout as layouts
|
||||
from .layout import EXE, SUPPORTED, version_tag
|
||||
from .runner import InstallError, Step
|
||||
|
||||
@@ -52,6 +56,7 @@ from extract_exefs import (common_tickets, container_entries, load_keys, nca_ctr
|
||||
GiB = 1 << 30
|
||||
DEST_EXTRA = 4 * GiB # beside the RomFS: shader and pipeline caches (about 2 GB), exefs, totk.exe, seed files
|
||||
TEMP_NEED = 3 * GiB # generated C (about 0.9 GB) and objects
|
||||
KIT_NEED = 1 * GiB # the build kit (Kit), about 0.65 GB
|
||||
HOSTCHECK = Path(__file__).resolve().parent / 'hostcheck.c'
|
||||
STAMP = '.install-key'
|
||||
|
||||
@@ -597,6 +602,8 @@ class Check(Step):
|
||||
dest_need -= romfs.stat().st_size
|
||||
if ctx.will_run('fonts'):
|
||||
dest_need += FONTS_NEED
|
||||
if ctx.will_run('kit') and layouts.uses_kit(ctx.layout):
|
||||
dest_need += KIT_NEED
|
||||
if ctx.will_run('prepare') or ctx.will_run('extract'):
|
||||
dest_need += DEST_EXTRA
|
||||
if ctx.will_run('lift') or ctx.will_run('compile'):
|
||||
@@ -649,6 +656,114 @@ class Check(Step):
|
||||
ctx.state['version'] = found
|
||||
|
||||
|
||||
# ---- 1b. build kit
|
||||
|
||||
class Kit(Step):
|
||||
"""The build kit (installer/layout.py, Windows release): the release folder without TotK-Setup.exe, copied into
|
||||
<install>/build-kit. Every step after this one runs its tools from there (settle), and the game's rebuild for its
|
||||
mods starts the setup window from there, so the setup folder can go once the install is done and the install
|
||||
folder can move. A newer setup replaces the kit; the kit's own rebuild keeps it. The steps' keys fingerprint file
|
||||
contents, not paths, so the kit, a copy of the setup's files, keeps every step the setup recorded."""
|
||||
|
||||
id = 'kit'
|
||||
|
||||
def key(self, ctx):
|
||||
return fingerprint('kit-1', ctx.layout.release if layouts.uses_kit(ctx.layout) else 'none')
|
||||
|
||||
def current(self, ctx, record):
|
||||
if not layouts.uses_kit(ctx.layout):
|
||||
return True
|
||||
kit = layouts.kit_folder(ctx.dest)
|
||||
if not layouts.is_release(kit):
|
||||
return False
|
||||
found = layouts.release_layout(kit)
|
||||
return found.release == ctx.layout.release and not found.missing(getattr(ctx, 'cpu', 'v3'))
|
||||
|
||||
def run(self, ctx):
|
||||
layout, rep = ctx.layout, ctx.reporter
|
||||
if not layouts.uses_kit(layout):
|
||||
return {}
|
||||
kit = layouts.kit_folder(ctx.dest)
|
||||
if layout.root.resolve() == kit.resolve(): # the kit's own rebuild: it is in place
|
||||
return {}
|
||||
new, old = kit.with_name(layouts.KIT + '.new'), kit.with_name(layouts.KIT + '.old')
|
||||
try:
|
||||
remove(new) # what a cancelled or failed run left
|
||||
remove(old)
|
||||
except OSError as e:
|
||||
raise InstallError('kit.in_use', path=str(e.filename or old)) from None
|
||||
files = []
|
||||
for name in layouts.KIT_ITEMS:
|
||||
src = layout.root / name
|
||||
if src.is_dir():
|
||||
files += [f for f in sorted(src.rglob('*')) if f.is_file() and '__pycache__' not in f.parts]
|
||||
elif src.is_file():
|
||||
files.append(src)
|
||||
total, done = size_of(files), 0
|
||||
rep.progress('kit', 'copy', 0, total, 'bytes', force=True)
|
||||
try:
|
||||
for f in files:
|
||||
dst = new / f.relative_to(layout.root)
|
||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(f, dst)
|
||||
done += f.stat().st_size
|
||||
rep.progress('kit', 'copy', done, total, 'bytes')
|
||||
except OSError as e:
|
||||
raise InstallError('kit.copy_failed', path=str(e.filename or new), detail=str(e)) from None
|
||||
# An open rebuild window, or a layout generator the game's settings menu started, holds files of the old kit:
|
||||
# then nothing is replaced, and the message asks to close the game and run the setup again
|
||||
moved = False
|
||||
try:
|
||||
if kit.exists():
|
||||
os.replace(kit, old)
|
||||
moved = True
|
||||
os.replace(new, kit)
|
||||
except OSError:
|
||||
if moved and not kit.exists():
|
||||
os.replace(old, kit) # the game keeps the kit it had
|
||||
raise InstallError('kit.in_use', path=str(kit)) from None
|
||||
try:
|
||||
remove(old)
|
||||
except OSError as e:
|
||||
rep.log(f'kit: the old kit stays until the next run: {e}')
|
||||
rep.log(f'kit: {len(files)} files, {total / GiB:.2f} GiB in {kit}')
|
||||
return {'bytes': total}
|
||||
|
||||
def settle(self, ctx):
|
||||
if not layouts.uses_kit(ctx.layout):
|
||||
return
|
||||
kit = layouts.kit_folder(ctx.dest).resolve()
|
||||
if ctx.layout.root.resolve() != kit:
|
||||
ctx.layout = layouts.release_layout(kit)
|
||||
ctx.reporter.log(f'kit: the next steps run from {kit}')
|
||||
|
||||
|
||||
def adopt_old_temp(layout, dest, temp):
|
||||
"""An install by a setup before the build kit has its temp folder (generated C, lift cache, objects) in that
|
||||
setup's folder: <setup>/temp/<install name>-<hash>, the setup build-cache/rebuild.txt names. The first run of a
|
||||
setup with the build kit moves it into the install folder when both are on one disk, and the steps' keys decide
|
||||
what of it still holds. On another disk the new temp folder starts empty: an update recompiles everything anyway
|
||||
(the compiler's path is in every compile command), so a copy would save only part of the lift.
|
||||
Runs before the run's log opens in temp; returns the line for the log, None when there was nothing to move."""
|
||||
if not layouts.uses_kit(layout) or temp != dest / layouts.TEMP_IN_DEST or temp.exists():
|
||||
return None
|
||||
try:
|
||||
lines = (dest / 'build-cache' / 'rebuild.txt').read_text(encoding='utf-8').splitlines()
|
||||
except OSError:
|
||||
return None
|
||||
if len(lines) < 4 or lines[1] != '-c' or not os.path.isabs(lines[3]):
|
||||
return None
|
||||
old = layouts.temp_folder(Path(lines[3]) / 'temp', dest)
|
||||
if not (old / 'gen').is_dir():
|
||||
return None
|
||||
try:
|
||||
temp.parent.mkdir(parents=True, exist_ok=True)
|
||||
os.replace(old, temp)
|
||||
return f'temp: moved the temp folder of the setup in {lines[3]} to {temp}'
|
||||
except OSError as e:
|
||||
return f'temp: the temp folder {old} stays where it is ({e}); {temp} starts empty'
|
||||
|
||||
|
||||
# ---- 2. fonts
|
||||
|
||||
class Fonts(Step):
|
||||
@@ -866,6 +981,43 @@ def exefs_files(ctx):
|
||||
return sorted(out)
|
||||
|
||||
|
||||
def plugin_files(ctx):
|
||||
"""The exlaunch plugins of the mods folder (each mod's exefs/subsdk*, in the first ExeFS place, as
|
||||
tools/exefs_plugins.py finds them), by mod name, for the lift key and the plugin stage."""
|
||||
mods = ctx.dest / 'mods'
|
||||
if not mods.is_dir():
|
||||
return []
|
||||
out = []
|
||||
for mod in sorted((m for m in mods.iterdir() if m.is_dir()), key=lambda m: m.name):
|
||||
exefs = next((mod / w for w in EXEFS_PLACES if (mod / w).is_dir()), None)
|
||||
if exefs:
|
||||
out += sorted((f for f in exefs.iterdir() if f.is_file() and f.name.lower().startswith('subsdk')),
|
||||
key=lambda f: f.name.lower())
|
||||
return out
|
||||
|
||||
|
||||
def plugins_status(ctx):
|
||||
"""The build's plugin status file (tools/exefs_plugins.py --status), which runtime/mods.c reads."""
|
||||
return ctx.dest / 'build-cache' / 'plugins.status'
|
||||
|
||||
|
||||
def built_plugins(status, files, mods):
|
||||
"""The files of the plugins the status file lists as built (kind `plugin`), in the order of files. The key is
|
||||
FNV-1a 32 of "<mod folder>/<path in the mod>", as tools/exefs_plugins.py and runtime/mods.c compute it."""
|
||||
if not status.is_file():
|
||||
return []
|
||||
built = {line.split('\t')[0] for line in status.read_text(encoding='utf-8').splitlines()
|
||||
if len(line.split('\t')) >= 3 and line.split('\t')[2] == 'plugin'}
|
||||
|
||||
def key(f):
|
||||
rel = f.relative_to(mods).as_posix()
|
||||
h = 0x811C9DC5
|
||||
for b in rel.encode():
|
||||
h = ((h ^ b) * 0x01000193) & 0xFFFFFFFF
|
||||
return f'{h:08X}'
|
||||
return [f for f in files if key(f) in built]
|
||||
|
||||
|
||||
def exefs_status(ctx):
|
||||
"""The build's ExeFS patch status file (tools/exefs_patches.py --status), which runtime/mods.c reads."""
|
||||
return ctx.dest / 'build-cache' / 'exefs.status'
|
||||
@@ -890,9 +1042,13 @@ class Lift(Step):
|
||||
def key(self, ctx):
|
||||
# fingerprint takes a file's name and content only; the paths under mods/ go in too, because tools/cheats.py
|
||||
# and tools/exefs_patches.py name each patch set after its mod folder, so a renamed folder needs a lift
|
||||
files = cheat_files(ctx) + exefs_files(ctx)
|
||||
# A mod plugin is built by running its init on a totk.exe of this build (tools/exefs_plugins.py), so the
|
||||
# runtime is in the key too when there is one, and this file, which runs that stage: a plugin stage that failed
|
||||
# (warn.plugins_skipped, the game built without the plugins) runs again once a release changes it.
|
||||
files = cheat_files(ctx) + exefs_files(ctx) + plugin_files(ctx)
|
||||
extra = [ctx.layout.tools / 'exefs_plugins.py', Path(__file__), runtime_key(ctx)] if plugin_files(ctx) else []
|
||||
return fingerprint('lift-5', ctx.keys['extract'], ctx.layout.recomp, ctx.layout.patches(game_version(ctx)),
|
||||
ctx.layout.tools / 'cheats.py', ctx.layout.tools / 'exefs_patches.py', *files,
|
||||
ctx.layout.tools / 'cheats.py', ctx.layout.tools / 'exefs_patches.py', *extra, *files,
|
||||
*(f.relative_to(ctx.dest / 'mods').as_posix() for f in files))
|
||||
|
||||
def current(self, ctx, record):
|
||||
@@ -943,12 +1099,50 @@ class Lift(Step):
|
||||
else:
|
||||
patches = ctx.temp / out
|
||||
args = ['--exefs', ctx.dest / 'exefs', '--out', gen]
|
||||
# The mods' exlaunch plugins (tools/exefs_plugins.py, after the design in #845 by itaskaev2): a lift with the
|
||||
# plugins in the layout, a totk.exe of it in build/ (the compile step's folder, so it recompiles only what
|
||||
# the hook sites change after), the plugin service run, and the plugins' patch sets for the lift below. A
|
||||
# refused plugin gets its reason in plugins.status; a failed stage costs the plugins, not the install.
|
||||
plugins = plugin_files(ctx)
|
||||
drop([plugins_status(ctx), ctx.dest / 'build-cache' / 'plugins.stale'])
|
||||
lift_plugins = []
|
||||
if plugins:
|
||||
listed = ['--plugins', ','.join(str(f) for f in plugins)]
|
||||
code, log = run_tool(ctx, 'lift', layout.recomp / 'gen.py', args + ['--patches', patches] + listed, parse)
|
||||
if not code:
|
||||
code, log = run_tool(ctx, 'lift', layout.tools / 'build_game.py', build_args(ctx, gen))
|
||||
if not code:
|
||||
# the service run's totk.exe loads its DLLs from its own folder, as the installed one does
|
||||
for dll in layout.dlls:
|
||||
replace_file(dll, ctx.temp / 'build' / dll.name)
|
||||
code, log = run_tool(ctx, 'lift', layout.tools / 'exefs_plugins.py', [
|
||||
'--exe', ctx.temp / 'build' / ('totk' + EXE), '--out', ctx.temp / 'plugins', '--mods',
|
||||
ctx.dest / 'mods', '--patches', patches, '--patches-out', ctx.temp / 'patches-plugins.txt',
|
||||
'--status', plugins_status(ctx)])
|
||||
# exit 1 with a status file: refused plugins, their reasons in it; the rest goes on
|
||||
if plugins_status(ctx).is_file() and (ctx.temp / 'patches-plugins.txt').is_file():
|
||||
code = 0
|
||||
if code:
|
||||
drop([plugins_status(ctx)])
|
||||
skipped['warn.plugins_skipped'] = log
|
||||
else:
|
||||
patches = ctx.temp / 'patches-plugins.txt'
|
||||
# With one plugin built, the layout keeps every plugin of the service runs: the records hold addresses
|
||||
# of that layout. A refused plugin stays loaded at play, its init never runs (no patch set).
|
||||
if built_plugins(plugins_status(ctx), plugins, ctx.dest / 'mods'):
|
||||
lift_plugins = plugins
|
||||
if lift_plugins:
|
||||
args += ['--plugins', ','.join(str(f) for f in lift_plugins)]
|
||||
code, log = run_tool(ctx, 'lift', layout.recomp / 'gen.py', args + ['--patches', patches], parse)
|
||||
if code and patches != plain:
|
||||
for tool, out, outputs, inputs, warn in stages:
|
||||
if inputs and warn not in skipped:
|
||||
drop(outputs)
|
||||
skipped[warn] = log
|
||||
if lift_plugins:
|
||||
drop([plugins_status(ctx)])
|
||||
skipped.setdefault('warn.plugins_skipped', log)
|
||||
args = ['--exefs', ctx.dest / 'exefs', '--out', gen]
|
||||
code, log = run_tool(ctx, 'lift', layout.recomp / 'gen.py', args + ['--patches', plain], parse)
|
||||
if code:
|
||||
raise InstallError('lift.failed', code=code, log=str(log))
|
||||
@@ -976,17 +1170,40 @@ def runtime_key(ctx):
|
||||
"""Fingerprint of what totk.exe is built from besides the lifted code: the runtime, the toolchain and the build
|
||||
tools. Shader preparation depends on these, not on the code cheats a lift adds."""
|
||||
layout, cpu = ctx.layout, getattr(ctx, 'cpu', 'v3')
|
||||
clang = subprocess.run([str(layout.clang), '--version'], capture_output=True, text=True).stdout
|
||||
# without the lines that name clang's folder: the build kit of a moved install folder is the same toolchain
|
||||
clang = '\n'.join(line for line in subprocess.run([str(layout.clang), '--version'], capture_output=True,
|
||||
text=True).stdout.splitlines()
|
||||
if not line.startswith(('InstalledDir:', 'Configuration file:')))
|
||||
tools = [layout.tools / n for n in ('build_game.py', 'romfs_index.py', 'check_content.py', 'check_isa.py')]
|
||||
return fingerprint('runtime-1', cpu, layout.runtime_lib_for(cpu), layout.runtime, layout.deps or 'system',
|
||||
layout.sysroot or 'host', *tools, clang, *[d.name for d in layout.dlls])
|
||||
|
||||
|
||||
def build_args(ctx, gen):
|
||||
"""tools/build_game.py's arguments for a totk.exe of the lifted C in gen, built in <temp>/build."""
|
||||
layout, dest = ctx.layout, ctx.dest
|
||||
cpu = getattr(ctx, 'cpu', 'v3')
|
||||
lib = layout.runtime_lib_for(cpu)
|
||||
pgo = layout.pgo(game_version(ctx))
|
||||
return ['--gen', gen, '--out', ctx.temp / 'build', '--toolchain', layout.llvm, '--cpu', cpu,
|
||||
*(['--deps', layout.deps] if layout.deps else []), *(['--sysroot', layout.sysroot] if layout.sysroot else []),
|
||||
'--runtime', layout.runtime, *(['--runtime-lib', lib] if lib else ()), *(['--pgo', pgo] if pgo else ()),
|
||||
'--ninja', layout.ninja,
|
||||
'--version', version_tag(game_version(ctx)), '--expected', layout.expected(game_version(ctx)),
|
||||
'--exefs', dest / 'exefs', '--romfs', dest / 'romfs',
|
||||
'--profile', dest / 'profile',
|
||||
# the build kit and the temp folder move with the install folder: Ninja's paths relative to the kit
|
||||
*(['--portable'] if layouts.uses_kit(layout) else [])]
|
||||
|
||||
|
||||
class Compile(Step):
|
||||
id = 'compile'
|
||||
|
||||
def key(self, ctx):
|
||||
return fingerprint('compile-3', ctx.keys['lift'], runtime_key(ctx),
|
||||
# The release string too: build_game.py bakes the VERSION of the tools' folder into totk.exe (the menu's title
|
||||
# line), and a release that leaves the lift and the runtime alone would otherwise keep the old exe and its
|
||||
# old version.
|
||||
return fingerprint('compile-4', ctx.keys['lift'], runtime_key(ctx), ctx.layout.release,
|
||||
ctx.layout.pgo(game_version(ctx)) or 'no profile')
|
||||
|
||||
def current(self, ctx, record):
|
||||
@@ -1012,16 +1229,7 @@ class Compile(Step):
|
||||
|
||||
rep.progress('compile', 'compile', force=True)
|
||||
cpu = getattr(ctx, 'cpu', 'v3')
|
||||
lib = layout.runtime_lib_for(cpu)
|
||||
pgo = layout.pgo(game_version(ctx))
|
||||
code, log = run_tool(ctx, 'compile', layout.tools / 'build_game.py', [
|
||||
'--gen', ctx.temp / 'gen', '--out', build, '--toolchain', layout.llvm, '--cpu', cpu,
|
||||
*(['--deps', layout.deps] if layout.deps else []), *(['--sysroot', layout.sysroot] if layout.sysroot else []),
|
||||
'--runtime', layout.runtime, *(['--runtime-lib', lib] if lib else ()), *(['--pgo', pgo] if pgo else ()),
|
||||
'--ninja', layout.ninja,
|
||||
'--version', version_tag(game_version(ctx)), '--expected', layout.expected(game_version(ctx)),
|
||||
'--exefs', dest / 'exefs', '--romfs', dest / 'romfs',
|
||||
'--profile', dest / 'profile'], parse)
|
||||
code, log = run_tool(ctx, 'compile', layout.tools / 'build_game.py', build_args(ctx, ctx.temp / 'gen'), parse)
|
||||
exe = build / ('totk' + EXE)
|
||||
if code and link_output_locked(log):
|
||||
raise InstallError('compile.exe_locked', path=str(exe), log=str(log))
|
||||
@@ -1095,14 +1303,15 @@ class Prepare(Step):
|
||||
dest / 'romfs-patches'])
|
||||
if code:
|
||||
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
|
||||
# The same with Xbox button icons in the prompts, for prompts = xbox (make_romfs_patches.py --prompts):
|
||||
# romfs-patches-xbox for the Nintendo pad layout, romfs-patches-xbox-label for xbox and auto (runtime/input_map.c
|
||||
# input_prompts_folder). Both are written on every install, so the menu choices work without another run of
|
||||
# The same with Xbox and PlayStation button icons in the prompts, for prompts = xbox and playstation
|
||||
# (make_romfs_patches.py --prompts): romfs-patches-xbox for the Nintendo pad layout, romfs-patches-xbox-label
|
||||
# for xbox and auto, and romfs-patches-playstation / -playstation-xbox likewise (runtime/input_map.c
|
||||
# input_prompts_folder). All are written on every install, so the menu choices work without another run of
|
||||
# the setup. Optional: when one fails, the game keeps the Switch prompts with that layout and the menu says the
|
||||
# files are missing, so the setup warns once and goes on. The keyboard and mouse prompts are the PcPrompts
|
||||
# step's: they follow totk.ini's bindings.
|
||||
failed = None
|
||||
for style in ('xbox', 'xbox-label'):
|
||||
for style in screens.PAD_PROMPTS:
|
||||
out = dest / f'romfs-patches-{style}'
|
||||
remove(out)
|
||||
code, log = run_tool(ctx, f'prepare-{style}', layout.tools / 'make_romfs_patches.py',
|
||||
@@ -1199,17 +1408,59 @@ class PcPrompts(Step):
|
||||
|
||||
# ---- 6b. screen shapes
|
||||
|
||||
SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-xbox|-xbox-label|-pc)?-\d+x\d+$')
|
||||
SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-(?:%s))?-\d+x\d+(?:-hud(?:16|21)x9)?$'
|
||||
% '|'.join(map(re.escape, screens.PROMPTS_STYLES)))
|
||||
# make_romfs_patches.py writes <folder>.part-<pid> and renames it to <folder> when it is complete. A run that was
|
||||
# stopped (the PC turned off under a generator the game started, runtime/romfs.c romfs_folders_prepare) leaves its
|
||||
# folder behind: one whose files did not change for PART_STALE_S is such a leftover, a younger one may belong to a
|
||||
# generator running now. SHAPED_FOLDER matches neither.
|
||||
PART_FOLDER = re.compile(r'^romfs-patches[\w.-]*\.part-[\w-]+$')
|
||||
PART_STALE_S = 3600
|
||||
|
||||
|
||||
def stale_parts(dest, now=None):
|
||||
"""The leftover .part folders of make_romfs_patches.py runs in dest."""
|
||||
now = time.time() if now is None else now
|
||||
found = []
|
||||
for folder in dest.iterdir() if dest.is_dir() else ():
|
||||
if not (folder.is_dir() and not folder.is_symlink() and PART_FOLDER.match(folder.name)):
|
||||
continue
|
||||
try:
|
||||
newest = max([folder.stat().st_mtime] + [f.stat().st_mtime for f in folder.rglob('*')])
|
||||
except OSError:
|
||||
continue
|
||||
if now - newest > PART_STALE_S:
|
||||
found.append(folder)
|
||||
return found
|
||||
|
||||
|
||||
def hud_width(dest):
|
||||
"""The selected HUD cap, with the same default as runtime/cfg.c."""
|
||||
try:
|
||||
text = (dest / 'totk.ini').read_text(encoding='utf-8-sig', errors='replace')
|
||||
except OSError:
|
||||
text = ''
|
||||
value = (screens.ini_value(text, 'hud_width') or 'full').lower()
|
||||
return value if value in ('16:9', '21:9') else 'full'
|
||||
|
||||
|
||||
def shape_hud(size, hud):
|
||||
"""The selected cap when at least 1% narrower than the shape, as make_romfs_patches.py requires."""
|
||||
w, h = (int(v) for v in size.split('x'))
|
||||
cap = {'16:9': 16 / 9, '21:9': 21 / 9}.get(hud)
|
||||
return hud if cap and cap < w / h * 0.99 else None
|
||||
|
||||
|
||||
class Shapes(Step):
|
||||
"""romfs-patches-<w>x<h> (the UI laid out for a shape, make_romfs_patches.py --aspect) and, with Xbox or PC prompts
|
||||
"""romfs-patches-<w>x<h> (the UI laid out for a shape, make_romfs_patches.py --aspect) and, with Xbox, PlayStation or
|
||||
PC prompts
|
||||
in totk.ini, romfs-patches-<style>-<w>x<h> (that layout with those prompts), for the shapes this player needs:
|
||||
those of the connected displays and of the totk.ini output_res, one folder per shape (installer/screens.py; the
|
||||
game maps its resolution to the folder in runtime/romfs.c overlay_init). A setup before this step wrote all 15
|
||||
sizes for every prompts style, 64 folders. The key holds the shapes and the style, so a run of the setup after a
|
||||
monitor or settings change (or its rebuild mode) writes only these again; the game's settings menu can also start
|
||||
the generator for the shape in use (runtime/ui/menu.cpp row_output_res)."""
|
||||
sizes for every prompts style, 64 folders. The key holds the shapes, prompts style and selected HUD width, so a run after a
|
||||
monitor or settings change (or its rebuild mode) writes only these again; the game also starts the generator for a
|
||||
folder its settings need and the install lacks, at start and from its menu (runtime/romfs.c romfs_folders_prepare,
|
||||
make_romfs_patches.py --background), whose unfinished .part folders the clean-up below leaves alone."""
|
||||
|
||||
id = 'shapes'
|
||||
|
||||
@@ -1222,10 +1473,16 @@ class Shapes(Step):
|
||||
sizes, style = self.wanted(ctx)
|
||||
# The pc prompts' shaped folders are drawn from the same bindings as romfs-patches-pc, so they follow its key
|
||||
prompts = ctx.keys.get('pc_prompts', '') if style == 'pc' else ''
|
||||
return fingerprint('shapes-2', ctx.keys.get('prepare', ''), prompts, style or 'nintendo', *sizes)
|
||||
# Without a capped folder to write (hud_width full, or no shape wider than the cap) the key stays the one a
|
||||
# setup before hud_width wrote, so an existing install does not prepare its shaped folders again
|
||||
hud = hud_width(ctx.dest)
|
||||
if not any(shape_hud(size, hud) for size in sizes):
|
||||
return fingerprint('shapes-2', ctx.keys.get('prepare', ''), prompts, style or 'nintendo', *sizes)
|
||||
return fingerprint('shapes-3', ctx.keys.get('prepare', ''), prompts, style or 'nintendo', hud, *sizes)
|
||||
|
||||
def current(self, ctx, record):
|
||||
return all((ctx.dest / name / 'manifest.tsv').is_file() for name in record.get('folders', []))
|
||||
return not record.get('failed') and all((ctx.dest / name / 'manifest.tsv').is_file()
|
||||
for name in record.get('folders', []))
|
||||
|
||||
def run(self, ctx):
|
||||
layout, rep, dest = ctx.layout, ctx.reporter, ctx.dest
|
||||
@@ -1237,31 +1494,38 @@ class Shapes(Step):
|
||||
version = version_tag(game_version(ctx))
|
||||
plain = dest / f'romfs-patches-{style}' if style else None
|
||||
folders, failed = [], None
|
||||
hud = hud_width(dest)
|
||||
for i, size in enumerate(sizes):
|
||||
rep.progress('shapes', 'layouts', i, len(sizes), 'shapes', force=True)
|
||||
out = dest / f'romfs-patches-{size}'
|
||||
code, log = run_tool(ctx, 'shapes', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--aspect', size])
|
||||
if code:
|
||||
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
|
||||
folders.append(out.name)
|
||||
# Only the Common archive differs from romfs-patches-<style>: --reuse links the fonts, messages and size
|
||||
# table from there. Optional like that folder: the game keeps the Switch prompts with this layout.
|
||||
if not plain or not (plain / 'manifest.tsv').is_file():
|
||||
continue
|
||||
out = dest / f'romfs-patches-{style}-{size}'
|
||||
code, log = run_tool(ctx, f'shapes-{style}', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--prompts', style,
|
||||
'--aspect', size, '--reuse', plain, *(pc_binds(dest) if style == 'pc' else ())])
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
else:
|
||||
cap = shape_hud(size, hud)
|
||||
# Keep the full layout as a fallback, plus only the cap this player selected for this shape.
|
||||
for variant in (None, cap) if cap else (None,):
|
||||
suffix = '-hud' + variant.replace(':', 'x') if variant else ''
|
||||
hud_args = ['--hud', variant] if variant else []
|
||||
out = dest / f'romfs-patches-{size}{suffix}'
|
||||
code, log = run_tool(ctx, 'shapes', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--aspect', size,
|
||||
*hud_args])
|
||||
if code:
|
||||
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
|
||||
folders.append(out.name)
|
||||
# Reuse the selected prompts' fonts/messages/table; PC layouts retain the player's bindings.
|
||||
if not plain or not (plain / 'manifest.tsv').is_file():
|
||||
continue
|
||||
out = dest / f'romfs-patches-{style}-{size}{suffix}'
|
||||
code, log = run_tool(ctx, f'shapes-{style}', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--prompts', style,
|
||||
'--aspect', size, *hud_args, '--reuse', plain,
|
||||
*(pc_binds(dest) if style == 'pc' else ())])
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
else:
|
||||
folders.append(out.name)
|
||||
rep.progress('shapes', 'layouts', len(sizes), len(sizes), 'shapes', force=True)
|
||||
if failed:
|
||||
rep.warning('warn.xbox_prompts_failed', code=failed[0], log=str(failed[1]))
|
||||
return {'folders': folders, 'sizes': sizes, 'style': style}
|
||||
return {'folders': folders, 'sizes': sizes, 'style': style, 'hud': hud, 'failed': bool(failed)}
|
||||
|
||||
|
||||
# ---- 7. NVIDIA DLSS
|
||||
@@ -1355,7 +1619,7 @@ class Cleanup(Step):
|
||||
ctx.state['lang'] = ctx.lang
|
||||
(dest / 'profile').mkdir(exist_ok=True)
|
||||
rep.progress('cleanup', 'temp', force=True)
|
||||
for stale in dest.glob('update-merge-*'):
|
||||
for stale in [*dest.glob('update-merge-*'), *stale_parts(dest)]:
|
||||
remove(stale)
|
||||
for name in ('check', 'unpacked', 'shader_list.tsv', 'shared-fonts'): # gen/ and build/ stay for the next rebuild
|
||||
remove(ctx.temp / name)
|
||||
@@ -1364,10 +1628,11 @@ class Cleanup(Step):
|
||||
return {}
|
||||
|
||||
|
||||
# Puts the release folder (the argument after -c) on sys.path and runs installer.gui with the rest. `-m installer.gui`
|
||||
# finds the package only through the release Python's ._pth: the Linux release's Python and the dev-mode embeddable one
|
||||
# lack that entry, and totk.exe starts the command in the install folder.
|
||||
REBUILD_BOOT = ('import runpy, sys; sys.path.insert(0, sys.argv.pop(1)); '
|
||||
# Puts the release folder or the build kit (the argument after -c, made absolute: the kit's is relative to the install
|
||||
# folder) on sys.path and runs installer.gui with the rest. `-m installer.gui` finds the package only through the
|
||||
# release Python's ._pth: the Linux release's Python and the dev-mode embeddable one lack that entry, and totk.exe
|
||||
# starts the command in the install folder.
|
||||
REBUILD_BOOT = ('import os, runpy, sys; sys.path.insert(0, os.path.abspath(sys.argv.pop(1))); '
|
||||
"runpy.run_module('installer.gui', run_name='__main__', alter_sys=True)")
|
||||
|
||||
|
||||
@@ -1386,7 +1651,13 @@ def rebuild_command(ctx):
|
||||
python = Path(sys.executable) if layout.dev else layout.python
|
||||
if os.name == 'nt' and python.with_name('pythonw.exe').is_file():
|
||||
python = python.with_name('pythonw.exe')
|
||||
return [str(python), '-c', REBUILD_BOOT, str(layout.root), '--root', str(layout.root), '--rebuild', str(ctx.dest)]
|
||||
root, dest = str(layout.root), str(ctx.dest)
|
||||
if layouts.uses_kit(layout) and layout.root.resolve() == layouts.kit_folder(ctx.dest).resolve():
|
||||
# the build kit: paths relative to the install folder, which totk.exe resolves against its own folder and
|
||||
# starts the command in, so a moved install folder keeps its rebuild
|
||||
python = Path(layouts.KIT) / python.relative_to(layout.root)
|
||||
root, dest = layouts.KIT, '.'
|
||||
return [str(python), '-c', REBUILD_BOOT, root, '--root', root, '--rebuild', dest]
|
||||
|
||||
|
||||
def write_rebuild_command(ctx):
|
||||
@@ -1414,4 +1685,4 @@ def romfs_problem(romfs, expected):
|
||||
|
||||
|
||||
def all_steps():
|
||||
return [Check(), Fonts(), Extract(), Lift(), Compile(), Prepare(), PcPrompts(), Shapes(), Dlss(), Cleanup()]
|
||||
return [Check(), Kit(), Fonts(), Extract(), Lift(), Compile(), Prepare(), PcPrompts(), Shapes(), Dlss(), Cleanup()]
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "Computer und Spieldateien prüfen",
|
||||
"step.kit": "Build-Kit in den Spielordner kopieren",
|
||||
"step.fonts": "Systemschriften extrahieren",
|
||||
"step.extract": "Spiel entpacken",
|
||||
"step.lift": "Spielcode nach C übersetzen",
|
||||
"step.compile": "{game_exe} kompilieren",
|
||||
"step.prepare": "Shader vorbereiten",
|
||||
"step.pc_prompts": "Tastatur- und Maussymbole zeichnen",
|
||||
"step.shapes": "Spielbildschirme für deine Monitore anordnen",
|
||||
"step.dlss": "NVIDIA DLSS herunterladen",
|
||||
"step.cleanup": "Aufräumen",
|
||||
"phase.check.host": "Prozessor und Grafikkarte prüfen",
|
||||
"phase.check.verify": "Bereits installierte Dateien prüfen",
|
||||
"phase.check.verify_romfs": "Installierte Spieldaten prüfen",
|
||||
"phase.check.inputs": "Spieldateien mit den Schlüsseln öffnen",
|
||||
"phase.check.unpack_base": "Komprimiertes Basisspiel entpacken",
|
||||
"phase.check.unpack_update": "Komprimiertes Update entpacken",
|
||||
"phase.check.versions": "Spielversionen prüfen",
|
||||
"phase.kit.copy": "Die Werkzeuge kopieren, mit denen sich das Spiel für Code-Mods neu baut",
|
||||
"phase.fonts.extract": "Gemeinsame Schriften aus der Firmware extrahieren",
|
||||
"phase.fonts.copy": "Gemeinsame Schriften in den Installationsordner kopieren",
|
||||
"phase.extract.hash_base": "Prüfsumme des Hauptspiels berechnen",
|
||||
"phase.extract.hash_update": "Prüfsumme des Updates berechnen",
|
||||
"phase.extract.exefs": "Spielcode extrahieren",
|
||||
"phase.extract.copy": "Spieldaten kopieren",
|
||||
"phase.extract.merge": "Update auf die Spieldaten anwenden",
|
||||
"phase.extract.diagnose": "Beschädigte Spieldatei suchen",
|
||||
"phase.extract.index": "Spieldaten überprüfen",
|
||||
"phase.lift.discover": "Funktionen suchen",
|
||||
"phase.lift.emit": "C-Code schreiben",
|
||||
"phase.compile.compile": "Kompilieren",
|
||||
"phase.compile.link": "{game_exe} linken",
|
||||
"phase.prepare.romfs_patches": "Spieldaten-Patches für 60 fps schreiben",
|
||||
"phase.pc_prompts.draw": "Tastatur- und Maustastensymbole nach den Belegungen in totk.ini zeichnen",
|
||||
"phase.prepare.seed": "Shader aus den Spieldaten lesen",
|
||||
"phase.prepare.translate": "Shader übersetzen",
|
||||
"phase.prepare.libraries": "Shader für den Grafiktreiber erstellen",
|
||||
"phase.prepare.pack": "Shader-Cache in eine Datei packen",
|
||||
"phase.shapes.layouts": "Bildschirmlayouts und Tastensymbole für jedes Bildschirmformat schreiben",
|
||||
"phase.dlss.download": "nvngx_dlss.dll aus NVIDIAs DLSS SDK herunterladen",
|
||||
"phase.cleanup.ini": "totk.ini schreiben",
|
||||
"phase.cleanup.temp": "Temporäre Dateien entfernen",
|
||||
"cli.usage": "Ungültige Befehlszeile: {detail}",
|
||||
"internal": "Unerwarteter Fehler ({exception}): {detail}",
|
||||
"state.unreadable": "{path} kann nicht gelesen werden. Wähle einen anderen Ordner oder lösche diese Datei.",
|
||||
"state.newer_format": "{path} wurde von einem neueren Installationsprogramm geschrieben. Verwende dieses oder einen anderen Ordner.",
|
||||
"state.output_changed": "Installierte Dateien des Schritts „{step}“ haben sich seit ihrer Erstellung geändert; dieser Schritt läuft erneut.",
|
||||
"check.release_incomplete": "Der Ordner des Installationsprogramms ist unvollständig; es fehlt: {paths}. Entpacke das Release erneut.",
|
||||
"check.dest_not_folder": "Der Installationsort {path} ist eine Datei, kein Ordner.",
|
||||
"check.dest_not_empty": "Der Installationsordner {path} ist nicht leer und enthält keine frühere Installation. Wähle einen leeren Ordner.",
|
||||
"check.lang_missing": "Wähle die Spielsprache.",
|
||||
"check.lang_unknown": "Unbekannte Sprache „{lang}“. Bekannt: {known}.",
|
||||
"check.toolchain_broken": "Der mitgelieferte Compiler funktioniert nicht: {detail}",
|
||||
"check.glibc_old": "Die C-Bibliothek dieses Systems ist glibc {version}; der Compiler des Setups braucht {need} oder neuer (Ubuntu 22.04, Debian 12, Fedora 35, SteamOS 3 und neuer haben sie). Ein Systemupdate behebt das.",
|
||||
"check.host_probe_failed": "Die Computerprüfung ist nicht gelaufen (Exit-Code {code}).",
|
||||
"check.cpu_too_old": "Diesem Prozessor fehlt x86-64-v2 (SSE4.2, POPCNT und CMPXCHG16B), die älteste Stufe, für die das Spiel gebaut wird. Intel Nehalem (2008) oder AMD Bulldozer (2011) und neuer haben sie.",
|
||||
"check.vulkan_missing": "Es ist kein Vulkan-Treiber installiert. Installiere den neuesten Treiber für deine Grafikkarte.",
|
||||
"check.vulkan_no_device": "Vulkan findet keine Grafikkarte. Installiere den neuesten Treiber für deine Grafikkarte.",
|
||||
"check.vulkan_too_old": "Das Spiel braucht eine Grafikkarte mit Vulkan 1.3; gefunden: {devices}. Aktualisiere den Grafiktreiber.",
|
||||
"check.no_display": "Zum Vorbereiten der Shader wird ein Bildschirm gebraucht. Starte das Setup aus der Desktop-Sitzung oder setze DISPLAY=:0 (auf einem Steam Deck im Spielmodus zusätzlich XDG_RUNTIME_DIR=/run/user/1000).",
|
||||
"check.inputs_needed": "Die Spieldateien werden gebraucht: wähle das Hauptspiel, das Update 1.1.0, 1.2.1 oder 1.4.3 und prod.keys.",
|
||||
"check.input_missing": "Datei nicht gefunden ({input}): {path}",
|
||||
"check.keys_unreadable": "Die Schlüsseldatei kann nicht gelesen werden. Wähle eine prod.keys-Datei.",
|
||||
"check.keys_no_header_key": "Die Schlüsseldatei enthält keinen header_key. Lies prod.keys erneut von deiner Konsole aus.",
|
||||
"check.keys_wrong": "Die Schlüssel können die Datei ({input}) nicht öffnen. Verwende die prod.keys deiner Konsole.",
|
||||
"check.keys_too_old": "Die Schlüsseldatei ist zu alt für die Datei ({input}) (braucht Schlüsselgeneration {generation}). Lies prod.keys von einer Konsole mit neuerer Firmware aus.",
|
||||
"check.not_game_file": "Die Datei ({input}) ist keine XCI-, NSP-, XCZ- oder NSZ-Spieldatei.",
|
||||
"check.file_unreadable": "Die Datei ({input}) kann nicht gelesen werden: {detail}",
|
||||
"check.unpack_failed": "Die komprimierte Datei {input} konnte nicht entpackt werden: {detail}",
|
||||
"check.ticket_personalized": "Die Datei ({input}) enthält ein personalisiertes Ticket; ein allgemeines Ticket wird gebraucht.",
|
||||
"check.ticket_missing": "Der Datei ({input}) fehlt das Ticket, das ihr Inhalt braucht.",
|
||||
"check.base_not_totk": "Die Hauptspieldatei ist nicht The Legend of Zelda: Tears of the Kingdom ({detail}).",
|
||||
"check.base_is_update": "Die Hauptspieldatei ist ein Update. Wähle hier das Hauptspiel als NSP oder XCI (Version 1.0.0) und diese Datei als Update.",
|
||||
"check.base_combined": "Die Hauptspieldatei enthält mehrere Pakete (Hauptspiel, Update oder DLC in einer Datei). Wähle einen Dump des Hauptspiels, der nur das Spiel enthält.",
|
||||
"check.update_not_nsp": "Das Update muss eine NSP- oder NSZ-Datei sein.",
|
||||
"check.update_is_base": "Die Update-Datei enthält ein Hauptspiel. Wähle die NSP des Updates 1.1.0, 1.2.1 oder 1.4.3.",
|
||||
"check.update_not_totk": "Die Update-Datei ist kein Update von Tears of the Kingdom ({detail}).",
|
||||
"check.exefs_failed": "Der Spielcode der Datei ({input}) hat die Prüfungen nicht bestanden; siehe {log}.",
|
||||
"check.input_damaged": "Die Datei ({input}) ist beschädigt oder unvollständig: {path} ({detail}). Kopiere diese Datei erneut von ihrer Quelle oder erstelle den Dump neu und starte das Setup dann erneut.",
|
||||
"check.base_wrong_version": "Das Hauptspiel ist nicht Version 1.0.0 ({modules} weichen ab).",
|
||||
"check.update_wrong_version": "Das Update hat Version {found}; dieses Release verwendet {wanted}.",
|
||||
"check.disk_space": "Nicht genug freier Speicher für {path}: {need_gb} GB nötig, {free_gb} GB frei.",
|
||||
"check.firmware_missing": "Der Firmware-Ordner {path} existiert nicht. Wähle den Ordner Contents/registered der Firmware.",
|
||||
"check.firmware_empty": "Der Firmware-Ordner {path} enthält keine NCA-Dateien. Wähle den Ordner Contents/registered der Firmware.",
|
||||
"check.fonts_keys_needed": "Die gemeinsamen Schriften für diese Sprache sind noch nicht installiert; wähle prod.keys, damit das Setup sie aus der Firmware extrahieren kann.",
|
||||
"extract.exefs_mismatch": "Der extrahierte Spielcode passt nicht zu Version {version} ({modules}).",
|
||||
"extract.romfs_merge_failed": "Das Anwenden des Updates auf die Spieldaten ist fehlgeschlagen: {detail}. Details: {log}",
|
||||
"extract.romfs_mismatch": "Die extrahierten Spieldaten passen nicht zu Version {version} (Größe {size}, Prüfsumme {sha256}...).",
|
||||
"fonts.failed": "Das Extrahieren der gemeinsamen Schriften ist fehlgeschlagen (Exit-Code {code}): {detail}. Details: {log}",
|
||||
"fonts.incomplete": "Beim Extrahieren der gemeinsamen Schriften wurden nicht alle Dateien geschrieben ({files}).",
|
||||
"fonts.copy_failed": "Die gemeinsamen Schriften können nicht nach {path} kopiert werden: {detail}",
|
||||
"lift.failed": "Das Übersetzen des Spielcodes ist fehlgeschlagen (Exit-Code {code}). Details: {log}",
|
||||
"compile.failed": "Das Kompilieren von {game_exe} ist fehlgeschlagen (Exit-Code {code}). Details: {log}",
|
||||
"compile.exe_in_use": "{path} wird verwendet. Schließe das Spiel und starte das Installationsprogramm erneut.",
|
||||
"kit.in_use": "{path} wird gerade verwendet. Schließe das Spiel und jedes offene Setup- oder Neubau-Fenster und starte das Setup dann erneut.",
|
||||
"kit.copy_failed": "Das Build-Kit kann nicht nach {path} kopiert werden: {detail}",
|
||||
"compile.exe_locked": "{path} kann nicht geschrieben werden: Ein anderes Programm hält die Datei, etwa ein aus diesem Ordner gestartetes Spiel oder ein Virenscanner, der die Datei gemeldet hat. Schließe das Spiel, nimm den Ordner des Setups und den Installationsordner in die Ausnahmen des Virenscanners auf, starte Windows neu und starte das Setup dann erneut. Details: {log}",
|
||||
"prepare.xlate_in_use": "{path} wird verwendet. Schließe das Spiel, beende jeden von einem früheren Lauf übrigen totk_xlate-Prozess und starte das Installationsprogramm erneut.",
|
||||
"prepare.shader_list_missing": "Die Shader-Liste fehlt.",
|
||||
"prepare.romfs_patches_failed": "Das Schreiben der Spieldaten-Patches ist fehlgeschlagen (Exit-Code {code}). Details: {log}",
|
||||
"prepare.shaders_failed": "Das Vorbereiten der Shader ist fehlgeschlagen (Exit-Code {code}). Details: {log}",
|
||||
"cleanup.romfs_unreadable": "Die Spieldaten in {path} fehlen nach der Installation oder können nicht gelesen werden. Starte Windows neu und führe das Installationsprogramm erneut auf demselben Ordner aus: Es entpackt die Spieldaten erneut und behält den Rest.",
|
||||
"prepare.pack_failed": "Das Packen des Shader-Caches ist fehlgeschlagen (Exit-Code {code}). Details: {log}",
|
||||
"cleanup.ini_failed": "totk.ini kann nicht geschrieben werden: {detail}",
|
||||
"warn.lang_needs_fonts": "Text auf {lang} braucht die Systemschriften der Switch, und es wurden keine angegeben. Das Spiel startet in dieser Sprache erst, wenn sie hinzugefügt sind. Wähle den Firmware-Ordner (Contents/registered) oder lies „Switch system fonts“ in docs/installer.md.",
|
||||
"warn.npdm_differs": "main.npdm weicht vom Referenz-Dump {version} ab; nur die Codemodule werden verwendet.",
|
||||
"warn.cheats_skipped": "Die Cheats des Mods-Ordners, die den Spielcode ändern, konnten nicht gebaut werden; das Spiel wird ohne sie installiert. Details: {log}",
|
||||
"warn.exefs_skipped": "Die ExeFS-Patches der Mods (.ips, .pchtxt) konnten nicht gebaut werden; das Spiel wird ohne sie installiert. Details: {log}",
|
||||
"warn.plugins_skipped": "Die Code-Plugins der Mods (exefs subsdk) konnten nicht gebaut werden; das Spiel wird ohne sie installiert. Details: {log}",
|
||||
"warn.xbox_prompts_failed": "Die Xbox-, PlayStation- oder PC-Tastensymbole konnten nicht vorbereitet werden (Exit-Code {code}); das Spiel behält die Switch-Symbole. Details: {log}",
|
||||
"warn.shaders_skipped": "Der Grafiktreiber ist beim Erstellen einiger Shader abgestürzt, daher wurden {count} bei der Vorbereitung ausgelassen. Das Spiel erstellt sie, wenn es sie zum ersten Mal braucht, und der Treiber kann dort ebenfalls abstürzen; ein Treiberupdate kann das beheben. Details: {log}",
|
||||
"warn.kernel_old": "Linux {version} fehlt das Schreib-Tracking, auf das das Spiel angewiesen ist (6.7 oder neuer); das Spiel kann sehr langsam laufen. Ein Systemupdate behebt das.",
|
||||
"warn.dlss_kept": "Im Installationsordner liegt bereits eine DLSS-Bibliothek ({path}); das Setup behält sie.",
|
||||
"warn.dlss_download_failed": "NVIDIA DLSS konnte nicht von {url} heruntergeladen werden: {detail}. Das Spiel läuft ohne; der nächste Setup-Lauf versucht es erneut.",
|
||||
"ui.title": "TotK-Setup",
|
||||
"ui.rebuild_title": "Spiel für deine Mods neu bauen",
|
||||
"ui.start_game": "Spiel starten",
|
||||
"ui.version": "Version {version}",
|
||||
"ui.intro": "Erstellt aus deinen eigenen Spieldateien einen spielbaren Ordner von Tears of the Kingdom. Das dauert eine Weile und läuft einmal.",
|
||||
"ui.notice": "Der Ordner, den dieses Setup erstellt, enthält das Spiel. Er ist nur für deinen eigenen Gebrauch; teile ihn nicht und lade ihn nicht hoch.",
|
||||
"ui.keys_private": "Die Schlüsseldatei wird an Ort und Stelle gelesen. Ihr Inhalt wird nie angezeigt, kopiert oder gespeichert.",
|
||||
"ui.base": "Hauptspiel",
|
||||
"ui.update": "Update",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Firmware (optional)",
|
||||
"ui.game_language": "Spielsprache",
|
||||
"ui.dest": "Installationsordner",
|
||||
"ui.browse": "Durchsuchen...",
|
||||
"ui.pick_game": "Hauptspieldatei wählen",
|
||||
"ui.pick_update": "Datei des Updates 1.1.0, 1.2.1 oder 1.4.3 wählen",
|
||||
"ui.pick_keys": "prod.keys wählen",
|
||||
"ui.pick_firmware": "Ordner der Switch-Firmware wählen (Contents/registered)",
|
||||
"ui.pick_dest": "Installationsordner wählen",
|
||||
"ui.firmware_help": "Für chinesischen, koreanischen und traditionell chinesischen Text: der Ordner Contents/registered der Firmware, zum Beispiel aus Ryujinx oder Yuzu. Das Setup kopiert daraus die Systemschriften der Switch in den Installationsordner.",
|
||||
"ui.dlss": "NVIDIA DLSS (nvngx_dlss.dll) für NVIDIA-RTX-Grafikkarten herunterladen",
|
||||
"ui.dlss_help": "Aus NVIDIAs DLSS SDK auf GitHub, unter NVIDIAs RTX-SDK-Lizenz (github.com/NVIDIA/DLSS). Damit funktionieren die Einstellungen dlaa und DLSS; ohne die Datei bewirken sie nichts.",
|
||||
"ui.compressed_help": "Komprimierte NSZ- und XCZ-Dateien funktionieren direkt: Das Setup entpackt sie selbst (bis die Spieldaten extrahiert sind, braucht das so viel freien Speicher, wie die entpackten Dateien belegen).",
|
||||
"ui.section_files": "Spieldateien",
|
||||
"ui.section_install": "Installation",
|
||||
"ui.more_details": "▸ Weitere Details",
|
||||
"ui.fewer_details": "▾ Details ausblenden",
|
||||
"ui.formats_help": "Hauptspiel: NSP, XCI, NSZ oder XCZ. Update: 1.1.0, 1.2.1 oder 1.4.3, als NSP oder NSZ.",
|
||||
"ui.type_game": "Spieldateien (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Schlüsseldateien (*.keys)",
|
||||
"ui.type_all": "Alle Dateien",
|
||||
"ui.start": "Starten",
|
||||
"ui.cancel": "Abbrechen",
|
||||
"ui.cancelling": "Wird abgebrochen...",
|
||||
"ui.show_log": "Protokoll zeigen",
|
||||
"ui.hide_log": "Protokoll ausblenden",
|
||||
"ui.close": "Schließen",
|
||||
"ui.back": "Zurück",
|
||||
"ui.open_folder": "Ordner öffnen",
|
||||
"ui.update_mode": "Dieser Ordner enthält eine frühere Installation. Das Setup setzt sie fort oder aktualisiert sie; die Spieldateien werden nur verlangt, wenn sie erneut gebraucht werden.",
|
||||
"ui.need_dest": "Wähle den Installationsordner.",
|
||||
"ui.need_base": "Wähle die Hauptspieldatei.",
|
||||
"ui.need_update": "Wähle die Datei des Updates 1.1.0, 1.2.1 oder 1.4.3.",
|
||||
"ui.need_keys": "Wähle die Datei prod.keys.",
|
||||
"ui.need_lang": "Wähle die Spielsprache.",
|
||||
"ui.missing_base": "Die Hauptspieldatei existiert nicht.",
|
||||
"ui.missing_update": "Die Update-Datei existiert nicht.",
|
||||
"ui.missing_keys": "Die Schlüsseldatei existiert nicht.",
|
||||
"ui.missing_firmware": "Der Firmware-Ordner existiert nicht.",
|
||||
"ui.running_install": "Installation",
|
||||
"ui.running_resume": "Früheres Setup wird fortgesetzt",
|
||||
"ui.running_update": "Installation wird aktualisiert",
|
||||
"ui.state_started": "gestartet",
|
||||
"ui.state_done": "fertig",
|
||||
"ui.state_skipped": "übersprungen",
|
||||
"ui.state_pending": "wartet",
|
||||
"ui.state_running": "läuft",
|
||||
"ui.state_failed": "fehlgeschlagen",
|
||||
"ui.log_warning": "Warnung",
|
||||
"ui.log_error": "Fehler",
|
||||
"ui.log_space": "Benötigter Speicher: {need} GB, frei: {free} GB",
|
||||
"ui.log_end": "Beendet",
|
||||
"ui.result_ok": "Das Spiel ist bereit",
|
||||
"ui.result_failed": "Das Setup ist fehlgeschlagen",
|
||||
"ui.result_cancelled": "Das Setup wurde abgebrochen",
|
||||
"ui.done_text": "Starte {game_exe} aus {dest}. Das Setup-Programm und die gewählten Spieldateien werden nicht mehr gebraucht.",
|
||||
"ui.cancelled_text": "Die fertigen Schritte bleiben erhalten. Starte das Setup erneut mit demselben Ordner, um fortzufahren.",
|
||||
"ui.log_file": "Protokolldatei: {path}",
|
||||
"ui.process_died": "Das Setup wurde unerwartet beendet (Exit-Code {code}).",
|
||||
"ui.confirm_cancel": "Das Setup läuft. Abbrechen und das Fenster schließen?",
|
||||
"ui.space_one": "Benötigter freier Speicher auf {path}: {need} GB (frei: {free} GB).",
|
||||
"ui.space_two": "Benötigter freier Speicher auf {path}: {need} GB (frei: {free} GB); auf {temp}: {temp_need} GB (frei: {temp_free} GB).",
|
||||
"ui.amount_bytes": "{done} / {total} GB",
|
||||
"ui.amount_chunks": "{done} / {total} Teile",
|
||||
"ui.amount_objects": "{done} / {total} Dateien",
|
||||
"ui.amount_shaders": "{done} / {total} Shader",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n} s",
|
||||
"param.input.base": "Hauptspiel",
|
||||
"param.input.update": "Update",
|
||||
"param.input.keys": "Schlüssel",
|
||||
"launcher.title": "TotK-Setup",
|
||||
"launcher.python_missing": "Die Setup-Dateien sind unvollständig: Der Ordner python neben TotK-Setup.exe fehlt. Entpacke das ganze Archiv erneut und starte TotK-Setup.exe aus dem entpackten Ordner.",
|
||||
"lang.ja": "Japanisch",
|
||||
"lang.en-US": "Englisch (USA)",
|
||||
"lang.en-GB": "Englisch (UK)",
|
||||
"lang.fr": "Französisch",
|
||||
"lang.fr-CA": "Französisch (Kanada)",
|
||||
"lang.de": "Deutsch",
|
||||
"lang.it": "Italienisch",
|
||||
"lang.es": "Spanisch",
|
||||
"lang.es-419": "Spanisch (Lateinamerika)",
|
||||
"lang.nl": "Niederländisch",
|
||||
"lang.pt": "Portugiesisch",
|
||||
"lang.pt-BR": "Portugiesisch (Brasilien)",
|
||||
"lang.ru": "Russisch",
|
||||
"lang.ko": "Koreanisch",
|
||||
"lang.zh-Hans": "Chinesisch (vereinfacht)",
|
||||
"lang.zh-Hant": "Chinesisch (traditionell)"
|
||||
}
|
||||
+14
-4
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"step.check": "Checking the computer and the game files",
|
||||
"step.kit": "Copying the build kit into the game folder",
|
||||
"step.fonts": "Extracting the system fonts",
|
||||
"step.extract": "Extracting the game",
|
||||
"step.lift": "Translating the game code to C",
|
||||
@@ -17,6 +18,7 @@
|
||||
"phase.check.unpack_base": "Unpacking the compressed base game",
|
||||
"phase.check.unpack_update": "Unpacking the compressed update",
|
||||
"phase.check.versions": "Checking the game versions",
|
||||
"phase.kit.copy": "Copying the tools the game rebuilds itself with for code mods",
|
||||
"phase.fonts.extract": "Extracting the shared fonts from the firmware",
|
||||
"phase.fonts.copy": "Copying the shared fonts into the install folder",
|
||||
"phase.extract.hash_base": "Computing the checksum of the base game",
|
||||
@@ -95,6 +97,8 @@
|
||||
"lift.failed": "Translating the game code failed (exit code {code}). Details: {log}",
|
||||
"compile.failed": "Compiling {game_exe} failed (exit code {code}). Details: {log}",
|
||||
"compile.exe_in_use": "{path} is in use. Close the game and run the installer again.",
|
||||
"kit.in_use": "{path} is in use. Close the game and any open setup or rebuild window, then run the installer again.",
|
||||
"kit.copy_failed": "The build kit cannot be copied to {path}: {detail}",
|
||||
"compile.exe_locked": "{path} cannot be written: another program holds it, a game started from that folder or an antivirus that flagged the file. Close the game, add the setup's folder and the install folder to the antivirus exclusions, restart Windows, then run the installer again. Details: {log}",
|
||||
"prepare.xlate_in_use": "{path} is in use. Close the game, end any totk_xlate process left from an earlier run, then run the installer again.",
|
||||
"prepare.shader_list_missing": "The shader list is missing.",
|
||||
@@ -108,7 +112,8 @@
|
||||
"warn.npdm_differs": "main.npdm differs from the reference {version} dump; only the code modules are used.",
|
||||
"warn.cheats_skipped": "The cheats of the mods folder that change the game's code could not be built; the game installs without them. Details: {log}",
|
||||
"warn.exefs_skipped": "The mods' ExeFS patches (.ips, .pchtxt) could not be built; the game installs without them. Details: {log}",
|
||||
"warn.xbox_prompts_failed": "The Xbox or PC button prompts could not be prepared (exit code {code}); the game keeps the Switch prompts. Details: {log}",
|
||||
"warn.plugins_skipped": "The mods' code plugins (exefs subsdk) could not be built; the game installs without them. Details: {log}",
|
||||
"warn.xbox_prompts_failed": "The Xbox, PlayStation or PC button prompts could not be prepared (exit code {code}); the game keeps the Switch prompts. Details: {log}",
|
||||
"warn.shaders_skipped": "The graphics driver crashed while building some shaders, so {count} were left out of the preparation. The game builds them when it first needs them, and the driver may crash there too; a driver update may fix it. Details: {log}",
|
||||
"warn.kernel_old": "Linux {version} lacks the write tracking the game relies on (6.7 or later); the game may run very slowly. Updating the system fixes this.",
|
||||
"warn.dlss_kept": "A DLSS library is already in the install folder ({path}); the setup keeps it.",
|
||||
@@ -121,10 +126,10 @@
|
||||
"ui.intro": "Builds a playable Tears of the Kingdom folder from your own game files. This takes a while and runs once.",
|
||||
"ui.notice": "The folder this setup builds contains the game. It is for your own use only; do not share or upload it.",
|
||||
"ui.keys_private": "The keys file is read in place. Its contents are never shown, copied or stored.",
|
||||
"ui.base": "Base game (NSP, XCI, NSZ or XCZ)",
|
||||
"ui.update": "Update 1.1.0 or 1.2.1 or 1.4.3 (NSP or NSZ)",
|
||||
"ui.base": "Base game",
|
||||
"ui.update": "Update",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Firmware folder (optional)",
|
||||
"ui.firmware": "Firmware (optional)",
|
||||
"ui.game_language": "Game language",
|
||||
"ui.dest": "Install folder",
|
||||
"ui.browse": "Browse...",
|
||||
@@ -137,6 +142,11 @@
|
||||
"ui.dlss": "Download NVIDIA DLSS (nvngx_dlss.dll) for NVIDIA RTX graphics cards",
|
||||
"ui.dlss_help": "From NVIDIA's DLSS SDK on GitHub, under NVIDIA's RTX SDK license (github.com/NVIDIA/DLSS). It makes the dlaa and DLSS settings work; without it they do nothing.",
|
||||
"ui.compressed_help": "Compressed NSZ and XCZ files work as they are: the setup unpacks them by itself (until the game data is extracted, that needs as much free space as the unpacked files take).",
|
||||
"ui.section_files": "Game files",
|
||||
"ui.section_install": "Install",
|
||||
"ui.more_details": "▸ More details",
|
||||
"ui.fewer_details": "▾ Hide details",
|
||||
"ui.formats_help": "Base game: NSP, XCI, NSZ or XCZ. Update: 1.1.0, 1.2.1 or 1.4.3, as NSP or NSZ.",
|
||||
"ui.type_game": "Game files (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Key files (*.keys)",
|
||||
"ui.type_all": "All files",
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "Comprobando el equipo y los archivos del juego",
|
||||
"step.kit": "Copiando el kit de compilación en la carpeta del juego",
|
||||
"step.fonts": "Extrayendo las fuentes del sistema",
|
||||
"step.extract": "Extrayendo el juego",
|
||||
"step.lift": "Traduciendo el código del juego a C",
|
||||
"step.compile": "Compilando {game_exe}",
|
||||
"step.prepare": "Preparando los shaders",
|
||||
"step.pc_prompts": "Dibujando los iconos de teclado y ratón",
|
||||
"step.shapes": "Ajustando las pantallas del juego a tus monitores",
|
||||
"step.dlss": "Descargando NVIDIA DLSS",
|
||||
"step.cleanup": "Limpiando",
|
||||
"phase.check.host": "Comprobando el procesador y la tarjeta gráfica",
|
||||
"phase.check.verify": "Comprobando los archivos ya instalados",
|
||||
"phase.check.verify_romfs": "Comprobando los datos del juego instalados",
|
||||
"phase.check.inputs": "Abriendo los archivos del juego con las claves",
|
||||
"phase.check.unpack_base": "Descomprimiendo el juego base comprimido",
|
||||
"phase.check.unpack_update": "Descomprimiendo la actualización comprimida",
|
||||
"phase.check.versions": "Comprobando las versiones del juego",
|
||||
"phase.kit.copy": "Copiando las herramientas con las que el juego se recompila para los mods de código",
|
||||
"phase.fonts.extract": "Extrayendo las fuentes compartidas del firmware",
|
||||
"phase.fonts.copy": "Copiando las fuentes compartidas a la carpeta de instalación",
|
||||
"phase.extract.hash_base": "Calculando la suma de comprobación del juego base",
|
||||
"phase.extract.hash_update": "Calculando la suma de comprobación de la actualización",
|
||||
"phase.extract.exefs": "Extrayendo el código del juego",
|
||||
"phase.extract.copy": "Copiando los datos del juego",
|
||||
"phase.extract.merge": "Aplicando la actualización a los datos del juego",
|
||||
"phase.extract.diagnose": "Buscando el archivo del juego dañado",
|
||||
"phase.extract.index": "Verificando los datos del juego",
|
||||
"phase.lift.discover": "Buscando las funciones",
|
||||
"phase.lift.emit": "Escribiendo código C",
|
||||
"phase.compile.compile": "Compilando",
|
||||
"phase.compile.link": "Enlazando {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Escribiendo los parches de datos para 60 fps",
|
||||
"phase.pc_prompts.draw": "Dibujando los iconos de teclas y botones del ratón según las asignaciones de totk.ini",
|
||||
"phase.prepare.seed": "Leyendo los shaders de los datos del juego",
|
||||
"phase.prepare.translate": "Traduciendo los shaders",
|
||||
"phase.prepare.libraries": "Creando los shaders para el controlador gráfico",
|
||||
"phase.prepare.pack": "Empaquetando la caché de shaders en un archivo",
|
||||
"phase.shapes.layouts": "Escribiendo las disposiciones de pantalla y los iconos de botones para cada formato de pantalla",
|
||||
"phase.dlss.download": "Descargando nvngx_dlss.dll del DLSS SDK de NVIDIA",
|
||||
"phase.cleanup.ini": "Escribiendo totk.ini",
|
||||
"phase.cleanup.temp": "Eliminando los archivos temporales",
|
||||
"cli.usage": "Línea de comandos no válida: {detail}",
|
||||
"internal": "Error inesperado ({exception}): {detail}",
|
||||
"state.unreadable": "No se puede leer {path}. Elige otra carpeta o elimina ese archivo.",
|
||||
"state.newer_format": "{path} lo escribió un instalador más reciente. Usa ese instalador u otra carpeta.",
|
||||
"state.output_changed": "Los archivos instalados del paso '{step}' cambiaron desde que se crearon; ese paso se ejecuta de nuevo.",
|
||||
"check.release_incomplete": "La carpeta del instalador está incompleta; falta: {paths}. Descomprime la versión de nuevo.",
|
||||
"check.dest_not_folder": "La ubicación de instalación {path} es un archivo, no una carpeta.",
|
||||
"check.dest_not_empty": "La carpeta de instalación {path} no está vacía y no contiene ninguna instalación anterior. Elige una carpeta vacía.",
|
||||
"check.lang_missing": "Elige el idioma del juego.",
|
||||
"check.lang_unknown": "Idioma desconocido '{lang}'. Conocidos: {known}.",
|
||||
"check.toolchain_broken": "El compilador incluido no funciona: {detail}",
|
||||
"check.glibc_old": "La biblioteca C de este sistema es glibc {version}; el compilador del instalador necesita {need} o posterior (Ubuntu 22.04, Debian 12, Fedora 35, SteamOS 3 y posteriores la tienen). Actualizar el sistema lo soluciona.",
|
||||
"check.host_probe_failed": "La comprobación del equipo no se ejecutó (código de salida {code}).",
|
||||
"check.cpu_too_old": "Este procesador no tiene x86-64-v2 (SSE4.2, POPCNT y CMPXCHG16B), el nivel más antiguo para el que se compila el juego. Intel Nehalem (2008) o AMD Bulldozer (2011) y posteriores lo tienen.",
|
||||
"check.vulkan_missing": "No hay ningún controlador Vulkan instalado. Instala el controlador más reciente de tu tarjeta gráfica.",
|
||||
"check.vulkan_no_device": "Vulkan no encuentra ninguna tarjeta gráfica. Instala el controlador más reciente de tu tarjeta gráfica.",
|
||||
"check.vulkan_too_old": "El juego necesita una tarjeta gráfica con Vulkan 1.3; encontrado: {devices}. Actualiza el controlador gráfico.",
|
||||
"check.no_display": "Preparar los shaders necesita una pantalla. Ejecuta el instalador desde la sesión de escritorio o exporta DISPLAY=:0 (en una Steam Deck en modo Juego, también XDG_RUNTIME_DIR=/run/user/1000).",
|
||||
"check.inputs_needed": "Se necesitan los archivos del juego: elige el juego base, la actualización 1.1.0, 1.2.1 o 1.4.3 y prod.keys.",
|
||||
"check.input_missing": "Archivo no encontrado ({input}): {path}",
|
||||
"check.keys_unreadable": "No se puede leer el archivo de claves. Elige un archivo prod.keys.",
|
||||
"check.keys_no_header_key": "El archivo de claves no tiene header_key. Vuelve a extraer prod.keys de tu consola.",
|
||||
"check.keys_wrong": "Las claves no pueden abrir el archivo ({input}). Usa el prod.keys de tu consola.",
|
||||
"check.keys_too_old": "El archivo de claves es demasiado antiguo para el archivo ({input}) (necesita la generación de claves {generation}). Extrae prod.keys de una consola con un firmware más reciente.",
|
||||
"check.not_game_file": "El archivo ({input}) no es un archivo de juego XCI, NSP, XCZ o NSZ.",
|
||||
"check.file_unreadable": "No se puede leer el archivo ({input}): {detail}",
|
||||
"check.unpack_failed": "No se pudo descomprimir el archivo comprimido {input}: {detail}",
|
||||
"check.ticket_personalized": "El archivo ({input}) lleva un ticket personalizado; se necesita un ticket común.",
|
||||
"check.ticket_missing": "Al archivo ({input}) le falta el ticket que necesita su contenido.",
|
||||
"check.base_not_totk": "El archivo del juego base no es The Legend of Zelda: Tears of the Kingdom ({detail}).",
|
||||
"check.base_is_update": "El archivo del juego base es una actualización. Elige aquí el juego base en NSP o XCI (versión 1.0.0) y este archivo como actualización.",
|
||||
"check.base_combined": "El archivo del juego base contiene varios paquetes (juego base, actualización o DLC en un solo archivo). Elige un volcado del juego base que contenga solo el juego.",
|
||||
"check.update_not_nsp": "La actualización debe ser un archivo NSP o NSZ.",
|
||||
"check.update_is_base": "El archivo de actualización contiene un juego base. Elige el NSP de la actualización 1.1.0, 1.2.1 o 1.4.3.",
|
||||
"check.update_not_totk": "El archivo de actualización no es una actualización de Tears of the Kingdom ({detail}).",
|
||||
"check.exefs_failed": "El código del juego del archivo ({input}) no superó las comprobaciones; consulta {log}.",
|
||||
"check.input_damaged": "El archivo ({input}) está dañado o incompleto: {path} ({detail}). Vuelve a copiar ese archivo desde su origen o vuelve a volcarlo y ejecuta el instalador de nuevo.",
|
||||
"check.base_wrong_version": "El juego base no es la versión 1.0.0 ({modules} difieren).",
|
||||
"check.update_wrong_version": "La actualización es la versión {found}; esta versión usa {wanted}.",
|
||||
"check.disk_space": "No hay suficiente espacio libre para {path}: se necesitan {need_gb} GB, hay {free_gb} GB libres.",
|
||||
"check.firmware_missing": "La carpeta del firmware {path} no existe. Elige la carpeta Contents/registered del firmware.",
|
||||
"check.firmware_empty": "La carpeta del firmware {path} no contiene archivos NCA. Elige la carpeta Contents/registered del firmware.",
|
||||
"check.fonts_keys_needed": "Las fuentes compartidas de este idioma aún no están instaladas; elige prod.keys para que el instalador pueda extraerlas del firmware.",
|
||||
"extract.exefs_mismatch": "El código del juego extraído no coincide con la versión {version} ({modules}).",
|
||||
"extract.romfs_merge_failed": "Falló la aplicación de la actualización a los datos del juego: {detail}. Detalles: {log}",
|
||||
"extract.romfs_mismatch": "Los datos del juego extraídos no coinciden con la versión {version} (tamaño {size}, suma de comprobación {sha256}...).",
|
||||
"fonts.failed": "Falló la extracción de las fuentes compartidas (código de salida {code}): {detail}. Detalles: {log}",
|
||||
"fonts.incomplete": "La extracción de las fuentes compartidas no escribió todos los archivos ({files}).",
|
||||
"fonts.copy_failed": "No se pueden copiar las fuentes compartidas a {path}: {detail}",
|
||||
"lift.failed": "Falló la traducción del código del juego (código de salida {code}). Detalles: {log}",
|
||||
"compile.failed": "Falló la compilación de {game_exe} (código de salida {code}). Detalles: {log}",
|
||||
"compile.exe_in_use": "{path} está en uso. Cierra el juego y vuelve a ejecutar el instalador.",
|
||||
"kit.in_use": "{path} está en uso. Cierra el juego y cualquier ventana de instalación o recompilación abierta, y vuelve a ejecutar el instalador.",
|
||||
"kit.copy_failed": "No se puede copiar el kit de compilación en {path}: {detail}",
|
||||
"compile.exe_locked": "No se puede escribir {path}: otro programa lo retiene, un juego iniciado desde esa carpeta o un antivirus que marcó el archivo. Cierra el juego, añade la carpeta del instalador y la carpeta de instalación a las exclusiones del antivirus, reinicia Windows y vuelve a ejecutar el instalador. Detalles: {log}",
|
||||
"prepare.xlate_in_use": "{path} está en uso. Cierra el juego, termina cualquier proceso totk_xlate que haya quedado de una ejecución anterior y vuelve a ejecutar el instalador.",
|
||||
"prepare.shader_list_missing": "Falta la lista de shaders.",
|
||||
"prepare.romfs_patches_failed": "Falló la escritura de los parches de datos del juego (código de salida {code}). Detalles: {log}",
|
||||
"prepare.shaders_failed": "Falló la preparación de los shaders (código de salida {code}). Detalles: {log}",
|
||||
"cleanup.romfs_unreadable": "Los datos del juego en {path} faltan o no se pueden leer tras la instalación. Reinicia Windows y vuelve a ejecutar el instalador en la misma carpeta: extrae de nuevo los datos del juego y conserva el resto.",
|
||||
"prepare.pack_failed": "Falló el empaquetado de la caché de shaders (código de salida {code}). Detalles: {log}",
|
||||
"cleanup.ini_failed": "No se puede escribir totk.ini: {detail}",
|
||||
"warn.lang_needs_fonts": "El texto en {lang} necesita las fuentes del sistema de Switch y no se indicó ninguna. El juego no se iniciará en este idioma hasta que se añadan. Elige la carpeta del firmware (Contents/registered) o consulta «Switch system fonts» en docs/installer.md.",
|
||||
"warn.npdm_differs": "main.npdm difiere del volcado de referencia {version}; solo se usan los módulos de código.",
|
||||
"warn.cheats_skipped": "No se pudieron crear los trucos de la carpeta mods que cambian el código del juego; el juego se instala sin ellos. Detalles: {log}",
|
||||
"warn.exefs_skipped": "No se pudieron crear los parches ExeFS de los mods (.ips, .pchtxt); el juego se instala sin ellos. Detalles: {log}",
|
||||
"warn.plugins_skipped": "No se pudieron compilar los plugins de código de los mods (exefs subsdk); el juego se instala sin ellos. Detalles: {log}",
|
||||
"warn.xbox_prompts_failed": "No se pudieron preparar los iconos de botones de Xbox, PlayStation o PC (código de salida {code}); el juego mantiene los iconos de Switch. Detalles: {log}",
|
||||
"warn.shaders_skipped": "El controlador gráfico falló al crear algunos shaders, así que {count} quedaron fuera de la preparación. El juego los crea cuando los necesita por primera vez, y el controlador también puede fallar ahí; una actualización del controlador puede solucionarlo. Detalles: {log}",
|
||||
"warn.kernel_old": "Linux {version} no tiene el seguimiento de escrituras del que depende el juego (6.7 o posterior); el juego puede ir muy lento. Actualizar el sistema lo soluciona.",
|
||||
"warn.dlss_kept": "Ya hay una biblioteca DLSS en la carpeta de instalación ({path}); el instalador la conserva.",
|
||||
"warn.dlss_download_failed": "No se pudo descargar NVIDIA DLSS desde {url}: {detail}. El juego funciona sin él; la próxima ejecución del instalador lo intentará de nuevo.",
|
||||
"ui.title": "Instalador de TotK",
|
||||
"ui.rebuild_title": "Reconstruyendo el juego para tus mods",
|
||||
"ui.start_game": "Iniciar el juego",
|
||||
"ui.version": "versión {version}",
|
||||
"ui.intro": "Crea una carpeta jugable de Tears of the Kingdom a partir de tus propios archivos del juego. Tarda un rato y se ejecuta una sola vez.",
|
||||
"ui.notice": "La carpeta que crea este instalador contiene el juego. Es solo para tu uso personal; no la compartas ni la subas.",
|
||||
"ui.keys_private": "El archivo de claves se lee en su sitio. Su contenido nunca se muestra, copia ni guarda.",
|
||||
"ui.base": "Juego base",
|
||||
"ui.update": "Actualización",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Firmware (opcional)",
|
||||
"ui.game_language": "Idioma del juego",
|
||||
"ui.dest": "Carpeta de instalación",
|
||||
"ui.browse": "Examinar...",
|
||||
"ui.pick_game": "Elige el archivo del juego base",
|
||||
"ui.pick_update": "Elige el archivo de la actualización 1.1.0, 1.2.1 o 1.4.3",
|
||||
"ui.pick_keys": "Elige prod.keys",
|
||||
"ui.pick_firmware": "Elige la carpeta del firmware de Switch (Contents/registered)",
|
||||
"ui.pick_dest": "Elige la carpeta de instalación",
|
||||
"ui.firmware_help": "Para texto en chino, coreano y chino tradicional: la carpeta Contents/registered del firmware, por ejemplo de Ryujinx o Yuzu. El instalador copia de ella las fuentes del sistema de Switch a la carpeta de instalación.",
|
||||
"ui.dlss": "Descargar NVIDIA DLSS (nvngx_dlss.dll) para tarjetas gráficas NVIDIA RTX",
|
||||
"ui.dlss_help": "Del DLSS SDK de NVIDIA en GitHub, bajo la licencia RTX SDK de NVIDIA (github.com/NVIDIA/DLSS). Hace que funcionen los ajustes dlaa y DLSS; sin él no hacen nada.",
|
||||
"ui.compressed_help": "Los archivos comprimidos NSZ y XCZ funcionan tal cual: el instalador los descomprime por sí mismo (hasta que se extraen los datos del juego, necesita tanto espacio libre como ocupan los archivos descomprimidos).",
|
||||
"ui.section_files": "Archivos del juego",
|
||||
"ui.section_install": "Instalación",
|
||||
"ui.more_details": "▸ Más detalles",
|
||||
"ui.fewer_details": "▾ Ocultar detalles",
|
||||
"ui.formats_help": "Juego base: NSP, XCI, NSZ o XCZ. Actualización: 1.1.0, 1.2.1 o 1.4.3, en NSP o NSZ.",
|
||||
"ui.type_game": "Archivos de juego (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Archivos de claves (*.keys)",
|
||||
"ui.type_all": "Todos los archivos",
|
||||
"ui.start": "Iniciar",
|
||||
"ui.cancel": "Cancelar",
|
||||
"ui.cancelling": "Cancelando...",
|
||||
"ui.show_log": "Mostrar registro",
|
||||
"ui.hide_log": "Ocultar registro",
|
||||
"ui.close": "Cerrar",
|
||||
"ui.back": "Atrás",
|
||||
"ui.open_folder": "Abrir carpeta",
|
||||
"ui.update_mode": "Esta carpeta contiene una instalación anterior. El instalador la continúa o la actualiza; los archivos del juego solo se piden si vuelven a ser necesarios.",
|
||||
"ui.need_dest": "Elige la carpeta de instalación.",
|
||||
"ui.need_base": "Elige el archivo del juego base.",
|
||||
"ui.need_update": "Elige el archivo de la actualización 1.1.0, 1.2.1 o 1.4.3.",
|
||||
"ui.need_keys": "Elige el archivo prod.keys.",
|
||||
"ui.need_lang": "Elige el idioma del juego.",
|
||||
"ui.missing_base": "El archivo del juego base no existe.",
|
||||
"ui.missing_update": "El archivo de actualización no existe.",
|
||||
"ui.missing_keys": "El archivo de claves no existe.",
|
||||
"ui.missing_firmware": "La carpeta del firmware no existe.",
|
||||
"ui.running_install": "Instalando",
|
||||
"ui.running_resume": "Continuando la instalación anterior",
|
||||
"ui.running_update": "Actualizando la instalación",
|
||||
"ui.state_started": "iniciado",
|
||||
"ui.state_done": "hecho",
|
||||
"ui.state_skipped": "omitido",
|
||||
"ui.state_pending": "en espera",
|
||||
"ui.state_running": "en curso",
|
||||
"ui.state_failed": "fallido",
|
||||
"ui.log_warning": "Advertencia",
|
||||
"ui.log_error": "Error",
|
||||
"ui.log_space": "Espacio necesario: {need} GB, libre: {free} GB",
|
||||
"ui.log_end": "Terminado",
|
||||
"ui.result_ok": "El juego está listo",
|
||||
"ui.result_failed": "La instalación falló",
|
||||
"ui.result_cancelled": "La instalación se canceló",
|
||||
"ui.done_text": "Inicia {game_exe} desde {dest}. El instalador y los archivos del juego que elegiste ya no son necesarios.",
|
||||
"ui.cancelled_text": "Los pasos terminados se conservan. Vuelve a iniciar el instalador con la misma carpeta para continuar.",
|
||||
"ui.log_file": "Archivo de registro: {path}",
|
||||
"ui.process_died": "El instalador se detuvo inesperadamente (código de salida {code}).",
|
||||
"ui.confirm_cancel": "El instalador está en marcha. ¿Cancelarlo y cerrar la ventana?",
|
||||
"ui.space_one": "Espacio libre necesario en {path}: {need} GB (libre: {free} GB).",
|
||||
"ui.space_two": "Espacio libre necesario en {path}: {need} GB (libre: {free} GB); en {temp}: {temp_need} GB (libre: {temp_free} GB).",
|
||||
"ui.amount_bytes": "{done} / {total} GB",
|
||||
"ui.amount_chunks": "{done} / {total} partes",
|
||||
"ui.amount_objects": "{done} / {total} archivos",
|
||||
"ui.amount_shaders": "{done} / {total} shaders",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n} s",
|
||||
"param.input.base": "juego base",
|
||||
"param.input.update": "actualización",
|
||||
"param.input.keys": "claves",
|
||||
"launcher.title": "Instalador de TotK",
|
||||
"launcher.python_missing": "Los archivos del instalador están incompletos: falta la carpeta python junto a TotK-Setup.exe. Descomprime de nuevo todo el archivo e inicia TotK-Setup.exe desde la carpeta descomprimida.",
|
||||
"lang.ja": "Japonés",
|
||||
"lang.en-US": "Inglés (EE. UU.)",
|
||||
"lang.en-GB": "Inglés (Reino Unido)",
|
||||
"lang.fr": "Francés",
|
||||
"lang.fr-CA": "Francés (Canadá)",
|
||||
"lang.de": "Alemán",
|
||||
"lang.it": "Italiano",
|
||||
"lang.es": "Español",
|
||||
"lang.es-419": "Español (Latinoamérica)",
|
||||
"lang.nl": "Neerlandés",
|
||||
"lang.pt": "Portugués",
|
||||
"lang.pt-BR": "Portugués (Brasil)",
|
||||
"lang.ru": "Ruso",
|
||||
"lang.ko": "Coreano",
|
||||
"lang.zh-Hans": "Chino (simplificado)",
|
||||
"lang.zh-Hant": "Chino (tradicional)"
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "Vérification de l'ordinateur et des fichiers du jeu",
|
||||
"step.kit": "Copie du kit de compilation dans le dossier du jeu",
|
||||
"step.fonts": "Extraction des polices système",
|
||||
"step.extract": "Extraction du jeu",
|
||||
"step.lift": "Traduction du code du jeu en C",
|
||||
"step.compile": "Compilation de {game_exe}",
|
||||
"step.prepare": "Préparation des shaders",
|
||||
"step.pc_prompts": "Dessin des icônes du clavier et de la souris",
|
||||
"step.shapes": "Mise en page des écrans du jeu pour vos moniteurs",
|
||||
"step.dlss": "Téléchargement de NVIDIA DLSS",
|
||||
"step.cleanup": "Nettoyage",
|
||||
"phase.check.host": "Vérification du processeur et de la carte graphique",
|
||||
"phase.check.verify": "Vérification des fichiers déjà installés",
|
||||
"phase.check.verify_romfs": "Vérification des données du jeu installées",
|
||||
"phase.check.inputs": "Ouverture des fichiers du jeu avec les clés",
|
||||
"phase.check.unpack_base": "Décompression du jeu de base compressé",
|
||||
"phase.check.unpack_update": "Décompression de la mise à jour compressée",
|
||||
"phase.check.versions": "Vérification des versions du jeu",
|
||||
"phase.kit.copy": "Copie des outils avec lesquels le jeu se recompile pour les mods de code",
|
||||
"phase.fonts.extract": "Extraction des polices partagées depuis le firmware",
|
||||
"phase.fonts.copy": "Copie des polices partagées dans le dossier d'installation",
|
||||
"phase.extract.hash_base": "Calcul de la somme de contrôle du jeu de base",
|
||||
"phase.extract.hash_update": "Calcul de la somme de contrôle de la mise à jour",
|
||||
"phase.extract.exefs": "Extraction du code du jeu",
|
||||
"phase.extract.copy": "Copie des données du jeu",
|
||||
"phase.extract.merge": "Application de la mise à jour aux données du jeu",
|
||||
"phase.extract.diagnose": "Recherche du fichier du jeu endommagé",
|
||||
"phase.extract.index": "Vérification des données du jeu",
|
||||
"phase.lift.discover": "Recherche des fonctions",
|
||||
"phase.lift.emit": "Écriture du code C",
|
||||
"phase.compile.compile": "Compilation",
|
||||
"phase.compile.link": "Édition des liens de {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Écriture des correctifs de données pour 60 fps",
|
||||
"phase.pc_prompts.draw": "Dessin des icônes des touches du clavier et de la souris d’après les affectations de totk.ini",
|
||||
"phase.prepare.seed": "Lecture des shaders dans les données du jeu",
|
||||
"phase.prepare.translate": "Traduction des shaders",
|
||||
"phase.prepare.libraries": "Construction des shaders pour le pilote graphique",
|
||||
"phase.prepare.pack": "Regroupement du cache de shaders en un fichier",
|
||||
"phase.shapes.layouts": "Écriture des mises en page et des icônes de boutons pour chaque format d’écran",
|
||||
"phase.dlss.download": "Téléchargement de nvngx_dlss.dll depuis le DLSS SDK de NVIDIA",
|
||||
"phase.cleanup.ini": "Écriture de totk.ini",
|
||||
"phase.cleanup.temp": "Suppression des fichiers temporaires",
|
||||
"cli.usage": "Ligne de commande invalide : {detail}",
|
||||
"internal": "Erreur inattendue ({exception}) : {detail}",
|
||||
"state.unreadable": "{path} est illisible. Choisissez un autre dossier ou supprimez ce fichier.",
|
||||
"state.newer_format": "{path} a été écrit par un installateur plus récent. Utilisez cet installateur ou un autre dossier.",
|
||||
"state.output_changed": "Les fichiers installés de l'étape « {step} » ont changé depuis leur création ; cette étape est relancée.",
|
||||
"check.release_incomplete": "Le dossier de l'installateur est incomplet ; il manque : {paths}. Décompressez à nouveau la version.",
|
||||
"check.dest_not_folder": "L'emplacement d'installation {path} est un fichier, pas un dossier.",
|
||||
"check.dest_not_empty": "Le dossier d'installation {path} n'est pas vide et ne contient aucune installation antérieure. Choisissez un dossier vide.",
|
||||
"check.lang_missing": "Choisissez la langue du jeu.",
|
||||
"check.lang_unknown": "Langue inconnue « {lang} ». Langues connues : {known}.",
|
||||
"check.toolchain_broken": "Le compilateur fourni ne fonctionne pas : {detail}",
|
||||
"check.glibc_old": "La bibliothèque C de ce système est glibc {version} ; le compilateur de l'installation demande {need} ou plus récent (Ubuntu 22.04, Debian 12, Fedora 35, SteamOS 3 et plus récents l'ont). Mettre à jour le système corrige cela.",
|
||||
"check.host_probe_failed": "La vérification de l'ordinateur ne s'est pas exécutée (code de sortie {code}).",
|
||||
"check.cpu_too_old": "Ce processeur ne prend pas en charge x86-64-v2 (SSE4.2, POPCNT et CMPXCHG16B), le niveau le plus ancien pour lequel le jeu est compilé. Intel Nehalem (2008) ou AMD Bulldozer (2011) et plus récents l'ont.",
|
||||
"check.vulkan_missing": "Aucun pilote Vulkan n'est installé. Installez le dernier pilote de votre carte graphique.",
|
||||
"check.vulkan_no_device": "Vulkan ne trouve aucune carte graphique. Installez le dernier pilote de votre carte graphique.",
|
||||
"check.vulkan_too_old": "Le jeu demande une carte graphique avec Vulkan 1.3 ; trouvé : {devices}. Mettez à jour le pilote graphique.",
|
||||
"check.no_display": "La préparation des shaders a besoin d'un écran. Lancez l'installation depuis la session de bureau, ou exportez DISPLAY=:0 (sur un Steam Deck en mode Jeu, aussi XDG_RUNTIME_DIR=/run/user/1000).",
|
||||
"check.inputs_needed": "Les fichiers du jeu sont nécessaires : choisissez le jeu de base, la mise à jour 1.1.0, 1.2.1 ou 1.4.3 et prod.keys.",
|
||||
"check.input_missing": "Fichier introuvable ({input}) : {path}",
|
||||
"check.keys_unreadable": "Le fichier de clés est illisible. Choisissez un fichier prod.keys.",
|
||||
"check.keys_no_header_key": "Le fichier de clés ne contient pas de header_key. Extrayez à nouveau prod.keys de votre console.",
|
||||
"check.keys_wrong": "Les clés ne peuvent pas ouvrir le fichier ({input}). Utilisez le prod.keys de votre console.",
|
||||
"check.keys_too_old": "Le fichier de clés est trop ancien pour le fichier ({input}) (génération de clés {generation} requise). Extrayez prod.keys d'une console avec un firmware plus récent.",
|
||||
"check.not_game_file": "Le fichier ({input}) n'est pas un fichier de jeu XCI, NSP, XCZ ou NSZ.",
|
||||
"check.file_unreadable": "Le fichier ({input}) est illisible : {detail}",
|
||||
"check.unpack_failed": "Le fichier compressé {input} n'a pas pu être décompressé : {detail}",
|
||||
"check.ticket_personalized": "Le fichier ({input}) contient un ticket personnalisé ; un ticket commun est nécessaire.",
|
||||
"check.ticket_missing": "Il manque au fichier ({input}) le ticket dont son contenu a besoin.",
|
||||
"check.base_not_totk": "Le fichier du jeu de base n'est pas The Legend of Zelda: Tears of the Kingdom ({detail}).",
|
||||
"check.base_is_update": "Le fichier du jeu de base est une mise à jour. Choisissez ici le jeu de base en NSP ou XCI (version 1.0.0) et ce fichier comme mise à jour.",
|
||||
"check.base_combined": "Le fichier du jeu de base contient plusieurs paquets (jeu de base, mise à jour ou DLC dans un seul fichier). Choisissez un dump du jeu de base qui ne contient que le jeu.",
|
||||
"check.update_not_nsp": "La mise à jour doit être un fichier NSP ou NSZ.",
|
||||
"check.update_is_base": "Le fichier de mise à jour contient un jeu de base. Choisissez le NSP de la mise à jour 1.1.0, 1.2.1 ou 1.4.3.",
|
||||
"check.update_not_totk": "Le fichier de mise à jour n'est pas une mise à jour de Tears of the Kingdom ({detail}).",
|
||||
"check.exefs_failed": "Le code du jeu du fichier ({input}) n'a pas passé les vérifications ; voir {log}.",
|
||||
"check.input_damaged": "Le fichier ({input}) est endommagé ou incomplet : {path} ({detail}). Copiez à nouveau ce fichier depuis sa source ou refaites le dump, puis relancez l'installation.",
|
||||
"check.base_wrong_version": "Le jeu de base n'est pas en version 1.0.0 ({modules} diffèrent).",
|
||||
"check.update_wrong_version": "La mise à jour est en version {found} ; cette version prend {wanted}.",
|
||||
"check.disk_space": "Espace libre insuffisant pour {path} : {need_gb} Go nécessaires, {free_gb} Go libres.",
|
||||
"check.firmware_missing": "Le dossier du firmware {path} n'existe pas. Choisissez le dossier Contents/registered du firmware.",
|
||||
"check.firmware_empty": "Le dossier du firmware {path} ne contient aucun fichier NCA. Choisissez le dossier Contents/registered du firmware.",
|
||||
"check.fonts_keys_needed": "Les polices partagées de cette langue ne sont pas encore installées ; choisissez prod.keys pour que l'installation puisse les extraire du firmware.",
|
||||
"extract.exefs_mismatch": "Le code du jeu extrait ne correspond pas à la version {version} ({modules}).",
|
||||
"extract.romfs_merge_failed": "L'application de la mise à jour aux données du jeu a échoué : {detail}. Détails : {log}",
|
||||
"extract.romfs_mismatch": "Les données du jeu extraites ne correspondent pas à la version {version} (taille {size}, somme de contrôle {sha256}...).",
|
||||
"fonts.failed": "L'extraction des polices partagées a échoué (code de sortie {code}) : {detail}. Détails : {log}",
|
||||
"fonts.incomplete": "L'extraction des polices partagées n'a pas écrit tous les fichiers ({files}).",
|
||||
"fonts.copy_failed": "Les polices partagées ne peuvent pas être copiées dans {path} : {detail}",
|
||||
"lift.failed": "La traduction du code du jeu a échoué (code de sortie {code}). Détails : {log}",
|
||||
"compile.failed": "La compilation de {game_exe} a échoué (code de sortie {code}). Détails : {log}",
|
||||
"compile.exe_in_use": "{path} est en cours d'utilisation. Fermez le jeu et relancez l'installateur.",
|
||||
"kit.in_use": "{path} est en cours d’utilisation. Fermez le jeu et toute fenêtre d’installation ou de recompilation ouverte, puis relancez l’installation.",
|
||||
"kit.copy_failed": "Impossible de copier le kit de compilation dans {path} : {detail}",
|
||||
"compile.exe_locked": "Impossible d’écrire {path} : un autre programme le retient, un jeu lancé depuis ce dossier ou un antivirus qui a signalé le fichier. Fermez le jeu, ajoutez le dossier du programme d’installation et le dossier d’installation aux exclusions de l’antivirus, redémarrez Windows, puis relancez l’installation. Détails : {log}",
|
||||
"prepare.xlate_in_use": "{path} est en cours d'utilisation. Fermez le jeu, terminez tout processus totk_xlate restant d'une exécution précédente, puis relancez l'installateur.",
|
||||
"prepare.shader_list_missing": "La liste des shaders est manquante.",
|
||||
"prepare.romfs_patches_failed": "L'écriture des correctifs de données du jeu a échoué (code de sortie {code}). Détails : {log}",
|
||||
"prepare.shaders_failed": "La préparation des shaders a échoué (code de sortie {code}). Détails : {log}",
|
||||
"cleanup.romfs_unreadable": "Les données du jeu dans {path} sont manquantes ou illisibles après l'installation. Redémarrez Windows, puis relancez l'installateur sur le même dossier : il extrait à nouveau les données du jeu et conserve le reste.",
|
||||
"prepare.pack_failed": "Le regroupement du cache de shaders a échoué (code de sortie {code}). Détails : {log}",
|
||||
"cleanup.ini_failed": "totk.ini ne peut pas être écrit : {detail}",
|
||||
"warn.lang_needs_fonts": "Le texte en {lang} nécessite les polices système de la Switch, et aucune n'a été fournie. Le jeu ne démarrera pas dans cette langue tant qu'elles ne sont pas ajoutées. Choisissez le dossier du firmware (Contents/registered), ou consultez « Switch system fonts » dans docs/installer.md.",
|
||||
"warn.npdm_differs": "main.npdm diffère du dump de référence {version} ; seuls les modules de code sont utilisés.",
|
||||
"warn.cheats_skipped": "Les codes de triche du dossier mods qui modifient le code du jeu n'ont pas pu être construits ; le jeu s'installe sans eux. Détails : {log}",
|
||||
"warn.exefs_skipped": "Les correctifs ExeFS des mods (.ips, .pchtxt) n'ont pas pu être construits ; le jeu s'installe sans eux. Détails : {log}",
|
||||
"warn.plugins_skipped": "Les plugins de code des mods (exefs subsdk) n’ont pas pu être compilés ; le jeu s’installe sans eux. Détails : {log}",
|
||||
"warn.xbox_prompts_failed": "Les icônes de boutons Xbox, PlayStation ou PC n'ont pas pu être préparées (code de sortie {code}) ; le jeu garde les icônes Switch. Détails : {log}",
|
||||
"warn.shaders_skipped": "Le pilote graphique a planté pendant la construction de certains shaders ; {count} ont donc été exclus de la préparation. Le jeu les construit quand il en a besoin pour la première fois, et le pilote peut y planter aussi ; une mise à jour du pilote peut corriger cela. Détails : {log}",
|
||||
"warn.kernel_old": "Linux {version} ne dispose pas du suivi des écritures dont le jeu dépend (6.7 ou plus récent) ; le jeu peut être très lent. Mettre à jour le système corrige cela.",
|
||||
"warn.dlss_kept": "Une bibliothèque DLSS se trouve déjà dans le dossier d'installation ({path}) ; l'installation la conserve.",
|
||||
"warn.dlss_download_failed": "NVIDIA DLSS n'a pas pu être téléchargé depuis {url} : {detail}. Le jeu fonctionne sans ; la prochaine installation réessaiera.",
|
||||
"ui.title": "Installation de TotK",
|
||||
"ui.rebuild_title": "Reconstruction du jeu pour vos mods",
|
||||
"ui.start_game": "Lancer le jeu",
|
||||
"ui.version": "version {version}",
|
||||
"ui.intro": "Construit un dossier jouable de Tears of the Kingdom à partir de vos propres fichiers du jeu. Cela prend du temps et ne s'exécute qu'une fois.",
|
||||
"ui.notice": "Le dossier construit par cette installation contient le jeu. Il est réservé à votre usage personnel ; ne le partagez pas et ne le mettez pas en ligne.",
|
||||
"ui.keys_private": "Le fichier de clés est lu sur place. Son contenu n'est jamais affiché, copié ni conservé.",
|
||||
"ui.base": "Jeu de base",
|
||||
"ui.update": "Mise à jour",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Firmware (facultatif)",
|
||||
"ui.game_language": "Langue du jeu",
|
||||
"ui.dest": "Dossier d'installation",
|
||||
"ui.browse": "Parcourir...",
|
||||
"ui.pick_game": "Choisissez le fichier du jeu de base",
|
||||
"ui.pick_update": "Choisissez le fichier de la mise à jour 1.1.0, 1.2.1 ou 1.4.3",
|
||||
"ui.pick_keys": "Choisissez prod.keys",
|
||||
"ui.pick_firmware": "Choisissez le dossier du firmware Switch (Contents/registered)",
|
||||
"ui.pick_dest": "Choisissez le dossier d'installation",
|
||||
"ui.firmware_help": "Pour le texte en chinois, en coréen et en chinois traditionnel : le dossier Contents/registered du firmware, par exemple celui de Ryujinx ou de Yuzu. L'installation en copie les polices système de la Switch dans le dossier d'installation.",
|
||||
"ui.dlss": "Télécharger NVIDIA DLSS (nvngx_dlss.dll) pour les cartes graphiques NVIDIA RTX",
|
||||
"ui.dlss_help": "Depuis le DLSS SDK de NVIDIA sur GitHub, sous la licence RTX SDK de NVIDIA (github.com/NVIDIA/DLSS). Il fait fonctionner les réglages dlaa et DLSS ; sans lui, ils n'ont aucun effet.",
|
||||
"ui.compressed_help": "Les fichiers compressés NSZ et XCZ fonctionnent tels quels : l'installation les décompresse elle-même (jusqu'à l'extraction des données du jeu, il faut autant d'espace libre que les fichiers décompressés).",
|
||||
"ui.section_files": "Fichiers du jeu",
|
||||
"ui.section_install": "Installation",
|
||||
"ui.more_details": "▸ Plus de détails",
|
||||
"ui.fewer_details": "▾ Masquer les détails",
|
||||
"ui.formats_help": "Jeu de base : NSP, XCI, NSZ ou XCZ. Mise à jour : 1.1.0, 1.2.1 ou 1.4.3, en NSP ou NSZ.",
|
||||
"ui.type_game": "Fichiers de jeu (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Fichiers de clés (*.keys)",
|
||||
"ui.type_all": "Tous les fichiers",
|
||||
"ui.start": "Démarrer",
|
||||
"ui.cancel": "Annuler",
|
||||
"ui.cancelling": "Annulation...",
|
||||
"ui.show_log": "Afficher le journal",
|
||||
"ui.hide_log": "Masquer le journal",
|
||||
"ui.close": "Fermer",
|
||||
"ui.back": "Retour",
|
||||
"ui.open_folder": "Ouvrir le dossier",
|
||||
"ui.update_mode": "Ce dossier contient une installation antérieure. L'installation la poursuit ou la met à jour ; les fichiers du jeu ne sont demandés que s'ils sont de nouveau nécessaires.",
|
||||
"ui.need_dest": "Choisissez le dossier d'installation.",
|
||||
"ui.need_base": "Choisissez le fichier du jeu de base.",
|
||||
"ui.need_update": "Choisissez le fichier de la mise à jour 1.1.0, 1.2.1 ou 1.4.3.",
|
||||
"ui.need_keys": "Choisissez le fichier prod.keys.",
|
||||
"ui.need_lang": "Choisissez la langue du jeu.",
|
||||
"ui.missing_base": "Le fichier du jeu de base n'existe pas.",
|
||||
"ui.missing_update": "Le fichier de mise à jour n'existe pas.",
|
||||
"ui.missing_keys": "Le fichier de clés n'existe pas.",
|
||||
"ui.missing_firmware": "Le dossier du firmware n'existe pas.",
|
||||
"ui.running_install": "Installation",
|
||||
"ui.running_resume": "Reprise de l'installation précédente",
|
||||
"ui.running_update": "Mise à jour de l'installation",
|
||||
"ui.state_started": "démarré",
|
||||
"ui.state_done": "terminé",
|
||||
"ui.state_skipped": "ignoré",
|
||||
"ui.state_pending": "en attente",
|
||||
"ui.state_running": "en cours",
|
||||
"ui.state_failed": "échec",
|
||||
"ui.log_warning": "Avertissement",
|
||||
"ui.log_error": "Erreur",
|
||||
"ui.log_space": "Espace nécessaire : {need} Go, libre : {free} Go",
|
||||
"ui.log_end": "Terminé",
|
||||
"ui.result_ok": "Le jeu est prêt",
|
||||
"ui.result_failed": "L'installation a échoué",
|
||||
"ui.result_cancelled": "L'installation a été annulée",
|
||||
"ui.done_text": "Lancez {game_exe} depuis {dest}. Le programme d'installation et les fichiers du jeu choisis ne sont plus nécessaires.",
|
||||
"ui.cancelled_text": "Les étapes terminées sont conservées. Relancez l'installation avec le même dossier pour continuer.",
|
||||
"ui.log_file": "Fichier journal : {path}",
|
||||
"ui.process_died": "L'installation s'est arrêtée de façon inattendue (code de sortie {code}).",
|
||||
"ui.confirm_cancel": "L'installation est en cours. L'annuler et fermer la fenêtre ?",
|
||||
"ui.space_one": "Espace libre nécessaire sur {path} : {need} Go (libre : {free} Go).",
|
||||
"ui.space_two": "Espace libre nécessaire sur {path} : {need} Go (libre : {free} Go) ; sur {temp} : {temp_need} Go (libre : {temp_free} Go).",
|
||||
"ui.amount_bytes": "{done} / {total} Go",
|
||||
"ui.amount_chunks": "{done} / {total} parties",
|
||||
"ui.amount_objects": "{done} / {total} fichiers",
|
||||
"ui.amount_shaders": "{done} / {total} shaders",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n} s",
|
||||
"param.input.base": "jeu de base",
|
||||
"param.input.update": "mise à jour",
|
||||
"param.input.keys": "clés",
|
||||
"launcher.title": "Installation de TotK",
|
||||
"launcher.python_missing": "Les fichiers d'installation sont incomplets : le dossier python à côté de TotK-Setup.exe est manquant. Décompressez à nouveau toute l'archive et lancez TotK-Setup.exe depuis le dossier décompressé.",
|
||||
"lang.ja": "Japonais",
|
||||
"lang.en-US": "Anglais (États-Unis)",
|
||||
"lang.en-GB": "Anglais (Royaume-Uni)",
|
||||
"lang.fr": "Français",
|
||||
"lang.fr-CA": "Français (Canada)",
|
||||
"lang.de": "Allemand",
|
||||
"lang.it": "Italien",
|
||||
"lang.es": "Espagnol",
|
||||
"lang.es-419": "Espagnol (Amérique latine)",
|
||||
"lang.nl": "Néerlandais",
|
||||
"lang.pt": "Portugais",
|
||||
"lang.pt-BR": "Portugais (Brésil)",
|
||||
"lang.ru": "Russe",
|
||||
"lang.ko": "Coréen",
|
||||
"lang.zh-Hans": "Chinois (simplifié)",
|
||||
"lang.zh-Hant": "Chinois (traditionnel)"
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "Controllo del computer e dei file del gioco",
|
||||
"step.kit": "Copia del kit di compilazione nella cartella del gioco",
|
||||
"step.fonts": "Estrazione dei font di sistema",
|
||||
"step.extract": "Estrazione del gioco",
|
||||
"step.lift": "Traduzione del codice del gioco in C",
|
||||
"step.compile": "Compilazione di {game_exe}",
|
||||
"step.prepare": "Preparazione degli shader",
|
||||
"step.pc_prompts": "Disegno delle icone di tastiera e mouse",
|
||||
"step.shapes": "Impaginazione delle schermate del gioco per i tuoi monitor",
|
||||
"step.dlss": "Download di NVIDIA DLSS",
|
||||
"step.cleanup": "Pulizia",
|
||||
"phase.check.host": "Controllo del processore e della scheda grafica",
|
||||
"phase.check.verify": "Controllo dei file già installati",
|
||||
"phase.check.verify_romfs": "Controllo dei dati di gioco installati",
|
||||
"phase.check.inputs": "Apertura dei file del gioco con le chiavi",
|
||||
"phase.check.unpack_base": "Decompressione del gioco base compresso",
|
||||
"phase.check.unpack_update": "Decompressione dell'aggiornamento compresso",
|
||||
"phase.check.versions": "Controllo delle versioni del gioco",
|
||||
"phase.kit.copy": "Copia degli strumenti con cui il gioco si ricompila per le mod di codice",
|
||||
"phase.fonts.extract": "Estrazione dei font condivisi dal firmware",
|
||||
"phase.fonts.copy": "Copia dei font condivisi nella cartella di installazione",
|
||||
"phase.extract.hash_base": "Calcolo del checksum del gioco base",
|
||||
"phase.extract.hash_update": "Calcolo del checksum dell'aggiornamento",
|
||||
"phase.extract.exefs": "Estrazione del codice del gioco",
|
||||
"phase.extract.copy": "Copia dei dati di gioco",
|
||||
"phase.extract.merge": "Applicazione dell'aggiornamento ai dati di gioco",
|
||||
"phase.extract.diagnose": "Ricerca del file di gioco danneggiato",
|
||||
"phase.extract.index": "Verifica dei dati di gioco",
|
||||
"phase.lift.discover": "Ricerca delle funzioni",
|
||||
"phase.lift.emit": "Scrittura del codice C",
|
||||
"phase.compile.compile": "Compilazione",
|
||||
"phase.compile.link": "Collegamento di {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Scrittura delle patch dei dati per i 60 fps",
|
||||
"phase.pc_prompts.draw": "Disegno delle icone dei tasti e dei pulsanti del mouse dalle assegnazioni di totk.ini",
|
||||
"phase.prepare.seed": "Lettura degli shader dai dati di gioco",
|
||||
"phase.prepare.translate": "Traduzione degli shader",
|
||||
"phase.prepare.libraries": "Creazione degli shader per il driver grafico",
|
||||
"phase.prepare.pack": "Raccolta della cache degli shader in un file",
|
||||
"phase.shapes.layouts": "Scrittura dei layout dello schermo e delle icone dei pulsanti per ogni formato di schermo",
|
||||
"phase.dlss.download": "Download di nvngx_dlss.dll dal DLSS SDK di NVIDIA",
|
||||
"phase.cleanup.ini": "Scrittura di totk.ini",
|
||||
"phase.cleanup.temp": "Rimozione dei file temporanei",
|
||||
"cli.usage": "Riga di comando non valida: {detail}",
|
||||
"internal": "Errore imprevisto ({exception}): {detail}",
|
||||
"state.unreadable": "Impossibile leggere {path}. Scegli un'altra cartella o elimina quel file.",
|
||||
"state.newer_format": "{path} è stato scritto da un programma di installazione più recente. Usa quel programma o un'altra cartella.",
|
||||
"state.output_changed": "I file installati del passaggio '{step}' sono cambiati da quando sono stati creati; quel passaggio viene ripetuto.",
|
||||
"check.release_incomplete": "La cartella del programma di installazione è incompleta; manca: {paths}. Estrai di nuovo la release.",
|
||||
"check.dest_not_folder": "Il percorso di installazione {path} è un file, non una cartella.",
|
||||
"check.dest_not_empty": "La cartella di installazione {path} non è vuota e non contiene un'installazione precedente. Scegli una cartella vuota.",
|
||||
"check.lang_missing": "Scegli la lingua del gioco.",
|
||||
"check.lang_unknown": "Lingua sconosciuta '{lang}'. Lingue note: {known}.",
|
||||
"check.toolchain_broken": "Il compilatore incluso non funziona: {detail}",
|
||||
"check.glibc_old": "La libreria C di questo sistema è glibc {version}; il compilatore dell'installazione richiede {need} o successiva (Ubuntu 22.04, Debian 12, Fedora 35, SteamOS 3 e successivi la hanno). Aggiornare il sistema risolve il problema.",
|
||||
"check.host_probe_failed": "Il controllo del computer non è stato eseguito (codice di uscita {code}).",
|
||||
"check.cpu_too_old": "Questo processore non supporta x86-64-v2 (SSE4.2, POPCNT e CMPXCHG16B), il livello più vecchio per cui il gioco viene compilato. Intel Nehalem (2008) o AMD Bulldozer (2011) e successivi lo supportano.",
|
||||
"check.vulkan_missing": "Non è installato alcun driver Vulkan. Installa il driver più recente della tua scheda grafica.",
|
||||
"check.vulkan_no_device": "Vulkan non trova alcuna scheda grafica. Installa il driver più recente della tua scheda grafica.",
|
||||
"check.vulkan_too_old": "Il gioco richiede una scheda grafica con Vulkan 1.3; trovato: {devices}. Aggiorna il driver grafico.",
|
||||
"check.no_display": "La preparazione degli shader richiede uno schermo. Avvia l'installazione dalla sessione desktop oppure esporta DISPLAY=:0 (su uno Steam Deck in modalità Gioco anche XDG_RUNTIME_DIR=/run/user/1000).",
|
||||
"check.inputs_needed": "Servono i file del gioco: scegli il gioco base, l'aggiornamento 1.1.0, 1.2.1 o 1.4.3 e prod.keys.",
|
||||
"check.input_missing": "File non trovato ({input}): {path}",
|
||||
"check.keys_unreadable": "Impossibile leggere il file delle chiavi. Scegli un file prod.keys.",
|
||||
"check.keys_no_header_key": "Il file delle chiavi non contiene header_key. Estrai di nuovo prod.keys dalla tua console.",
|
||||
"check.keys_wrong": "Le chiavi non riescono ad aprire il file ({input}). Usa il prod.keys della tua console.",
|
||||
"check.keys_too_old": "Il file delle chiavi è troppo vecchio per il file ({input}) (richiede la generazione di chiavi {generation}). Estrai prod.keys da una console con un firmware più recente.",
|
||||
"check.not_game_file": "Il file ({input}) non è un file di gioco XCI, NSP, XCZ o NSZ.",
|
||||
"check.file_unreadable": "Impossibile leggere il file ({input}): {detail}",
|
||||
"check.unpack_failed": "Impossibile decomprimere il file compresso {input}: {detail}",
|
||||
"check.ticket_personalized": "Il file ({input}) contiene un ticket personalizzato; serve un ticket comune.",
|
||||
"check.ticket_missing": "Al file ({input}) manca il ticket richiesto dal suo contenuto.",
|
||||
"check.base_not_totk": "Il file del gioco base non è The Legend of Zelda: Tears of the Kingdom ({detail}).",
|
||||
"check.base_is_update": "Il file del gioco base è un aggiornamento. Scegli qui il gioco base in NSP o XCI (versione 1.0.0) e questo file come aggiornamento.",
|
||||
"check.base_combined": "Il file del gioco base contiene più pacchetti (gioco base, aggiornamento o DLC in un unico file). Scegli un dump del gioco base che contenga solo il gioco.",
|
||||
"check.update_not_nsp": "L'aggiornamento deve essere un file NSP o NSZ.",
|
||||
"check.update_is_base": "Il file dell'aggiornamento contiene un gioco base. Scegli l'NSP dell'aggiornamento 1.1.0, 1.2.1 o 1.4.3.",
|
||||
"check.update_not_totk": "Il file dell'aggiornamento non è un aggiornamento di Tears of the Kingdom ({detail}).",
|
||||
"check.exefs_failed": "Il codice del gioco del file ({input}) non ha superato i controlli; vedi {log}.",
|
||||
"check.input_damaged": "Il file ({input}) è danneggiato o incompleto: {path} ({detail}). Copia di nuovo quel file dalla sua origine o rifai il dump, poi esegui di nuovo l'installazione.",
|
||||
"check.base_wrong_version": "Il gioco base non è la versione 1.0.0 ({modules} diversi).",
|
||||
"check.update_wrong_version": "L'aggiornamento è la versione {found}; questa release usa {wanted}.",
|
||||
"check.disk_space": "Spazio libero insufficiente per {path}: servono {need_gb} GB, liberi {free_gb} GB.",
|
||||
"check.firmware_missing": "La cartella del firmware {path} non esiste. Scegli la cartella Contents/registered del firmware.",
|
||||
"check.firmware_empty": "La cartella del firmware {path} non contiene file NCA. Scegli la cartella Contents/registered del firmware.",
|
||||
"check.fonts_keys_needed": "I font condivisi per questa lingua non sono ancora installati; scegli prod.keys perché l'installazione possa estrarli dal firmware.",
|
||||
"extract.exefs_mismatch": "Il codice del gioco estratto non corrisponde alla versione {version} ({modules}).",
|
||||
"extract.romfs_merge_failed": "L'applicazione dell'aggiornamento ai dati di gioco non è riuscita: {detail}. Dettagli: {log}",
|
||||
"extract.romfs_mismatch": "I dati di gioco estratti non corrispondono alla versione {version} (dimensione {size}, checksum {sha256}...).",
|
||||
"fonts.failed": "L'estrazione dei font condivisi non è riuscita (codice di uscita {code}): {detail}. Dettagli: {log}",
|
||||
"fonts.incomplete": "L'estrazione dei font condivisi non ha scritto tutti i file ({files}).",
|
||||
"fonts.copy_failed": "Impossibile copiare i font condivisi in {path}: {detail}",
|
||||
"lift.failed": "La traduzione del codice del gioco non è riuscita (codice di uscita {code}). Dettagli: {log}",
|
||||
"compile.failed": "La compilazione di {game_exe} non è riuscita (codice di uscita {code}). Dettagli: {log}",
|
||||
"compile.exe_in_use": "{path} è in uso. Chiudi il gioco ed esegui di nuovo il programma di installazione.",
|
||||
"kit.in_use": "{path} è in uso. Chiudi il gioco e ogni finestra di installazione o ricompilazione aperta, poi esegui di nuovo l'installazione.",
|
||||
"kit.copy_failed": "Impossibile copiare il kit di compilazione in {path}: {detail}",
|
||||
"compile.exe_locked": "Impossibile scrivere {path}: un altro programma lo tiene aperto, un gioco avviato da quella cartella o un antivirus che ha segnalato il file. Chiudi il gioco, aggiungi la cartella del programma di installazione e la cartella di installazione alle esclusioni dell'antivirus, riavvia Windows, poi esegui di nuovo l'installazione. Dettagli: {log}",
|
||||
"prepare.xlate_in_use": "{path} è in uso. Chiudi il gioco, termina ogni processo totk_xlate rimasto da un'esecuzione precedente, poi esegui di nuovo il programma di installazione.",
|
||||
"prepare.shader_list_missing": "Manca l'elenco degli shader.",
|
||||
"prepare.romfs_patches_failed": "La scrittura delle patch dei dati di gioco non è riuscita (codice di uscita {code}). Dettagli: {log}",
|
||||
"prepare.shaders_failed": "La preparazione degli shader non è riuscita (codice di uscita {code}). Dettagli: {log}",
|
||||
"cleanup.romfs_unreadable": "I dati di gioco in {path} mancano o non sono leggibili dopo l'installazione. Riavvia Windows, poi esegui di nuovo il programma di installazione sulla stessa cartella: estrae di nuovo i dati di gioco e mantiene il resto.",
|
||||
"prepare.pack_failed": "La raccolta della cache degli shader non è riuscita (codice di uscita {code}). Dettagli: {log}",
|
||||
"cleanup.ini_failed": "Impossibile scrivere totk.ini: {detail}",
|
||||
"warn.lang_needs_fonts": "Il testo in {lang} richiede i font di sistema di Switch e non ne è stato indicato nessuno. Il gioco non si avvierà in questa lingua finché non verranno aggiunti. Scegli la cartella del firmware (Contents/registered) o consulta \"Switch system fonts\" in docs/installer.md.",
|
||||
"warn.npdm_differs": "main.npdm è diverso dal dump di riferimento {version}; vengono usati solo i moduli di codice.",
|
||||
"warn.cheats_skipped": "Non è stato possibile creare i trucchi della cartella mods che modificano il codice del gioco; il gioco viene installato senza di essi. Dettagli: {log}",
|
||||
"warn.exefs_skipped": "Non è stato possibile creare le patch ExeFS delle mod (.ips, .pchtxt); il gioco viene installato senza di esse. Dettagli: {log}",
|
||||
"warn.plugins_skipped": "Non è stato possibile compilare i plugin di codice delle mod (exefs subsdk); il gioco si installa senza di essi. Dettagli: {log}",
|
||||
"warn.xbox_prompts_failed": "Non è stato possibile preparare le icone dei pulsanti Xbox, PlayStation o PC (codice di uscita {code}); il gioco mantiene le icone di Switch. Dettagli: {log}",
|
||||
"warn.shaders_skipped": "Il driver grafico si è bloccato durante la creazione di alcuni shader, quindi {count} sono stati esclusi dalla preparazione. Il gioco li crea quando servono per la prima volta, e anche lì il driver potrebbe bloccarsi; un aggiornamento del driver potrebbe risolvere. Dettagli: {log}",
|
||||
"warn.kernel_old": "Linux {version} non ha il tracciamento delle scritture su cui si basa il gioco (6.7 o successivo); il gioco potrebbe essere molto lento. Aggiornare il sistema risolve il problema.",
|
||||
"warn.dlss_kept": "Nella cartella di installazione c'è già una libreria DLSS ({path}); l'installazione la mantiene.",
|
||||
"warn.dlss_download_failed": "Impossibile scaricare NVIDIA DLSS da {url}: {detail}. Il gioco funziona senza; la prossima esecuzione dell'installazione riproverà.",
|
||||
"ui.title": "Installazione di TotK",
|
||||
"ui.rebuild_title": "Ricostruzione del gioco per le tue mod",
|
||||
"ui.start_game": "Avvia il gioco",
|
||||
"ui.version": "versione {version}",
|
||||
"ui.intro": "Crea una cartella giocabile di Tears of the Kingdom dai tuoi file del gioco. Richiede un po' di tempo e si esegue una sola volta.",
|
||||
"ui.notice": "La cartella creata da questa installazione contiene il gioco. È solo per uso personale; non condividerla né caricarla online.",
|
||||
"ui.keys_private": "Il file delle chiavi viene letto sul posto. Il suo contenuto non viene mai mostrato, copiato o salvato.",
|
||||
"ui.base": "Gioco base",
|
||||
"ui.update": "Aggiornamento",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Firmware (facoltativo)",
|
||||
"ui.game_language": "Lingua del gioco",
|
||||
"ui.dest": "Cartella di installazione",
|
||||
"ui.browse": "Sfoglia...",
|
||||
"ui.pick_game": "Scegli il file del gioco base",
|
||||
"ui.pick_update": "Scegli il file dell'aggiornamento 1.1.0, 1.2.1 o 1.4.3",
|
||||
"ui.pick_keys": "Scegli prod.keys",
|
||||
"ui.pick_firmware": "Scegli la cartella del firmware di Switch (Contents/registered)",
|
||||
"ui.pick_dest": "Scegli la cartella di installazione",
|
||||
"ui.firmware_help": "Per il testo in cinese, coreano e cinese tradizionale: la cartella Contents/registered del firmware, ad esempio da Ryujinx o Yuzu. L'installazione ne copia i font di sistema di Switch nella cartella di installazione.",
|
||||
"ui.dlss": "Scarica NVIDIA DLSS (nvngx_dlss.dll) per le schede grafiche NVIDIA RTX",
|
||||
"ui.dlss_help": "Dal DLSS SDK di NVIDIA su GitHub, con la licenza RTX SDK di NVIDIA (github.com/NVIDIA/DLSS). Fa funzionare le impostazioni dlaa e DLSS; senza, non hanno effetto.",
|
||||
"ui.compressed_help": "I file compressi NSZ e XCZ funzionano così come sono: l'installazione li decomprime da sé (finché i dati del gioco non sono estratti, serve tanto spazio libero quanto occupano i file decompressi).",
|
||||
"ui.section_files": "File del gioco",
|
||||
"ui.section_install": "Installazione",
|
||||
"ui.more_details": "▸ Altri dettagli",
|
||||
"ui.fewer_details": "▾ Nascondi dettagli",
|
||||
"ui.formats_help": "Gioco base: NSP, XCI, NSZ o XCZ. Aggiornamento: 1.1.0, 1.2.1 o 1.4.3, in NSP o NSZ.",
|
||||
"ui.type_game": "File di gioco (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "File di chiavi (*.keys)",
|
||||
"ui.type_all": "Tutti i file",
|
||||
"ui.start": "Avvia",
|
||||
"ui.cancel": "Annulla",
|
||||
"ui.cancelling": "Annullamento...",
|
||||
"ui.show_log": "Mostra registro",
|
||||
"ui.hide_log": "Nascondi registro",
|
||||
"ui.close": "Chiudi",
|
||||
"ui.back": "Indietro",
|
||||
"ui.open_folder": "Apri cartella",
|
||||
"ui.update_mode": "Questa cartella contiene un'installazione precedente. L'installazione la prosegue o la aggiorna; i file del gioco vengono chiesti solo se servono di nuovo.",
|
||||
"ui.need_dest": "Scegli la cartella di installazione.",
|
||||
"ui.need_base": "Scegli il file del gioco base.",
|
||||
"ui.need_update": "Scegli il file dell'aggiornamento 1.1.0, 1.2.1 o 1.4.3.",
|
||||
"ui.need_keys": "Scegli il file prod.keys.",
|
||||
"ui.need_lang": "Scegli la lingua del gioco.",
|
||||
"ui.missing_base": "Il file del gioco base non esiste.",
|
||||
"ui.missing_update": "Il file dell'aggiornamento non esiste.",
|
||||
"ui.missing_keys": "Il file delle chiavi non esiste.",
|
||||
"ui.missing_firmware": "La cartella del firmware non esiste.",
|
||||
"ui.running_install": "Installazione",
|
||||
"ui.running_resume": "Ripresa dell'installazione precedente",
|
||||
"ui.running_update": "Aggiornamento dell'installazione",
|
||||
"ui.state_started": "avviato",
|
||||
"ui.state_done": "fatto",
|
||||
"ui.state_skipped": "saltato",
|
||||
"ui.state_pending": "in attesa",
|
||||
"ui.state_running": "in corso",
|
||||
"ui.state_failed": "non riuscito",
|
||||
"ui.log_warning": "Avviso",
|
||||
"ui.log_error": "Errore",
|
||||
"ui.log_space": "Spazio necessario: {need} GB, libero: {free} GB",
|
||||
"ui.log_end": "Terminato",
|
||||
"ui.result_ok": "Il gioco è pronto",
|
||||
"ui.result_failed": "L'installazione non è riuscita",
|
||||
"ui.result_cancelled": "L'installazione è stata annullata",
|
||||
"ui.done_text": "Avvia {game_exe} da {dest}. Il programma di installazione e i file del gioco scelti non servono più.",
|
||||
"ui.cancelled_text": "I passaggi completati vengono mantenuti. Avvia di nuovo l'installazione con la stessa cartella per continuare.",
|
||||
"ui.log_file": "File di registro: {path}",
|
||||
"ui.process_died": "L'installazione si è interrotta inaspettatamente (codice di uscita {code}).",
|
||||
"ui.confirm_cancel": "L'installazione è in corso. Annullarla e chiudere la finestra?",
|
||||
"ui.space_one": "Spazio libero necessario su {path}: {need} GB (libero: {free} GB).",
|
||||
"ui.space_two": "Spazio libero necessario su {path}: {need} GB (libero: {free} GB); su {temp}: {temp_need} GB (libero: {temp_free} GB).",
|
||||
"ui.amount_bytes": "{done} / {total} GB",
|
||||
"ui.amount_chunks": "{done} / {total} parti",
|
||||
"ui.amount_objects": "{done} / {total} file",
|
||||
"ui.amount_shaders": "{done} / {total} shader",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n} s",
|
||||
"param.input.base": "gioco base",
|
||||
"param.input.update": "aggiornamento",
|
||||
"param.input.keys": "chiavi",
|
||||
"launcher.title": "Installazione di TotK",
|
||||
"launcher.python_missing": "I file di installazione sono incompleti: manca la cartella python accanto a TotK-Setup.exe. Estrai di nuovo l'intero archivio e avvia TotK-Setup.exe dalla cartella estratta.",
|
||||
"lang.ja": "Giapponese",
|
||||
"lang.en-US": "Inglese (USA)",
|
||||
"lang.en-GB": "Inglese (Regno Unito)",
|
||||
"lang.fr": "Francese",
|
||||
"lang.fr-CA": "Francese (Canada)",
|
||||
"lang.de": "Tedesco",
|
||||
"lang.it": "Italiano",
|
||||
"lang.es": "Spagnolo",
|
||||
"lang.es-419": "Spagnolo (America Latina)",
|
||||
"lang.nl": "Olandese",
|
||||
"lang.pt": "Portoghese",
|
||||
"lang.pt-BR": "Portoghese (Brasile)",
|
||||
"lang.ru": "Russo",
|
||||
"lang.ko": "Coreano",
|
||||
"lang.zh-Hans": "Cinese (semplificato)",
|
||||
"lang.zh-Hant": "Cinese (tradizionale)"
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "コンピューターとゲームファイルの確認",
|
||||
"step.kit": "ビルドキットをゲームフォルダーにコピー",
|
||||
"step.fonts": "システムフォントの抽出",
|
||||
"step.extract": "ゲームの展開",
|
||||
"step.lift": "ゲームコードの C への変換",
|
||||
"step.compile": "{game_exe} のコンパイル",
|
||||
"step.prepare": "シェーダーの準備",
|
||||
"step.pc_prompts": "キーボードとマウスのボタン表示の作成",
|
||||
"step.shapes": "ディスプレイに合わせたゲーム画面のレイアウト",
|
||||
"step.dlss": "NVIDIA DLSS のダウンロード",
|
||||
"step.cleanup": "後片付け",
|
||||
"phase.check.host": "プロセッサーとグラフィックカードを確認しています",
|
||||
"phase.check.verify": "インストール済みのファイルを確認しています",
|
||||
"phase.check.verify_romfs": "インストール済みのゲームデータを確認しています",
|
||||
"phase.check.inputs": "キーでゲームファイルを開いています",
|
||||
"phase.check.unpack_base": "圧縮されたベースゲームを展開しています",
|
||||
"phase.check.unpack_update": "圧縮されたアップデートを展開しています",
|
||||
"phase.check.versions": "ゲームのバージョンを確認しています",
|
||||
"phase.kit.copy": "コード MOD 用にゲームが自身を再ビルドするためのツールをコピーしています",
|
||||
"phase.fonts.extract": "ファームウェアから共有フォントを抽出しています",
|
||||
"phase.fonts.copy": "共有フォントをインストール先フォルダーにコピーしています",
|
||||
"phase.extract.hash_base": "本編のチェックサムを計算しています",
|
||||
"phase.extract.hash_update": "アップデートのチェックサムを計算しています",
|
||||
"phase.extract.exefs": "ゲームコードを抽出しています",
|
||||
"phase.extract.copy": "ゲームデータをコピーしています",
|
||||
"phase.extract.merge": "ゲームデータにアップデートを適用しています",
|
||||
"phase.extract.diagnose": "破損したゲームファイルを探しています",
|
||||
"phase.extract.index": "ゲームデータを検証しています",
|
||||
"phase.lift.discover": "関数を探しています",
|
||||
"phase.lift.emit": "C コードを書き出しています",
|
||||
"phase.compile.compile": "コンパイルしています",
|
||||
"phase.compile.link": "{game_exe} をリンクしています",
|
||||
"phase.prepare.romfs_patches": "60 fps 用のゲームデータパッチを書き出しています",
|
||||
"phase.pc_prompts.draw": "totk.ini の割り当てからキーとマウスボタンの表示を作成しています",
|
||||
"phase.prepare.seed": "ゲームデータからシェーダーを読み込んでいます",
|
||||
"phase.prepare.translate": "シェーダーを変換しています",
|
||||
"phase.prepare.libraries": "グラフィックドライバー用にシェーダーをビルドしています",
|
||||
"phase.prepare.pack": "シェーダーキャッシュを 1 つのファイルにまとめています",
|
||||
"phase.shapes.layouts": "画面の形ごとに画面レイアウトとボタン表示を書き込んでいます",
|
||||
"phase.dlss.download": "NVIDIA の DLSS SDK から nvngx_dlss.dll をダウンロードしています",
|
||||
"phase.cleanup.ini": "totk.ini を書き込んでいます",
|
||||
"phase.cleanup.temp": "一時ファイルを削除しています",
|
||||
"cli.usage": "コマンドラインが無効です: {detail}",
|
||||
"internal": "予期しないエラー ({exception}): {detail}",
|
||||
"state.unreadable": "{path} を読み取れません。別のフォルダーを選ぶか、そのファイルを削除してください。",
|
||||
"state.newer_format": "{path} は新しいバージョンのインストーラーで書き込まれています。そのインストーラーか別のフォルダーを使ってください。",
|
||||
"state.output_changed": "手順「{step}」でインストールしたファイルが作成後に変更されています。その手順をもう一度実行します。",
|
||||
"check.release_incomplete": "インストーラーのフォルダーが不完全です。不足: {paths}。リリースをもう一度展開してください。",
|
||||
"check.dest_not_folder": "インストール先 {path} はフォルダーではなくファイルです。",
|
||||
"check.dest_not_empty": "インストール先フォルダー {path} は空ではなく、以前のインストールも含まれていません。空のフォルダーを選んでください。",
|
||||
"check.lang_missing": "ゲームの言語を選んでください。",
|
||||
"check.lang_unknown": "不明な言語「{lang}」です。使用できる言語: {known}。",
|
||||
"check.toolchain_broken": "同梱のコンパイラーが動作しません: {detail}",
|
||||
"check.glibc_old": "このシステムの C ライブラリは glibc {version} です。セットアップのコンパイラーには {need} 以降が必要です (Ubuntu 22.04、Debian 12、Fedora 35、SteamOS 3 以降にあります)。システムを更新すると解決します。",
|
||||
"check.host_probe_failed": "コンピューターの確認を実行できませんでした (終了コード {code})。",
|
||||
"check.cpu_too_old": "このプロセッサーは、ゲームのビルド対象となる最も古いレベルである x86-64-v2 (SSE4.2、POPCNT、CMPXCHG16B) に対応していません。Intel Nehalem (2008 年) または AMD Bulldozer (2011 年) 以降が対応しています。",
|
||||
"check.vulkan_missing": "Vulkan ドライバーがインストールされていません。グラフィックカードの最新ドライバーをインストールしてください。",
|
||||
"check.vulkan_no_device": "Vulkan がグラフィックカードを見つけられません。グラフィックカードの最新ドライバーをインストールしてください。",
|
||||
"check.vulkan_too_old": "このゲームには Vulkan 1.3 対応のグラフィックカードが必要です。見つかったもの: {devices}。グラフィックドライバーを更新してください。",
|
||||
"check.no_display": "シェーダーの準備にはディスプレイが必要です。デスクトップのセッションからセットアップを実行するか、DISPLAY=:0 を export してください(Steam Deck のゲームモードでは XDG_RUNTIME_DIR=/run/user/1000 も)。",
|
||||
"check.inputs_needed": "ゲームファイルが必要です。本編、1.1.0・1.2.1・1.4.3 のいずれかのアップデート、prod.keys を選んでください。",
|
||||
"check.input_missing": "ファイルが見つかりません ({input}): {path}",
|
||||
"check.keys_unreadable": "キーファイルを読み取れません。prod.keys ファイルを選んでください。",
|
||||
"check.keys_no_header_key": "キーファイルに header_key がありません。本体から prod.keys をもう一度吸い出してください。",
|
||||
"check.keys_wrong": "このキーでは{input}のファイルを開けません。ご自分の本体の prod.keys を使ってください。",
|
||||
"check.keys_too_old": "キーファイルが{input}のファイルには古すぎます (キー世代 {generation} が必要)。より新しいファームウェアの本体から prod.keys を吸い出してください。",
|
||||
"check.not_game_file": "{input}のファイルは XCI、NSP、XCZ、NSZ のいずれのゲームファイルでもありません。",
|
||||
"check.file_unreadable": "{input}のファイルを読み取れません: {detail}",
|
||||
"check.unpack_failed": "圧縮ファイル {input} を展開できませんでした: {detail}",
|
||||
"check.ticket_personalized": "{input}のファイルには個人用チケットが含まれています。共通チケットが必要です。",
|
||||
"check.ticket_missing": "{input}のファイルには、内容に必要なチケットがありません。",
|
||||
"check.base_not_totk": "本編のファイルは ゼルダの伝説 ティアーズ オブ ザ キングダム ではありません ({detail})。",
|
||||
"check.base_is_update": "本編のファイルはアップデートです。ここには本編の NSP または XCI (バージョン 1.0.0) を選び、このファイルはアップデートとして選んでください。",
|
||||
"check.base_combined": "本編のファイルに複数のパッケージ (本編、アップデート、DLC が 1 つのファイル) が含まれています。ゲームだけを含む本編のダンプを選んでください。",
|
||||
"check.update_not_nsp": "アップデートは NSP または NSZ ファイルである必要があります。",
|
||||
"check.update_is_base": "アップデートのファイルに本編が含まれています。1.1.0・1.2.1・1.4.3 のいずれかのアップデートの NSP を選んでください。",
|
||||
"check.update_not_totk": "アップデートのファイルは ティアーズ オブ ザ キングダム のアップデートではありません ({detail})。",
|
||||
"check.exefs_failed": "{input}のファイルのゲームコードが検査に合格しませんでした。{log} を参照してください。",
|
||||
"check.input_damaged": "{input}のファイルが破損しているか不完全です: {path} ({detail})。そのファイルを元の場所からもう一度コピーするか、もう一度吸い出してから、セットアップを再実行してください。",
|
||||
"check.base_wrong_version": "本編がバージョン 1.0.0 ではありません ({modules} が異なります)。",
|
||||
"check.update_wrong_version": "アップデートのバージョンは {found} です。このリリースは {wanted} に対応しています。",
|
||||
"check.disk_space": "{path} の空き容量が足りません: {need_gb} GB 必要、空き {free_gb} GB。",
|
||||
"check.firmware_missing": "ファームウェアフォルダー {path} が存在しません。ファームウェアの Contents/registered フォルダーを選んでください。",
|
||||
"check.firmware_empty": "ファームウェアフォルダー {path} に NCA ファイルがありません。ファームウェアの Contents/registered フォルダーを選んでください。",
|
||||
"check.fonts_keys_needed": "この言語用の共有フォントがまだインストールされていません。セットアップがファームウェアから抽出できるよう、prod.keys を選んでください。",
|
||||
"extract.exefs_mismatch": "抽出したゲームコードがバージョン {version} と一致しません ({modules})。",
|
||||
"extract.romfs_merge_failed": "ゲームデータへのアップデートの適用に失敗しました: {detail}。詳細: {log}",
|
||||
"extract.romfs_mismatch": "抽出したゲームデータがバージョン {version} と一致しません (サイズ {size}、チェックサム {sha256}...)。",
|
||||
"fonts.failed": "共有フォントの抽出に失敗しました (終了コード {code}): {detail}。詳細: {log}",
|
||||
"fonts.incomplete": "共有フォントの抽出で一部のファイルが書き込まれませんでした ({files})。",
|
||||
"fonts.copy_failed": "共有フォントを {path} にコピーできません: {detail}",
|
||||
"lift.failed": "ゲームコードの変換に失敗しました (終了コード {code})。詳細: {log}",
|
||||
"compile.failed": "{game_exe} のコンパイルに失敗しました (終了コード {code})。詳細: {log}",
|
||||
"compile.exe_in_use": "{path} は使用中です。ゲームを閉じてから、インストーラーをもう一度実行してください。",
|
||||
"kit.in_use": "{path} は使用中です。ゲームと、開いているセットアップや再ビルドのウィンドウをすべて閉じてから、セットアップをもう一度実行してください。",
|
||||
"kit.copy_failed": "ビルドキットを {path} にコピーできません: {detail}",
|
||||
"compile.exe_locked": "{path} に書き込めません。別のプログラムがファイルを使用しています (そのフォルダーから起動したゲーム、またはファイルを検出したウイルス対策ソフト)。ゲームを閉じ、セットアップのフォルダーとインストール先フォルダーをウイルス対策ソフトの除外に追加し、Windows を再起動してから、セットアップをもう一度実行してください。詳細: {log}",
|
||||
"prepare.xlate_in_use": "{path} は使用中です。ゲームを閉じ、以前の実行で残った totk_xlate プロセスを終了してから、インストーラーをもう一度実行してください。",
|
||||
"prepare.shader_list_missing": "シェーダーの一覧がありません。",
|
||||
"prepare.romfs_patches_failed": "ゲームデータパッチの書き出しに失敗しました (終了コード {code})。詳細: {log}",
|
||||
"prepare.shaders_failed": "シェーダーの準備に失敗しました (終了コード {code})。詳細: {log}",
|
||||
"cleanup.romfs_unreadable": "インストール後、{path} のゲームデータが見つからないか読み取れません。Windows を再起動し、同じフォルダーでインストーラーをもう一度実行してください。ゲームデータだけを再展開し、それ以外は保持します。",
|
||||
"prepare.pack_failed": "シェーダーキャッシュのまとめに失敗しました (終了コード {code})。詳細: {log}",
|
||||
"cleanup.ini_failed": "totk.ini を書き込めません: {detail}",
|
||||
"warn.lang_needs_fonts": "{lang}のテキストには Switch のシステムフォントが必要ですが、指定されていません。追加されるまで、この言語ではゲームが起動しません。ファームウェアフォルダー (Contents/registered) を選ぶか、docs/installer.md の「Switch system fonts」を参照してください。",
|
||||
"warn.npdm_differs": "main.npdm が参照用の {version} ダンプと異なります。コードモジュールのみを使用します。",
|
||||
"warn.cheats_skipped": "mods フォルダーにあるゲームコードを変更するチートをビルドできませんでした。チートなしでゲームをインストールします。詳細: {log}",
|
||||
"warn.exefs_skipped": "Mod の ExeFS パッチ (.ips、.pchtxt) をビルドできませんでした。パッチなしでゲームをインストールします。詳細: {log}",
|
||||
"warn.plugins_skipped": "MOD のコードプラグイン (exefs subsdk) をビルドできませんでした。ゲームはそれらなしでインストールされます。詳細: {log}",
|
||||
"warn.xbox_prompts_failed": "Xbox、PlayStation、PC のボタン表示を準備できませんでした (終了コード {code})。ゲームは Switch のボタン表示のままです。詳細: {log}",
|
||||
"warn.shaders_skipped": "一部のシェーダーのビルド中にグラフィックドライバーがクラッシュしたため、{count} 個を準備から除外しました。ゲームは初めて必要になったときにそれらをビルドしますが、そこでもドライバーがクラッシュする可能性があります。ドライバーを更新すると解決することがあります。詳細: {log}",
|
||||
"warn.kernel_old": "Linux {version} には、ゲームが必要とする書き込み追跡 (6.7 以降) がありません。ゲームが非常に遅くなることがあります。システムを更新すると解決します。",
|
||||
"warn.dlss_kept": "インストール先フォルダーには既に DLSS ライブラリがあります ({path})。セットアップはそれを残します。",
|
||||
"warn.dlss_download_failed": "NVIDIA DLSS を {url} からダウンロードできませんでした: {detail}。ゲームはなしで動作します。次回のセットアップ実行時に再試行します。",
|
||||
"ui.title": "TotK セットアップ",
|
||||
"ui.rebuild_title": "Mod に合わせてゲームを再ビルドしています",
|
||||
"ui.start_game": "ゲームを開始",
|
||||
"ui.version": "バージョン {version}",
|
||||
"ui.intro": "お持ちのゲームファイルから、プレイ可能な ティアーズ オブ ザ キングダム のフォルダーを作成します。時間がかかりますが、実行は一度だけです。",
|
||||
"ui.notice": "このセットアップが作成するフォルダーにはゲームが含まれます。個人での使用に限り、共有やアップロードはしないでください。",
|
||||
"ui.keys_private": "キーファイルはその場で読み取られます。内容が表示、コピー、保存されることはありません。",
|
||||
"ui.base": "本編",
|
||||
"ui.update": "アップデート",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "ファームウェア (任意)",
|
||||
"ui.game_language": "ゲームの言語",
|
||||
"ui.dest": "インストール先フォルダー",
|
||||
"ui.browse": "参照...",
|
||||
"ui.pick_game": "本編のファイルを選択",
|
||||
"ui.pick_update": "1.1.0・1.2.1・1.4.3 のアップデートファイルを選択",
|
||||
"ui.pick_keys": "prod.keys を選択",
|
||||
"ui.pick_firmware": "Switch のファームウェアフォルダー (Contents/registered) を選択",
|
||||
"ui.pick_dest": "インストール先フォルダーを選択",
|
||||
"ui.firmware_help": "中国語、韓国語、繁体字中国語のテキスト用: ファームウェアの Contents/registered フォルダー (例: Ryujinx や Yuzu のもの)。セットアップはそこから Switch のシステムフォントをインストール先フォルダーにコピーします。",
|
||||
"ui.dlss": "NVIDIA RTX グラフィックカード用に NVIDIA DLSS (nvngx_dlss.dll) をダウンロードする",
|
||||
"ui.dlss_help": "GitHub 上の NVIDIA の DLSS SDK から、NVIDIA の RTX SDK ライセンスのもとで取得します (github.com/NVIDIA/DLSS)。これで dlaa と DLSS の設定が機能します。ない場合、これらの設定は効果がありません。",
|
||||
"ui.compressed_help": "圧縮された NSZ / XCZ ファイルはそのまま使えます。セットアップが自分で展開します(ゲームデータの展開が終わるまで、展開後のファイルと同じだけの空き容量が必要です)。",
|
||||
"ui.section_files": "ゲームファイル",
|
||||
"ui.section_install": "インストール",
|
||||
"ui.more_details": "▸ 詳細を表示",
|
||||
"ui.fewer_details": "▾ 詳細を隠す",
|
||||
"ui.formats_help": "本編: NSP、XCI、NSZ または XCZ。アップデート: 1.1.0、1.2.1 または 1.4.3 (NSP または NSZ)。",
|
||||
"ui.type_game": "ゲームファイル (NSP、XCI、NSZ、XCZ)",
|
||||
"ui.type_keys": "キーファイル (*.keys)",
|
||||
"ui.type_all": "すべてのファイル",
|
||||
"ui.start": "開始",
|
||||
"ui.cancel": "キャンセル",
|
||||
"ui.cancelling": "キャンセルしています...",
|
||||
"ui.show_log": "ログを表示",
|
||||
"ui.hide_log": "ログを隠す",
|
||||
"ui.close": "閉じる",
|
||||
"ui.back": "戻る",
|
||||
"ui.open_folder": "フォルダーを開く",
|
||||
"ui.update_mode": "このフォルダーには以前のインストールがあります。セットアップはそれを続行または更新します。ゲームファイルは再度必要な場合にのみ求められます。",
|
||||
"ui.need_dest": "インストール先フォルダーを選んでください。",
|
||||
"ui.need_base": "本編のファイルを選んでください。",
|
||||
"ui.need_update": "1.1.0・1.2.1・1.4.3 のアップデートファイルを選んでください。",
|
||||
"ui.need_keys": "prod.keys ファイルを選んでください。",
|
||||
"ui.need_lang": "ゲームの言語を選んでください。",
|
||||
"ui.missing_base": "本編のファイルが存在しません。",
|
||||
"ui.missing_update": "アップデートのファイルが存在しません。",
|
||||
"ui.missing_keys": "キーファイルが存在しません。",
|
||||
"ui.missing_firmware": "ファームウェアフォルダーが存在しません。",
|
||||
"ui.running_install": "インストール中",
|
||||
"ui.running_resume": "以前のセットアップを続行中",
|
||||
"ui.running_update": "インストールを更新中",
|
||||
"ui.state_started": "開始",
|
||||
"ui.state_done": "完了",
|
||||
"ui.state_skipped": "スキップ",
|
||||
"ui.state_pending": "待機中",
|
||||
"ui.state_running": "実行中",
|
||||
"ui.state_failed": "失敗",
|
||||
"ui.log_warning": "警告",
|
||||
"ui.log_error": "エラー",
|
||||
"ui.log_space": "必要な容量: {need} GB、空き: {free} GB",
|
||||
"ui.log_end": "終了",
|
||||
"ui.result_ok": "ゲームの準備ができました",
|
||||
"ui.result_failed": "セットアップに失敗しました",
|
||||
"ui.result_cancelled": "セットアップはキャンセルされました",
|
||||
"ui.done_text": "{dest} から {game_exe} を起動してください。セットアップと選んだゲームファイルはもう必要ありません。",
|
||||
"ui.cancelled_text": "完了した手順は保持されます。続けるには、同じフォルダーでセットアップをもう一度開始してください。",
|
||||
"ui.log_file": "ログファイル: {path}",
|
||||
"ui.process_died": "セットアップが予期せず停止しました (終了コード {code})。",
|
||||
"ui.confirm_cancel": "セットアップを実行中です。キャンセルしてウィンドウを閉じますか?",
|
||||
"ui.space_one": "{path} に必要な空き容量: {need} GB (空き: {free} GB)。",
|
||||
"ui.space_two": "{path} に必要な空き容量: {need} GB (空き: {free} GB)、{temp}: {temp_need} GB (空き: {temp_free} GB)。",
|
||||
"ui.amount_bytes": "{done} / {total} GB",
|
||||
"ui.amount_chunks": "{done} / {total} パート",
|
||||
"ui.amount_objects": "{done} / {total} ファイル",
|
||||
"ui.amount_shaders": "{done} / {total} シェーダー",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n} 秒",
|
||||
"param.input.base": "本編",
|
||||
"param.input.update": "アップデート",
|
||||
"param.input.keys": "キー",
|
||||
"launcher.title": "TotK セットアップ",
|
||||
"launcher.python_missing": "セットアップのファイルが不完全です。TotK-Setup.exe の隣にある python フォルダーがありません。アーカイブ全体をもう一度展開し、展開したフォルダーから TotK-Setup.exe を起動してください。",
|
||||
"lang.ja": "日本語",
|
||||
"lang.en-US": "英語 (米国)",
|
||||
"lang.en-GB": "英語 (英国)",
|
||||
"lang.fr": "フランス語",
|
||||
"lang.fr-CA": "フランス語 (カナダ)",
|
||||
"lang.de": "ドイツ語",
|
||||
"lang.it": "イタリア語",
|
||||
"lang.es": "スペイン語",
|
||||
"lang.es-419": "スペイン語 (中南米)",
|
||||
"lang.nl": "オランダ語",
|
||||
"lang.pt": "ポルトガル語",
|
||||
"lang.pt-BR": "ポルトガル語 (ブラジル)",
|
||||
"lang.ru": "ロシア語",
|
||||
"lang.ko": "韓国語",
|
||||
"lang.zh-Hans": "中国語 (簡体字)",
|
||||
"lang.zh-Hant": "中国語 (繁体字)"
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "컴퓨터와 게임 파일 확인",
|
||||
"step.kit": "빌드 키트를 게임 폴더로 복사",
|
||||
"step.fonts": "시스템 글꼴 추출",
|
||||
"step.extract": "게임 추출",
|
||||
"step.lift": "게임 코드를 C로 변환",
|
||||
"step.compile": "{game_exe} 컴파일",
|
||||
"step.prepare": "셰이더 준비",
|
||||
"step.pc_prompts": "키보드 및 마우스 버튼 표시 그리기",
|
||||
"step.shapes": "모니터에 맞게 게임 화면 배치",
|
||||
"step.dlss": "NVIDIA DLSS 다운로드",
|
||||
"step.cleanup": "정리",
|
||||
"phase.check.host": "프로세서와 그래픽 카드를 확인하는 중",
|
||||
"phase.check.verify": "이미 설치된 파일을 확인하는 중",
|
||||
"phase.check.verify_romfs": "설치된 게임 데이터를 확인하는 중",
|
||||
"phase.check.inputs": "키로 게임 파일을 여는 중",
|
||||
"phase.check.unpack_base": "압축된 기본 게임의 압축을 푸는 중",
|
||||
"phase.check.unpack_update": "압축된 업데이트의 압축을 푸는 중",
|
||||
"phase.check.versions": "게임 버전을 확인하는 중",
|
||||
"phase.kit.copy": "코드 모드용으로 게임이 스스로 다시 빌드할 때 쓰는 도구 복사 중",
|
||||
"phase.fonts.extract": "펌웨어에서 공유 글꼴을 추출하는 중",
|
||||
"phase.fonts.copy": "공유 글꼴을 설치 폴더로 복사하는 중",
|
||||
"phase.extract.hash_base": "기본 게임의 체크섬을 계산하는 중",
|
||||
"phase.extract.hash_update": "업데이트의 체크섬을 계산하는 중",
|
||||
"phase.extract.exefs": "게임 코드를 추출하는 중",
|
||||
"phase.extract.copy": "게임 데이터를 복사하는 중",
|
||||
"phase.extract.merge": "게임 데이터에 업데이트를 적용하는 중",
|
||||
"phase.extract.diagnose": "손상된 게임 파일을 찾는 중",
|
||||
"phase.extract.index": "게임 데이터를 검증하는 중",
|
||||
"phase.lift.discover": "함수를 찾는 중",
|
||||
"phase.lift.emit": "C 코드를 작성하는 중",
|
||||
"phase.compile.compile": "컴파일하는 중",
|
||||
"phase.compile.link": "{game_exe} 링크 중",
|
||||
"phase.prepare.romfs_patches": "60 fps 게임 데이터 패치를 작성하는 중",
|
||||
"phase.pc_prompts.draw": "totk.ini의 할당에 따라 키와 마우스 버튼 표시 그리는 중",
|
||||
"phase.prepare.seed": "게임 데이터에서 셰이더를 읽는 중",
|
||||
"phase.prepare.translate": "셰이더를 변환하는 중",
|
||||
"phase.prepare.libraries": "그래픽 드라이버용 셰이더를 빌드하는 중",
|
||||
"phase.prepare.pack": "셰이더 캐시를 파일 하나로 묶는 중",
|
||||
"phase.shapes.layouts": "화면 형태마다 화면 레이아웃과 버튼 표시 쓰는 중",
|
||||
"phase.dlss.download": "NVIDIA DLSS SDK에서 nvngx_dlss.dll을 다운로드하는 중",
|
||||
"phase.cleanup.ini": "totk.ini를 쓰는 중",
|
||||
"phase.cleanup.temp": "임시 파일을 삭제하는 중",
|
||||
"cli.usage": "잘못된 명령줄: {detail}",
|
||||
"internal": "예기치 않은 오류({exception}): {detail}",
|
||||
"state.unreadable": "{path}을(를) 읽을 수 없습니다. 다른 폴더를 선택하거나 해당 파일을 삭제하세요.",
|
||||
"state.newer_format": "{path}은(는) 더 새로운 설치 프로그램이 작성했습니다. 그 설치 프로그램이나 다른 폴더를 사용하세요.",
|
||||
"state.output_changed": "'{step}' 단계에서 설치한 파일이 만들어진 후 변경되었습니다. 해당 단계를 다시 실행합니다.",
|
||||
"check.release_incomplete": "설치 프로그램 폴더가 불완전합니다. 누락: {paths}. 릴리스 압축을 다시 푸세요.",
|
||||
"check.dest_not_folder": "설치 위치 {path}은(는) 폴더가 아니라 파일입니다.",
|
||||
"check.dest_not_empty": "설치 폴더 {path}이(가) 비어 있지 않으며 이전 설치도 없습니다. 빈 폴더를 선택하세요.",
|
||||
"check.lang_missing": "게임 언어를 선택하세요.",
|
||||
"check.lang_unknown": "알 수 없는 언어 '{lang}'. 사용 가능: {known}.",
|
||||
"check.toolchain_broken": "포함된 컴파일러가 작동하지 않습니다: {detail}",
|
||||
"check.glibc_old": "이 시스템의 C 라이브러리는 glibc {version}입니다. 설치 프로그램의 컴파일러에는 {need} 이상이 필요합니다(Ubuntu 22.04, Debian 12, Fedora 35, SteamOS 3 이상에 있음). 시스템을 업데이트하면 해결됩니다.",
|
||||
"check.host_probe_failed": "컴퓨터 확인이 실행되지 않았습니다(종료 코드 {code}).",
|
||||
"check.cpu_too_old": "이 프로세서에는 게임이 빌드되는 가장 오래된 수준인 x86-64-v2(SSE4.2, POPCNT, CMPXCHG16B)가 없습니다. Intel Nehalem(2008) 또는 AMD Bulldozer(2011) 이후 프로세서에 있습니다.",
|
||||
"check.vulkan_missing": "Vulkan 드라이버가 설치되어 있지 않습니다. 그래픽 카드의 최신 드라이버를 설치하세요.",
|
||||
"check.vulkan_no_device": "Vulkan이 그래픽 카드를 찾지 못했습니다. 그래픽 카드의 최신 드라이버를 설치하세요.",
|
||||
"check.vulkan_too_old": "게임에는 Vulkan 1.3을 지원하는 그래픽 카드가 필요합니다. 발견된 장치: {devices}. 그래픽 드라이버를 업데이트하세요.",
|
||||
"check.no_display": "셰이더를 준비하려면 디스플레이가 필요합니다. 데스크톱 세션에서 설치 프로그램을 실행하거나 DISPLAY=:0 을 export 하세요(게임 모드의 Steam Deck에서는 XDG_RUNTIME_DIR=/run/user/1000 도).",
|
||||
"check.inputs_needed": "게임 파일이 필요합니다. 기본 게임, 1.1.0 또는 1.2.1 또는 1.4.3 업데이트, prod.keys를 선택하세요.",
|
||||
"check.input_missing": "파일을 찾을 수 없음({input}): {path}",
|
||||
"check.keys_unreadable": "키 파일을 읽을 수 없습니다. prod.keys 파일을 선택하세요.",
|
||||
"check.keys_no_header_key": "키 파일에 header_key가 없습니다. 본체에서 prod.keys를 다시 덤프하세요.",
|
||||
"check.keys_wrong": "키로 {input} 파일을 열 수 없습니다. 본인 본체의 prod.keys를 사용하세요.",
|
||||
"check.keys_too_old": "키 파일이 {input} 파일에 비해 너무 오래되었습니다(키 세대 {generation} 필요). 더 새로운 펌웨어의 본체에서 prod.keys를 덤프하세요.",
|
||||
"check.not_game_file": "{input} 파일은 XCI, NSP, XCZ 또는 NSZ 게임 파일이 아닙니다.",
|
||||
"check.file_unreadable": "{input} 파일을 읽을 수 없습니다: {detail}",
|
||||
"check.unpack_failed": "압축 파일 {input}의 압축을 풀 수 없습니다: {detail}",
|
||||
"check.ticket_personalized": "{input} 파일에 개인화된 티켓이 들어 있습니다. 공통 티켓이 필요합니다.",
|
||||
"check.ticket_missing": "{input} 파일에 콘텐츠에 필요한 티켓이 없습니다.",
|
||||
"check.base_not_totk": "기본 게임 파일이 젤다의 전설 티어스 오브 더 킹덤이 아닙니다({detail}).",
|
||||
"check.base_is_update": "기본 게임 파일이 업데이트입니다. 여기에는 기본 게임 NSP 또는 XCI(버전 1.0.0)를 선택하고 이 파일은 업데이트로 선택하세요.",
|
||||
"check.base_combined": "기본 게임 파일에 여러 패키지(기본 게임, 업데이트 또는 DLC가 한 파일에)가 들어 있습니다. 게임만 들어 있는 기본 게임 덤프를 선택하세요.",
|
||||
"check.update_not_nsp": "업데이트는 NSP 또는 NSZ 파일이어야 합니다.",
|
||||
"check.update_is_base": "업데이트 파일에 기본 게임이 들어 있습니다. 1.1.0 또는 1.2.1 또는 1.4.3 업데이트 NSP를 선택하세요.",
|
||||
"check.update_not_totk": "업데이트 파일이 티어스 오브 더 킹덤 업데이트가 아닙니다({detail}).",
|
||||
"check.exefs_failed": "{input} 파일의 게임 코드가 검사를 통과하지 못했습니다. {log}을(를) 참조하세요.",
|
||||
"check.input_damaged": "{input} 파일이 손상되었거나 불완전합니다: {path}({detail}). 원본에서 파일을 다시 복사하거나 다시 덤프한 다음 설치를 다시 실행하세요.",
|
||||
"check.base_wrong_version": "기본 게임이 버전 1.0.0이 아닙니다({modules} 다름).",
|
||||
"check.update_wrong_version": "업데이트 버전은 {found}입니다. 이 릴리스는 {wanted}을(를) 사용합니다.",
|
||||
"check.disk_space": "{path}의 여유 공간이 부족합니다. {need_gb} GB 필요, {free_gb} GB 사용 가능.",
|
||||
"check.firmware_missing": "펌웨어 폴더 {path}이(가) 없습니다. 펌웨어의 Contents/registered 폴더를 선택하세요.",
|
||||
"check.firmware_empty": "펌웨어 폴더 {path}에 NCA 파일이 없습니다. 펌웨어의 Contents/registered 폴더를 선택하세요.",
|
||||
"check.fonts_keys_needed": "이 언어의 공유 글꼴이 아직 설치되지 않았습니다. 설치 프로그램이 펌웨어에서 추출할 수 있도록 prod.keys를 선택하세요.",
|
||||
"extract.exefs_mismatch": "추출한 게임 코드가 버전 {version}과(와) 일치하지 않습니다({modules}).",
|
||||
"extract.romfs_merge_failed": "게임 데이터에 업데이트를 적용하지 못했습니다: {detail}. 자세히: {log}",
|
||||
"extract.romfs_mismatch": "추출한 게임 데이터가 버전 {version}과(와) 일치하지 않습니다(크기 {size}, 체크섬 {sha256}...).",
|
||||
"fonts.failed": "공유 글꼴 추출에 실패했습니다(종료 코드 {code}): {detail}. 자세히: {log}",
|
||||
"fonts.incomplete": "공유 글꼴 추출에서 일부 파일이 작성되지 않았습니다({files}).",
|
||||
"fonts.copy_failed": "공유 글꼴을 {path}(으)로 복사할 수 없습니다: {detail}",
|
||||
"lift.failed": "게임 코드 변환에 실패했습니다(종료 코드 {code}). 자세히: {log}",
|
||||
"compile.failed": "{game_exe} 컴파일에 실패했습니다(종료 코드 {code}). 자세히: {log}",
|
||||
"compile.exe_in_use": "{path}이(가) 사용 중입니다. 게임을 닫고 설치 프로그램을 다시 실행하세요.",
|
||||
"kit.in_use": "{path}이(가) 사용 중입니다. 게임과 열려 있는 설치 또는 다시 빌드 창을 모두 닫은 다음 설치 프로그램을 다시 실행하세요.",
|
||||
"kit.copy_failed": "빌드 키트를 {path}에 복사할 수 없습니다: {detail}",
|
||||
"compile.exe_locked": "{path}에 쓸 수 없습니다. 다른 프로그램이 파일을 사용하고 있습니다(그 폴더에서 실행한 게임 또는 파일을 감지한 백신 프로그램). 게임을 닫고, 설치 프로그램 폴더와 설치 폴더를 백신 프로그램의 예외 목록에 추가한 다음 Windows를 다시 시작하고 설치 프로그램을 다시 실행하세요. 자세히: {log}",
|
||||
"prepare.xlate_in_use": "{path}이(가) 사용 중입니다. 게임을 닫고 이전 실행에서 남은 totk_xlate 프로세스를 종료한 다음 설치 프로그램을 다시 실행하세요.",
|
||||
"prepare.shader_list_missing": "셰이더 목록이 없습니다.",
|
||||
"prepare.romfs_patches_failed": "게임 데이터 패치 작성에 실패했습니다(종료 코드 {code}). 자세히: {log}",
|
||||
"prepare.shaders_failed": "셰이더 준비에 실패했습니다(종료 코드 {code}). 자세히: {log}",
|
||||
"cleanup.romfs_unreadable": "설치 후 {path}의 게임 데이터가 없거나 읽을 수 없습니다. Windows를 다시 시작한 다음 같은 폴더로 설치 프로그램을 다시 실행하세요. 게임 데이터만 다시 추출하고 나머지는 유지합니다.",
|
||||
"prepare.pack_failed": "셰이더 캐시 묶기에 실패했습니다(종료 코드 {code}). 자세히: {log}",
|
||||
"cleanup.ini_failed": "totk.ini를 쓸 수 없습니다: {detail}",
|
||||
"warn.lang_needs_fonts": "{lang} 텍스트에는 Switch 시스템 글꼴이 필요하지만 지정되지 않았습니다. 글꼴을 추가할 때까지 이 언어로는 게임이 시작되지 않습니다. 펌웨어 폴더(Contents/registered)를 선택하거나 docs/installer.md의 \"Switch system fonts\"를 참조하세요.",
|
||||
"warn.npdm_differs": "main.npdm이 참조용 {version} 덤프와 다릅니다. 코드 모듈만 사용합니다.",
|
||||
"warn.cheats_skipped": "mods 폴더에서 게임 코드를 바꾸는 치트를 빌드할 수 없었습니다. 치트 없이 게임을 설치합니다. 자세히: {log}",
|
||||
"warn.exefs_skipped": "모드의 ExeFS 패치(.ips, .pchtxt)를 빌드할 수 없었습니다. 패치 없이 게임을 설치합니다. 자세히: {log}",
|
||||
"warn.plugins_skipped": "모드의 코드 플러그인(exefs subsdk)을 빌드할 수 없었습니다. 게임은 플러그인 없이 설치됩니다. 자세히: {log}",
|
||||
"warn.xbox_prompts_failed": "Xbox, PlayStation 또는 PC 버튼 표시를 준비할 수 없었습니다(종료 코드 {code}). 게임은 Switch 버튼 표시를 유지합니다. 자세히: {log}",
|
||||
"warn.shaders_skipped": "일부 셰이더를 빌드하는 동안 그래픽 드라이버가 충돌하여 {count}개를 준비에서 제외했습니다. 게임은 처음 필요할 때 이를 빌드하며, 그때도 드라이버가 충돌할 수 있습니다. 드라이버를 업데이트하면 해결될 수 있습니다. 자세히: {log}",
|
||||
"warn.kernel_old": "Linux {version}에는 게임이 사용하는 쓰기 추적(6.7 이상)이 없습니다. 게임이 매우 느릴 수 있습니다. 시스템을 업데이트하면 해결됩니다.",
|
||||
"warn.dlss_kept": "설치 폴더에 이미 DLSS 라이브러리가 있습니다({path}). 설치 프로그램은 그대로 둡니다.",
|
||||
"warn.dlss_download_failed": "{url}에서 NVIDIA DLSS를 다운로드할 수 없습니다: {detail}. 게임은 없이도 실행되며, 다음 설치 실행 때 다시 시도합니다.",
|
||||
"ui.title": "TotK 설치",
|
||||
"ui.rebuild_title": "모드에 맞게 게임을 다시 빌드하는 중",
|
||||
"ui.start_game": "게임 시작",
|
||||
"ui.version": "버전 {version}",
|
||||
"ui.intro": "보유한 게임 파일로 플레이 가능한 티어스 오브 더 킹덤 폴더를 만듭니다. 시간이 걸리며 한 번만 실행됩니다.",
|
||||
"ui.notice": "이 설치 프로그램이 만드는 폴더에는 게임이 들어 있습니다. 개인 용도로만 사용하고 공유하거나 업로드하지 마세요.",
|
||||
"ui.keys_private": "키 파일은 그 자리에서 읽습니다. 내용은 표시, 복사, 저장되지 않습니다.",
|
||||
"ui.base": "기본 게임",
|
||||
"ui.update": "업데이트",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "펌웨어(선택 사항)",
|
||||
"ui.game_language": "게임 언어",
|
||||
"ui.dest": "설치 폴더",
|
||||
"ui.browse": "찾아보기...",
|
||||
"ui.pick_game": "기본 게임 파일 선택",
|
||||
"ui.pick_update": "1.1.0 또는 1.2.1 또는 1.4.3 업데이트 파일 선택",
|
||||
"ui.pick_keys": "prod.keys 선택",
|
||||
"ui.pick_firmware": "Switch 펌웨어 폴더 선택(Contents/registered)",
|
||||
"ui.pick_dest": "설치 폴더 선택",
|
||||
"ui.firmware_help": "중국어, 한국어, 번체 중국어 텍스트용: 펌웨어의 Contents/registered 폴더(예: Ryujinx 또는 Yuzu의 폴더). 설치 프로그램이 여기에서 Switch 시스템 글꼴을 설치 폴더로 복사합니다.",
|
||||
"ui.dlss": "NVIDIA RTX 그래픽 카드용 NVIDIA DLSS (nvngx_dlss.dll) 다운로드",
|
||||
"ui.dlss_help": "GitHub의 NVIDIA DLSS SDK에서, NVIDIA RTX SDK 라이선스에 따라 받습니다(github.com/NVIDIA/DLSS). 이 파일이 있어야 dlaa 및 DLSS 설정이 작동하며, 없으면 아무 효과가 없습니다.",
|
||||
"ui.compressed_help": "압축된 NSZ 및 XCZ 파일은 그대로 사용할 수 있습니다. 설치 프로그램이 직접 압축을 풉니다(게임 데이터를 추출할 때까지 압축을 푼 파일만큼의 여유 공간이 필요합니다).",
|
||||
"ui.section_files": "게임 파일",
|
||||
"ui.section_install": "설치",
|
||||
"ui.more_details": "▸ 자세히 보기",
|
||||
"ui.fewer_details": "▾ 자세히 숨기기",
|
||||
"ui.formats_help": "기본 게임: NSP, XCI, NSZ 또는 XCZ. 업데이트: 1.1.0, 1.2.1 또는 1.4.3(NSP 또는 NSZ).",
|
||||
"ui.type_game": "게임 파일(NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "키 파일(*.keys)",
|
||||
"ui.type_all": "모든 파일",
|
||||
"ui.start": "시작",
|
||||
"ui.cancel": "취소",
|
||||
"ui.cancelling": "취소하는 중...",
|
||||
"ui.show_log": "로그 보기",
|
||||
"ui.hide_log": "로그 숨기기",
|
||||
"ui.close": "닫기",
|
||||
"ui.back": "뒤로",
|
||||
"ui.open_folder": "폴더 열기",
|
||||
"ui.update_mode": "이 폴더에 이전 설치가 있습니다. 설치 프로그램이 이를 이어서 진행하거나 업데이트합니다. 게임 파일은 다시 필요한 경우에만 요청합니다.",
|
||||
"ui.need_dest": "설치 폴더를 선택하세요.",
|
||||
"ui.need_base": "기본 게임 파일을 선택하세요.",
|
||||
"ui.need_update": "1.1.0 또는 1.2.1 또는 1.4.3 업데이트 파일을 선택하세요.",
|
||||
"ui.need_keys": "prod.keys 파일을 선택하세요.",
|
||||
"ui.need_lang": "게임 언어를 선택하세요.",
|
||||
"ui.missing_base": "기본 게임 파일이 없습니다.",
|
||||
"ui.missing_update": "업데이트 파일이 없습니다.",
|
||||
"ui.missing_keys": "키 파일이 없습니다.",
|
||||
"ui.missing_firmware": "펌웨어 폴더가 없습니다.",
|
||||
"ui.running_install": "설치 중",
|
||||
"ui.running_resume": "이전 설치를 이어서 진행하는 중",
|
||||
"ui.running_update": "설치를 업데이트하는 중",
|
||||
"ui.state_started": "시작됨",
|
||||
"ui.state_done": "완료",
|
||||
"ui.state_skipped": "건너뜀",
|
||||
"ui.state_pending": "대기 중",
|
||||
"ui.state_running": "실행 중",
|
||||
"ui.state_failed": "실패",
|
||||
"ui.log_warning": "경고",
|
||||
"ui.log_error": "오류",
|
||||
"ui.log_space": "필요한 공간: {need} GB, 여유: {free} GB",
|
||||
"ui.log_end": "끝남",
|
||||
"ui.result_ok": "게임이 준비되었습니다",
|
||||
"ui.result_failed": "설치에 실패했습니다",
|
||||
"ui.result_cancelled": "설치가 취소되었습니다",
|
||||
"ui.done_text": "{dest}에서 {game_exe}을(를) 실행하세요. 설치 프로그램과 선택한 게임 파일은 더 이상 필요하지 않습니다.",
|
||||
"ui.cancelled_text": "완료된 단계는 유지됩니다. 계속하려면 같은 폴더로 설치를 다시 시작하세요.",
|
||||
"ui.log_file": "로그 파일: {path}",
|
||||
"ui.process_died": "설치가 예기치 않게 중지되었습니다(종료 코드 {code}).",
|
||||
"ui.confirm_cancel": "설치가 실행 중입니다. 취소하고 창을 닫을까요?",
|
||||
"ui.space_one": "{path}에 필요한 여유 공간: {need} GB(여유: {free} GB).",
|
||||
"ui.space_two": "{path}에 필요한 여유 공간: {need} GB(여유: {free} GB), {temp}: {temp_need} GB(여유: {temp_free} GB).",
|
||||
"ui.amount_bytes": "{done} / {total} GB",
|
||||
"ui.amount_chunks": "{done} / {total} 부분",
|
||||
"ui.amount_objects": "{done} / {total} 파일",
|
||||
"ui.amount_shaders": "{done} / {total} 셰이더",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n}초",
|
||||
"param.input.base": "기본 게임",
|
||||
"param.input.update": "업데이트",
|
||||
"param.input.keys": "키",
|
||||
"launcher.title": "TotK 설치",
|
||||
"launcher.python_missing": "설치 파일이 불완전합니다. TotK-Setup.exe 옆의 python 폴더가 없습니다. 전체 압축 파일을 다시 풀고 압축을 푼 폴더에서 TotK-Setup.exe를 실행하세요.",
|
||||
"lang.ja": "일본어",
|
||||
"lang.en-US": "영어(미국)",
|
||||
"lang.en-GB": "영어(영국)",
|
||||
"lang.fr": "프랑스어",
|
||||
"lang.fr-CA": "프랑스어(캐나다)",
|
||||
"lang.de": "독일어",
|
||||
"lang.it": "이탈리아어",
|
||||
"lang.es": "스페인어",
|
||||
"lang.es-419": "스페인어(중남미)",
|
||||
"lang.nl": "네덜란드어",
|
||||
"lang.pt": "포르투갈어",
|
||||
"lang.pt-BR": "포르투갈어(브라질)",
|
||||
"lang.ru": "러시아어",
|
||||
"lang.ko": "한국어",
|
||||
"lang.zh-Hans": "중국어(간체)",
|
||||
"lang.zh-Hant": "중국어(번체)"
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"step.check": "Computer en spelbestanden controleren",
|
||||
"step.kit": "De bouwkit naar de spelmap kopiëren",
|
||||
"step.fonts": "Systeemlettertypen uitpakken",
|
||||
"step.extract": "Spel uitpakken",
|
||||
"step.lift": "Spelcode naar C vertalen",
|
||||
"step.compile": "{game_exe} compileren",
|
||||
"step.prepare": "Shaders voorbereiden",
|
||||
"step.pc_prompts": "Toetsenbord- en muispictogrammen tekenen",
|
||||
"step.shapes": "De spelschermen voor je beeldschermen indelen",
|
||||
"step.dlss": "NVIDIA DLSS downloaden",
|
||||
"step.cleanup": "Opruimen",
|
||||
"phase.check.host": "Processor en videokaart controleren",
|
||||
"phase.check.verify": "Al geïnstalleerde bestanden controleren",
|
||||
"phase.check.verify_romfs": "Geïnstalleerde spelgegevens controleren",
|
||||
"phase.check.inputs": "Spelbestanden openen met de sleutels",
|
||||
"phase.check.unpack_base": "Gecomprimeerd basisspel uitpakken",
|
||||
"phase.check.unpack_update": "Gecomprimeerde update uitpakken",
|
||||
"phase.check.versions": "Spelversies controleren",
|
||||
"phase.kit.copy": "De hulpmiddelen kopiëren waarmee het spel zichzelf opnieuw bouwt voor codemods",
|
||||
"phase.fonts.extract": "Gedeelde lettertypen uit de firmware uitpakken",
|
||||
"phase.fonts.copy": "Gedeelde lettertypen naar de installatiemap kopiëren",
|
||||
"phase.extract.hash_base": "Controlesom van het basisspel berekenen",
|
||||
"phase.extract.hash_update": "Controlesom van de update berekenen",
|
||||
"phase.extract.exefs": "Spelcode uitpakken",
|
||||
"phase.extract.copy": "Spelgegevens kopiëren",
|
||||
"phase.extract.merge": "Update op de spelgegevens toepassen",
|
||||
"phase.extract.diagnose": "Beschadigd spelbestand zoeken",
|
||||
"phase.extract.index": "Spelgegevens verifiëren",
|
||||
"phase.lift.discover": "Functies zoeken",
|
||||
"phase.lift.emit": "C-code schrijven",
|
||||
"phase.compile.compile": "Compileren",
|
||||
"phase.compile.link": "{game_exe} linken",
|
||||
"phase.prepare.romfs_patches": "Spelgegevenspatches voor 60 fps schrijven",
|
||||
"phase.pc_prompts.draw": "Toets- en muisknoppictogrammen tekenen volgens de toewijzingen in totk.ini",
|
||||
"phase.prepare.seed": "Shaders uit de spelgegevens lezen",
|
||||
"phase.prepare.translate": "Shaders vertalen",
|
||||
"phase.prepare.libraries": "Shaders voor het grafische stuurprogramma bouwen",
|
||||
"phase.prepare.pack": "Shadercache in één bestand verpakken",
|
||||
"phase.shapes.layouts": "Schermindelingen en knoppictogrammen voor elke schermvorm schrijven",
|
||||
"phase.dlss.download": "nvngx_dlss.dll downloaden uit NVIDIA's DLSS SDK",
|
||||
"phase.cleanup.ini": "totk.ini schrijven",
|
||||
"phase.cleanup.temp": "Tijdelijke bestanden verwijderen",
|
||||
"cli.usage": "Ongeldige opdrachtregel: {detail}",
|
||||
"internal": "Onverwachte fout ({exception}): {detail}",
|
||||
"state.unreadable": "{path} kan niet worden gelezen. Kies een andere map of verwijder dat bestand.",
|
||||
"state.newer_format": "{path} is geschreven door een nieuwer installatieprogramma. Gebruik dat programma of een andere map.",
|
||||
"state.output_changed": "Geïnstalleerde bestanden van stap '{step}' zijn gewijzigd sinds ze zijn gemaakt; die stap wordt opnieuw uitgevoerd.",
|
||||
"check.release_incomplete": "De map van het installatieprogramma is onvolledig; ontbreekt: {paths}. Pak de release opnieuw uit.",
|
||||
"check.dest_not_folder": "De installatielocatie {path} is een bestand, geen map.",
|
||||
"check.dest_not_empty": "De installatiemap {path} is niet leeg en bevat geen eerdere installatie. Kies een lege map.",
|
||||
"check.lang_missing": "Kies de taal van het spel.",
|
||||
"check.lang_unknown": "Onbekende taal '{lang}'. Bekend: {known}.",
|
||||
"check.toolchain_broken": "De meegeleverde compiler werkt niet: {detail}",
|
||||
"check.glibc_old": "De C-bibliotheek van dit systeem is glibc {version}; de compiler van de installatie heeft {need} of nieuwer nodig (Ubuntu 22.04, Debian 12, Fedora 35, SteamOS 3 en nieuwer hebben die). Het systeem bijwerken lost dit op.",
|
||||
"check.host_probe_failed": "De computercontrole is niet uitgevoerd (afsluitcode {code}).",
|
||||
"check.cpu_too_old": "Deze processor mist x86-64-v2 (SSE4.2, POPCNT en CMPXCHG16B), het oudste niveau waarvoor het spel wordt gebouwd. Intel Nehalem (2008) of AMD Bulldozer (2011) en nieuwer hebben het.",
|
||||
"check.vulkan_missing": "Er is geen Vulkan-stuurprogramma geïnstalleerd. Installeer het nieuwste stuurprogramma voor je videokaart.",
|
||||
"check.vulkan_no_device": "Vulkan vindt geen videokaart. Installeer het nieuwste stuurprogramma voor je videokaart.",
|
||||
"check.vulkan_too_old": "Het spel heeft een videokaart met Vulkan 1.3 nodig; gevonden: {devices}. Werk het grafische stuurprogramma bij.",
|
||||
"check.no_display": "Voor het voorbereiden van de shaders is een scherm nodig. Start de installatie vanuit de bureaubladsessie of exporteer DISPLAY=:0 (op een Steam Deck in de Gamemodus ook XDG_RUNTIME_DIR=/run/user/1000).",
|
||||
"check.inputs_needed": "De spelbestanden zijn nodig: kies het basisspel, de update 1.1.0, 1.2.1 of 1.4.3 en prod.keys.",
|
||||
"check.input_missing": "Bestand niet gevonden ({input}): {path}",
|
||||
"check.keys_unreadable": "Het sleutelbestand kan niet worden gelezen. Kies een prod.keys-bestand.",
|
||||
"check.keys_no_header_key": "Het sleutelbestand heeft geen header_key. Lees prod.keys opnieuw uit je console uit.",
|
||||
"check.keys_wrong": "De sleutels kunnen het bestand ({input}) niet openen. Gebruik de prod.keys van je console.",
|
||||
"check.keys_too_old": "Het sleutelbestand is te oud voor het bestand ({input}) (sleutelgeneratie {generation} nodig). Lees prod.keys uit een console met nieuwere firmware.",
|
||||
"check.not_game_file": "Het bestand ({input}) is geen XCI-, NSP-, XCZ- of NSZ-spelbestand.",
|
||||
"check.file_unreadable": "Het bestand ({input}) kan niet worden gelezen: {detail}",
|
||||
"check.unpack_failed": "Het gecomprimeerde bestand {input} kon niet worden uitgepakt: {detail}",
|
||||
"check.ticket_personalized": "Het bestand ({input}) bevat een gepersonaliseerd ticket; een algemeen ticket is nodig.",
|
||||
"check.ticket_missing": "Het bestand ({input}) mist het ticket dat de inhoud nodig heeft.",
|
||||
"check.base_not_totk": "Het basisspelbestand is niet The Legend of Zelda: Tears of the Kingdom ({detail}).",
|
||||
"check.base_is_update": "Het basisspelbestand is een update. Kies hier het basisspel als NSP of XCI (versie 1.0.0) en dit bestand als update.",
|
||||
"check.base_combined": "Het basisspelbestand bevat meerdere pakketten (basisspel, update of DLC in één bestand). Kies een dump van het basisspel die alleen het spel bevat.",
|
||||
"check.update_not_nsp": "De update moet een NSP- of NSZ-bestand zijn.",
|
||||
"check.update_is_base": "Het updatebestand bevat een basisspel. Kies de NSP van update 1.1.0, 1.2.1 of 1.4.3.",
|
||||
"check.update_not_totk": "Het updatebestand is geen update van Tears of the Kingdom ({detail}).",
|
||||
"check.exefs_failed": "De spelcode van het bestand ({input}) heeft de controles niet doorstaan; zie {log}.",
|
||||
"check.input_damaged": "Het bestand ({input}) is beschadigd of onvolledig: {path} ({detail}). Kopieer dat bestand opnieuw vanaf de bron of maak de dump opnieuw en voer de installatie dan opnieuw uit.",
|
||||
"check.base_wrong_version": "Het basisspel is niet versie 1.0.0 ({modules} wijken af).",
|
||||
"check.update_wrong_version": "De update is versie {found}; deze release gebruikt {wanted}.",
|
||||
"check.disk_space": "Niet genoeg vrije ruimte voor {path}: {need_gb} GB nodig, {free_gb} GB vrij.",
|
||||
"check.firmware_missing": "De firmwaremap {path} bestaat niet. Kies de map Contents/registered van de firmware.",
|
||||
"check.firmware_empty": "De firmwaremap {path} bevat geen NCA-bestanden. Kies de map Contents/registered van de firmware.",
|
||||
"check.fonts_keys_needed": "De gedeelde lettertypen voor deze taal zijn nog niet geïnstalleerd; kies prod.keys zodat de installatie ze uit de firmware kan uitpakken.",
|
||||
"extract.exefs_mismatch": "De uitgepakte spelcode komt niet overeen met versie {version} ({modules}).",
|
||||
"extract.romfs_merge_failed": "Het toepassen van de update op de spelgegevens is mislukt: {detail}. Details: {log}",
|
||||
"extract.romfs_mismatch": "De uitgepakte spelgegevens komen niet overeen met versie {version} (grootte {size}, controlesom {sha256}...).",
|
||||
"fonts.failed": "Het uitpakken van de gedeelde lettertypen is mislukt (afsluitcode {code}): {detail}. Details: {log}",
|
||||
"fonts.incomplete": "Het uitpakken van de gedeelde lettertypen heeft niet elk bestand geschreven ({files}).",
|
||||
"fonts.copy_failed": "De gedeelde lettertypen kunnen niet naar {path} worden gekopieerd: {detail}",
|
||||
"lift.failed": "Het vertalen van de spelcode is mislukt (afsluitcode {code}). Details: {log}",
|
||||
"compile.failed": "Het compileren van {game_exe} is mislukt (afsluitcode {code}). Details: {log}",
|
||||
"compile.exe_in_use": "{path} is in gebruik. Sluit het spel en voer het installatieprogramma opnieuw uit.",
|
||||
"kit.in_use": "{path} is in gebruik. Sluit het spel en elk geopend installatie- of herbouwvenster en start de installatie daarna opnieuw.",
|
||||
"kit.copy_failed": "De bouwkit kan niet naar {path} worden gekopieerd: {detail}",
|
||||
"compile.exe_locked": "{path} kan niet worden geschreven: een ander programma houdt het vast, een spel dat vanuit die map is gestart of een virusscanner die het bestand heeft gemarkeerd. Sluit het spel, voeg de map van de installatie en de installatiemap toe aan de uitzonderingen van de virusscanner, start Windows opnieuw en start de installatie daarna opnieuw. Details: {log}",
|
||||
"prepare.xlate_in_use": "{path} is in gebruik. Sluit het spel, beëindig elk totk_xlate-proces dat van een eerdere uitvoering over is en voer het installatieprogramma opnieuw uit.",
|
||||
"prepare.shader_list_missing": "De shaderlijst ontbreekt.",
|
||||
"prepare.romfs_patches_failed": "Het schrijven van de spelgegevenspatches is mislukt (afsluitcode {code}). Details: {log}",
|
||||
"prepare.shaders_failed": "Het voorbereiden van de shaders is mislukt (afsluitcode {code}). Details: {log}",
|
||||
"cleanup.romfs_unreadable": "De spelgegevens in {path} ontbreken of kunnen na de installatie niet worden gelezen. Start Windows opnieuw en voer het installatieprogramma opnieuw uit op dezelfde map: het pakt de spelgegevens opnieuw uit en behoudt de rest.",
|
||||
"prepare.pack_failed": "Het verpakken van de shadercache is mislukt (afsluitcode {code}). Details: {log}",
|
||||
"cleanup.ini_failed": "totk.ini kan niet worden geschreven: {detail}",
|
||||
"warn.lang_needs_fonts": "Tekst in het {lang} heeft de systeemlettertypen van de Switch nodig, en die zijn niet opgegeven. Het spel start niet in deze taal totdat ze zijn toegevoegd. Kies de firmwaremap (Contents/registered) of zie \"Switch system fonts\" in docs/installer.md.",
|
||||
"warn.npdm_differs": "main.npdm wijkt af van de referentiedump {version}; alleen de codemodules worden gebruikt.",
|
||||
"warn.cheats_skipped": "De cheats uit de modsmap die de spelcode wijzigen konden niet worden gebouwd; het spel wordt zonder ze geïnstalleerd. Details: {log}",
|
||||
"warn.exefs_skipped": "De ExeFS-patches van de mods (.ips, .pchtxt) konden niet worden gebouwd; het spel wordt zonder ze geïnstalleerd. Details: {log}",
|
||||
"warn.plugins_skipped": "De codeplug-ins van de mods (exefs subsdk) konden niet worden gebouwd; het spel wordt zonder ze geïnstalleerd. Details: {log}",
|
||||
"warn.xbox_prompts_failed": "De Xbox-, PlayStation- of pc-knoppictogrammen konden niet worden voorbereid (afsluitcode {code}); het spel houdt de Switch-pictogrammen. Details: {log}",
|
||||
"warn.shaders_skipped": "Het grafische stuurprogramma is gecrasht bij het bouwen van enkele shaders, dus {count} zijn uit de voorbereiding weggelaten. Het spel bouwt ze wanneer het ze voor het eerst nodig heeft, en het stuurprogramma kan daar ook crashen; een update van het stuurprogramma kan dit oplossen. Details: {log}",
|
||||
"warn.kernel_old": "Linux {version} mist de schrijftracering waar het spel op rekent (6.7 of nieuwer); het spel kan erg traag zijn. Het systeem bijwerken lost dit op.",
|
||||
"warn.dlss_kept": "Er staat al een DLSS-bibliotheek in de installatiemap ({path}); de installatie laat die staan.",
|
||||
"warn.dlss_download_failed": "NVIDIA DLSS kon niet worden gedownload van {url}: {detail}. Het spel werkt zonder; de volgende installatieronde probeert het opnieuw.",
|
||||
"ui.title": "TotK-installatie",
|
||||
"ui.rebuild_title": "Spel opnieuw bouwen voor je mods",
|
||||
"ui.start_game": "Spel starten",
|
||||
"ui.version": "versie {version}",
|
||||
"ui.intro": "Bouwt een speelbare map van Tears of the Kingdom uit je eigen spelbestanden. Dit duurt even en gebeurt één keer.",
|
||||
"ui.notice": "De map die deze installatie bouwt bevat het spel. Die is alleen voor eigen gebruik; deel of upload hem niet.",
|
||||
"ui.keys_private": "Het sleutelbestand wordt ter plaatse gelezen. De inhoud wordt nooit getoond, gekopieerd of opgeslagen.",
|
||||
"ui.base": "Basisspel",
|
||||
"ui.update": "Update",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Firmware (optioneel)",
|
||||
"ui.game_language": "Taal van het spel",
|
||||
"ui.dest": "Installatiemap",
|
||||
"ui.browse": "Bladeren...",
|
||||
"ui.pick_game": "Kies het basisspelbestand",
|
||||
"ui.pick_update": "Kies het bestand van update 1.1.0, 1.2.1 of 1.4.3",
|
||||
"ui.pick_keys": "Kies prod.keys",
|
||||
"ui.pick_firmware": "Kies de map van de Switch-firmware (Contents/registered)",
|
||||
"ui.pick_dest": "Kies de installatiemap",
|
||||
"ui.firmware_help": "Voor Chinese, Koreaanse en traditioneel Chinese tekst: de map Contents/registered van de firmware, bijvoorbeeld uit Ryujinx of Yuzu. De installatie kopieert daaruit de systeemlettertypen van de Switch naar de installatiemap.",
|
||||
"ui.dlss": "NVIDIA DLSS (nvngx_dlss.dll) downloaden voor NVIDIA RTX-videokaarten",
|
||||
"ui.dlss_help": "Uit NVIDIA's DLSS SDK op GitHub, onder NVIDIA's RTX SDK-licentie (github.com/NVIDIA/DLSS). Hiermee werken de instellingen dlaa en DLSS; zonder doen ze niets.",
|
||||
"ui.compressed_help": "Gecomprimeerde NSZ- en XCZ-bestanden werken zoals ze zijn: de installatie pakt ze zelf uit (tot de spelgegevens zijn uitgepakt, is daarvoor evenveel vrije ruimte nodig als de uitgepakte bestanden innemen).",
|
||||
"ui.section_files": "Spelbestanden",
|
||||
"ui.section_install": "Installatie",
|
||||
"ui.more_details": "▸ Meer details",
|
||||
"ui.fewer_details": "▾ Details verbergen",
|
||||
"ui.formats_help": "Basisspel: NSP, XCI, NSZ of XCZ. Update: 1.1.0, 1.2.1 of 1.4.3, als NSP of NSZ.",
|
||||
"ui.type_game": "Spelbestanden (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Sleutelbestanden (*.keys)",
|
||||
"ui.type_all": "Alle bestanden",
|
||||
"ui.start": "Starten",
|
||||
"ui.cancel": "Annuleren",
|
||||
"ui.cancelling": "Annuleren...",
|
||||
"ui.show_log": "Logboek tonen",
|
||||
"ui.hide_log": "Logboek verbergen",
|
||||
"ui.close": "Sluiten",
|
||||
"ui.back": "Terug",
|
||||
"ui.open_folder": "Map openen",
|
||||
"ui.update_mode": "Deze map bevat een eerdere installatie. De installatie zet die voort of werkt die bij; de spelbestanden worden alleen gevraagd als ze opnieuw nodig zijn.",
|
||||
"ui.need_dest": "Kies de installatiemap.",
|
||||
"ui.need_base": "Kies het basisspelbestand.",
|
||||
"ui.need_update": "Kies het bestand van update 1.1.0, 1.2.1 of 1.4.3.",
|
||||
"ui.need_keys": "Kies het bestand prod.keys.",
|
||||
"ui.need_lang": "Kies de taal van het spel.",
|
||||
"ui.missing_base": "Het basisspelbestand bestaat niet.",
|
||||
"ui.missing_update": "Het updatebestand bestaat niet.",
|
||||
"ui.missing_keys": "Het sleutelbestand bestaat niet.",
|
||||
"ui.missing_firmware": "De firmwaremap bestaat niet.",
|
||||
"ui.running_install": "Installeren",
|
||||
"ui.running_resume": "Eerdere installatie voortzetten",
|
||||
"ui.running_update": "Installatie bijwerken",
|
||||
"ui.state_started": "gestart",
|
||||
"ui.state_done": "klaar",
|
||||
"ui.state_skipped": "overgeslagen",
|
||||
"ui.state_pending": "wacht",
|
||||
"ui.state_running": "bezig",
|
||||
"ui.state_failed": "mislukt",
|
||||
"ui.log_warning": "Waarschuwing",
|
||||
"ui.log_error": "Fout",
|
||||
"ui.log_space": "Benodigde ruimte: {need} GB, vrij: {free} GB",
|
||||
"ui.log_end": "Klaar",
|
||||
"ui.result_ok": "Het spel is klaar",
|
||||
"ui.result_failed": "De installatie is mislukt",
|
||||
"ui.result_cancelled": "De installatie is geannuleerd",
|
||||
"ui.done_text": "Start {game_exe} vanuit {dest}. Het installatieprogramma en de gekozen spelbestanden zijn niet meer nodig.",
|
||||
"ui.cancelled_text": "De voltooide stappen blijven bewaard. Start de installatie opnieuw met dezelfde map om verder te gaan.",
|
||||
"ui.log_file": "Logbestand: {path}",
|
||||
"ui.process_died": "De installatie is onverwacht gestopt (afsluitcode {code}).",
|
||||
"ui.confirm_cancel": "De installatie is bezig. Annuleren en het venster sluiten?",
|
||||
"ui.space_one": "Benodigde vrije ruimte op {path}: {need} GB (vrij: {free} GB).",
|
||||
"ui.space_two": "Benodigde vrije ruimte op {path}: {need} GB (vrij: {free} GB); op {temp}: {temp_need} GB (vrij: {temp_free} GB).",
|
||||
"ui.amount_bytes": "{done} / {total} GB",
|
||||
"ui.amount_chunks": "{done} / {total} delen",
|
||||
"ui.amount_objects": "{done} / {total} bestanden",
|
||||
"ui.amount_shaders": "{done} / {total} shaders",
|
||||
"ui.amount_other": "{done} / {total} {unit}",
|
||||
"ui.seconds": "{n} s",
|
||||
"param.input.base": "basisspel",
|
||||
"param.input.update": "update",
|
||||
"param.input.keys": "sleutels",
|
||||
"launcher.title": "TotK-installatie",
|
||||
"launcher.python_missing": "De installatiebestanden zijn onvolledig: de map python naast TotK-Setup.exe ontbreekt. Pak het hele archief opnieuw uit en start TotK-Setup.exe vanuit de uitgepakte map.",
|
||||
"lang.ja": "Japans",
|
||||
"lang.en-US": "Engels (VS)",
|
||||
"lang.en-GB": "Engels (VK)",
|
||||
"lang.fr": "Frans",
|
||||
"lang.fr-CA": "Frans (Canada)",
|
||||
"lang.de": "Duits",
|
||||
"lang.it": "Italiaans",
|
||||
"lang.es": "Spaans",
|
||||
"lang.es-419": "Spaans (Latijns-Amerika)",
|
||||
"lang.nl": "Nederlands",
|
||||
"lang.pt": "Portugees",
|
||||
"lang.pt-BR": "Portugees (Brazilië)",
|
||||
"lang.ru": "Russisch",
|
||||
"lang.ko": "Koreaans",
|
||||
"lang.zh-Hans": "Chinees (vereenvoudigd)",
|
||||
"lang.zh-Hant": "Chinees (traditioneel)"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"step.check": "Verificando o computador e os arquivos do jogo",
|
||||
"step.kit": "Copiando o kit de compilação para a pasta do jogo",
|
||||
"step.fonts": "Extraindo as fontes do sistema",
|
||||
"step.extract": "Extraindo o jogo",
|
||||
"step.lift": "Traduzindo o código do jogo para C",
|
||||
@@ -17,6 +18,7 @@
|
||||
"phase.check.unpack_base": "Descompactando o jogo base compactado",
|
||||
"phase.check.unpack_update": "Descompactando a atualização compactada",
|
||||
"phase.check.versions": "Verificando as versões do jogo",
|
||||
"phase.kit.copy": "Copiando as ferramentas com que o jogo se recompila para mods de código",
|
||||
"phase.fonts.extract": "Extraindo as fontes compartilhadas do firmware",
|
||||
"phase.fonts.copy": "Copiando as fontes compartilhadas para a pasta de instalação",
|
||||
"phase.extract.hash_base": "Calculando o checksum do jogo base",
|
||||
@@ -95,6 +97,8 @@
|
||||
"lift.failed": "Falha ao traduzir o código do jogo (código de saída {code}). Detalhes: {log}",
|
||||
"compile.failed": "Falha ao compilar o {game_exe} (código de saída {code}). Detalhes: {log}",
|
||||
"compile.exe_in_use": "{path} está em uso. Feche o jogo e execute o instalador de novo.",
|
||||
"kit.in_use": "{path} está em uso. Feche o jogo e qualquer janela de instalação ou recompilação aberta, depois execute o instalador de novo.",
|
||||
"kit.copy_failed": "Não foi possível copiar o kit de compilação para {path}: {detail}",
|
||||
"compile.exe_locked": "Não é possível gravar {path}: outro programa o está usando, um jogo aberto dessa pasta ou um antivírus que marcou o arquivo. Feche o jogo, adicione a pasta do instalador e a pasta de instalação às exceções do antivírus, reinicie o Windows e execute o instalador de novo. Detalhes: {log}",
|
||||
"prepare.xlate_in_use": "{path} está em uso. Feche o jogo, encerre qualquer processo totk_xlate que tenha sobrado de uma execução anterior e execute o instalador de novo.",
|
||||
"prepare.shader_list_missing": "A lista de shaders está faltando.",
|
||||
@@ -107,8 +111,9 @@
|
||||
"warn.lang_needs_fonts": "Textos em {lang} precisam das fontes de sistema do Switch, e nenhuma foi informada. O jogo não inicia neste idioma até que sejam adicionadas. Escolha a pasta do firmware (Contents/registered) ou veja \"Switch system fonts\" em docs/installer.md.",
|
||||
"warn.cheats_skipped": "Não foi possível compilar os cheats da pasta de mods que alteram o código do jogo; o jogo é instalado sem eles. Detalhes: {log}",
|
||||
"warn.exefs_skipped": "Não foi possível compilar os patches ExeFS dos mods (.ips, .pchtxt); o jogo é instalado sem eles. Detalhes: {log}",
|
||||
"warn.plugins_skipped": "Não foi possível compilar os plugins de código dos mods (exefs subsdk); o jogo é instalado sem eles. Detalhes: {log}",
|
||||
"warn.npdm_differs": "O main.npdm difere do dump de referência da versão {version}; só os módulos de código são usados.",
|
||||
"warn.xbox_prompts_failed": "Não foi possível preparar os ícones de botão do Xbox ou do PC (código de saída {code}); o jogo mantém os ícones do Switch. Detalhes: {log}",
|
||||
"warn.xbox_prompts_failed": "Não foi possível preparar os ícones de botão do Xbox, do PlayStation ou do PC (código de saída {code}); o jogo mantém os ícones do Switch. Detalhes: {log}",
|
||||
"warn.shaders_skipped": "O driver gráfico travou ao compilar alguns shaders, então {count} ficaram fora da preparação. O jogo os compila quando precisar deles pela primeira vez, e o driver pode travar ali também; uma atualização do driver pode resolver. Detalhes: {log}",
|
||||
"warn.kernel_old": "O Linux {version} não tem o rastreamento de escrita de que o jogo depende (6.7 ou mais novo); o jogo pode rodar muito devagar. Atualizar o sistema resolve.",
|
||||
"warn.dlss_kept": "Já existe uma biblioteca DLSS na pasta de instalação ({path}); a instalação a mantém.",
|
||||
@@ -121,10 +126,10 @@
|
||||
"ui.intro": "Monta uma pasta jogável de Tears of the Kingdom a partir dos seus próprios arquivos do jogo. Isso demora um pouco e só precisa ser feito uma vez.",
|
||||
"ui.notice": "A pasta que esta instalação monta contém o jogo. Ela é só para seu uso pessoal; não compartilhe nem envie para a internet.",
|
||||
"ui.keys_private": "O arquivo de chaves é lido no lugar. O conteúdo dele nunca é mostrado, copiado nem guardado.",
|
||||
"ui.base": "Jogo base (NSP, XCI, NSZ ou XCZ)",
|
||||
"ui.update": "Atualização 1.1.0, 1.2.1 ou 1.4.3 (NSP ou NSZ)",
|
||||
"ui.base": "Jogo base",
|
||||
"ui.update": "Atualização",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Pasta de firmware (opcional)",
|
||||
"ui.firmware": "Firmware (opcional)",
|
||||
"ui.game_language": "Idioma do jogo",
|
||||
"ui.dest": "Pasta de instalação",
|
||||
"ui.browse": "Procurar...",
|
||||
@@ -137,6 +142,11 @@
|
||||
"ui.dlss": "Baixar o NVIDIA DLSS (nvngx_dlss.dll) para placas de vídeo NVIDIA RTX",
|
||||
"ui.dlss_help": "Do DLSS SDK da NVIDIA no GitHub, sob a licença NVIDIA RTX SDK (github.com/NVIDIA/DLSS). Sem ele as opções dlaa e DLSS não fazem nada.",
|
||||
"ui.compressed_help": "Arquivos compactados NSZ e XCZ funcionam do jeito que estão: a instalação os descompacta sozinha (para isso, até os dados do jogo serem extraídos, ela precisa de tanto espaço livre quanto ocupam os arquivos descompactados).",
|
||||
"ui.section_files": "Arquivos do jogo",
|
||||
"ui.section_install": "Instalação",
|
||||
"ui.more_details": "▸ Mais detalhes",
|
||||
"ui.fewer_details": "▾ Ocultar detalhes",
|
||||
"ui.formats_help": "Jogo base: NSP, XCI, NSZ ou XCZ. Atualização: 1.1.0, 1.2.1 ou 1.4.3, em NSP ou NSZ.",
|
||||
"ui.type_game": "Arquivos de jogo (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Arquivos de chaves (*.keys)",
|
||||
"ui.type_all": "Todos os arquivos",
|
||||
|
||||
+14
-4
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"step.check": "Проверка компьютера и игровых файлов",
|
||||
"step.kit": "Копирование набора сборки в папку игры",
|
||||
"step.fonts": "Извлечение системных шрифтов",
|
||||
"step.extract": "Распаковка игры",
|
||||
"step.lift": "Перевод кода игры в C",
|
||||
@@ -17,6 +18,7 @@
|
||||
"phase.check.unpack_base": "Распаковка сжатой базовой игры",
|
||||
"phase.check.unpack_update": "Распаковка сжатого обновления",
|
||||
"phase.check.versions": "Проверка версий игры",
|
||||
"phase.kit.copy": "Копирование инструментов, которыми игра пересобирает себя для модов с кодом",
|
||||
"phase.fonts.extract": "Извлечение общих шрифтов из прошивки",
|
||||
"phase.fonts.copy": "Копирование общих шрифтов в папку установки",
|
||||
"phase.extract.hash_base": "Подсчёт контрольной суммы базовой игры",
|
||||
@@ -95,6 +97,8 @@
|
||||
"lift.failed": "Не удалось перевести код игры (код выхода {code}). Подробности: {log}",
|
||||
"compile.failed": "Не удалось собрать {game_exe} (код выхода {code}). Подробности: {log}",
|
||||
"compile.exe_in_use": "Файл {path} занят. Закройте игру и запустите установку снова.",
|
||||
"kit.in_use": "{path} занят другой программой. Закройте игру и все окна установки или пересборки, затем запустите установку снова.",
|
||||
"kit.copy_failed": "Не удалось скопировать набор сборки в {path}: {detail}",
|
||||
"compile.exe_locked": "Файл {path} не удаётся записать: его держит другая программа — игра, запущенная из этой папки, или антивирус, который пометил файл. Закройте игру, добавьте папку установщика и папку установки в исключения антивируса, перезагрузите Windows и запустите установку снова. Подробности: {log}",
|
||||
"prepare.xlate_in_use": "Файл {path} занят. Закройте игру, завершите процесс totk_xlate, оставшийся от прошлого запуска, и запустите установку снова.",
|
||||
"prepare.shader_list_missing": "Нет списка шейдеров.",
|
||||
@@ -108,7 +112,8 @@
|
||||
"warn.npdm_differs": "main.npdm отличается от эталонного дампа {version}; используются только модули с кодом.",
|
||||
"warn.cheats_skipped": "Не удалось собрать читы из папки модов, меняющие код игры; игра установится без них. Подробности: {log}",
|
||||
"warn.exefs_skipped": "Не удалось собрать ExeFS-патчи модов (.ips, .pchtxt); игра установится без них. Подробности: {log}",
|
||||
"warn.xbox_prompts_failed": "Не удалось подготовить подсказки кнопок Xbox или PC (код выхода {code}); игра оставит подсказки Switch. Подробности: {log}",
|
||||
"warn.plugins_skipped": "Не удалось собрать плагины кода модов (exefs subsdk); игра установится без них. Подробности: {log}",
|
||||
"warn.xbox_prompts_failed": "Не удалось подготовить подсказки кнопок Xbox, PlayStation или PC (код выхода {code}); игра оставит подсказки Switch. Подробности: {log}",
|
||||
"warn.shaders_skipped": "Графический драйвер аварийно завершился при сборке части шейдеров, поэтому {count} из них пропущены при подготовке. Игра соберёт их, когда они впервые понадобятся, и драйвер может упасть и там; обновление драйвера может это исправить. Подробности: {log}",
|
||||
"warn.kernel_old": "В Linux {version} нет отслеживания записи, на которое опирается игра (нужна версия 6.7 или новее); игра может работать очень медленно. Обновление системы это исправит.",
|
||||
"warn.dlss_kept": "В папке установки уже есть библиотека DLSS ({path}); установка её оставляет.",
|
||||
@@ -121,10 +126,10 @@
|
||||
"ui.intro": "Собирает готовую к запуску папку с Tears of the Kingdom из ваших игровых файлов. Занимает много времени и выполняется один раз.",
|
||||
"ui.notice": "Папка, которую создаёт установка, содержит игру. Она предназначена только для личного использования: не передавайте и не выкладывайте её.",
|
||||
"ui.keys_private": "Файл ключей читается на месте. Его содержимое не показывается, не копируется и не сохраняется.",
|
||||
"ui.base": "Базовая игра (NSP, XCI, NSZ или XCZ)",
|
||||
"ui.update": "Обновление 1.1.0 или 1.2.1 или 1.4.3 (NSP или NSZ)",
|
||||
"ui.base": "Базовая игра",
|
||||
"ui.update": "Обновление",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "Папка прошивки (необязательно)",
|
||||
"ui.firmware": "Прошивка (необязательно)",
|
||||
"ui.game_language": "Язык игры",
|
||||
"ui.dest": "Папка установки",
|
||||
"ui.browse": "Обзор...",
|
||||
@@ -137,6 +142,11 @@
|
||||
"ui.dlss": "Загрузить NVIDIA DLSS (nvngx_dlss.dll) для видеокарт NVIDIA RTX",
|
||||
"ui.dlss_help": "Из DLSS SDK от NVIDIA на GitHub, по лицензии NVIDIA RTX SDK (github.com/NVIDIA/DLSS). Без него настройки dlaa и DLSS ничего не делают.",
|
||||
"ui.compressed_help": "Сжатые файлы NSZ и XCZ подходят как есть: установка сама их распакует (для этого, пока извлекаются данные игры, нужно столько свободного места, сколько занимают распакованные файлы).",
|
||||
"ui.section_files": "Файлы игры",
|
||||
"ui.section_install": "Установка",
|
||||
"ui.more_details": "▸ Подробнее",
|
||||
"ui.fewer_details": "▾ Скрыть подробности",
|
||||
"ui.formats_help": "Базовая игра: NSP, XCI, NSZ или XCZ. Обновление: 1.1.0, 1.2.1 или 1.4.3, в NSP или NSZ.",
|
||||
"ui.type_game": "Файлы игры (NSP, XCI, NSZ, XCZ)",
|
||||
"ui.type_keys": "Файлы ключей (*.keys)",
|
||||
"ui.type_all": "Все файлы",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"step.check": "检查电脑和游戏文件",
|
||||
"step.kit": "正在把构建工具包复制到游戏文件夹",
|
||||
"step.fonts": "正在提取系统字体",
|
||||
"step.extract": "解包游戏",
|
||||
"step.lift": "将游戏代码转换为 C 代码",
|
||||
@@ -17,6 +18,7 @@
|
||||
"phase.check.unpack_base": "正在解压压缩的游戏本体",
|
||||
"phase.check.unpack_update": "正在解压压缩的更新",
|
||||
"phase.check.versions": "检查游戏版本",
|
||||
"phase.kit.copy": "正在复制游戏为代码模组重新构建自身所用的工具",
|
||||
"phase.fonts.extract": "正在从固件中提取共享字体",
|
||||
"phase.fonts.copy": "正在将共享字体复制到安装文件夹",
|
||||
"phase.extract.hash_base": "计算游戏本体的校验和",
|
||||
@@ -95,6 +97,8 @@
|
||||
"lift.failed": "游戏代码转换失败(退出代码 {code})。详情:{log}",
|
||||
"compile.failed": "编译 {game_exe} 失败(退出代码 {code})。详情:{log}",
|
||||
"compile.exe_in_use": "{path} 正在使用中。请关闭游戏后重新运行安装程序。",
|
||||
"kit.in_use": "{path} 正在被占用。请关闭游戏以及所有打开的安装或重新构建窗口,再重新运行安装程序。",
|
||||
"kit.copy_failed": "无法把构建工具包复制到 {path}:{detail}",
|
||||
"compile.exe_locked": "无法写入 {path}:另一个程序正在占用它,可能是从该文件夹启动的游戏,或标记了该文件的杀毒软件。请关闭游戏,将安装程序文件夹和安装文件夹加入杀毒软件的排除项,重启 Windows,然后重新运行安装程序。详情:{log}",
|
||||
"prepare.xlate_in_use": "{path} 正在被占用。请关闭游戏,结束上次残留的 totk_xlate 进程,再重新运行安装程序。",
|
||||
"prepare.shader_list_missing": "缺少着色器列表。",
|
||||
@@ -107,8 +111,9 @@
|
||||
"warn.lang_needs_fonts": "{lang}文本需要 Switch 系统字体,但未提供。在添加这些字体之前,游戏无法以该语言启动。请选择固件文件夹(Contents/registered),或参阅 docs/installer.md 中的“Switch system fonts”一节。",
|
||||
"warn.cheats_skipped": "无法构建 mods 文件夹中修改游戏代码的金手指;游戏将不含它们进行安装。详情:{log}",
|
||||
"warn.exefs_skipped": "无法构建模组的 ExeFS 补丁(.ips、.pchtxt);游戏将不含它们进行安装。详情:{log}",
|
||||
"warn.plugins_skipped": "无法构建模组的代码插件(exefs subsdk);游戏将不含它们进行安装。详情:{log}",
|
||||
"warn.npdm_differs": "main.npdm 与参考的 {version} 导出不同;只使用其中的代码模块。",
|
||||
"warn.xbox_prompts_failed": "无法准备 Xbox 或 PC 按键提示(退出代码 {code});游戏将继续使用 Switch 按键提示。详情:{log}",
|
||||
"warn.xbox_prompts_failed": "无法准备 Xbox、PlayStation 或 PC 按键提示(退出代码 {code});游戏将继续使用 Switch 按键提示。详情:{log}",
|
||||
"warn.shaders_skipped": "显卡驱动在编译部分着色器时崩溃,因此有 {count} 个着色器未被预先准备。游戏会在首次需要时编译它们,驱动在那时也可能崩溃;更新驱动可能会解决。详情:{log}",
|
||||
"warn.kernel_old": "Linux {version} 缺少游戏依赖的写入跟踪功能(需要 6.7 或更新版本);游戏可能运行得很慢。更新系统即可解决。",
|
||||
"warn.dlss_kept": "安装文件夹中已有 DLSS 库({path});安装程序将保留它。",
|
||||
@@ -121,10 +126,10 @@
|
||||
"ui.intro": "用你自己的游戏文件构建一个可以游玩的《王国之泪》文件夹。耗时较长,只需运行一次。",
|
||||
"ui.notice": "此安装程序构建的文件夹包含游戏本身,仅供你个人使用;请勿分享或上传。",
|
||||
"ui.keys_private": "密钥文件只在原位置读取,其内容绝不会被显示、复制或保存。",
|
||||
"ui.base": "游戏本体(NSP、XCI、NSZ 或 XCZ)",
|
||||
"ui.update": "1.1.0、1.2.1 或 1.4.3 更新(NSP 或 NSZ)",
|
||||
"ui.base": "游戏本体",
|
||||
"ui.update": "更新",
|
||||
"ui.keys": "prod.keys",
|
||||
"ui.firmware": "固件文件夹(可选)",
|
||||
"ui.firmware": "固件(可选)",
|
||||
"ui.game_language": "游戏语言",
|
||||
"ui.dest": "安装文件夹",
|
||||
"ui.browse": "浏览...",
|
||||
@@ -137,6 +142,11 @@
|
||||
"ui.dlss": "为 NVIDIA RTX 显卡下载 NVIDIA DLSS(nvngx_dlss.dll)",
|
||||
"ui.dlss_help": "来自 GitHub 上 NVIDIA 的 DLSS SDK,遵循 NVIDIA RTX SDK 许可(github.com/NVIDIA/DLSS)。没有它,dlaa 和 DLSS 设置不起作用。",
|
||||
"ui.compressed_help": "压缩的 NSZ 和 XCZ 文件可以直接使用:安装程序会自行解压(在游戏数据提取完成之前,需要与解压后文件大小相同的可用空间)。",
|
||||
"ui.section_files": "游戏文件",
|
||||
"ui.section_install": "安装",
|
||||
"ui.more_details": "▸ 更多说明",
|
||||
"ui.fewer_details": "▾ 收起说明",
|
||||
"ui.formats_help": "游戏本体:NSP、XCI、NSZ 或 XCZ。更新:1.1.0、1.2.1 或 1.4.3,NSP 或 NSZ 格式。",
|
||||
"ui.type_game": "游戏文件(NSP、XCI、NSZ、XCZ)",
|
||||
"ui.type_keys": "密钥文件(*.keys)",
|
||||
"ui.type_all": "所有文件",
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) rdbende <rdbende@proton.me>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Vendored
+130
@@ -0,0 +1,130 @@
|
||||
package require Tk 8.6-
|
||||
|
||||
source [file join [file dirname [info script]] theme light.tcl]
|
||||
source [file join [file dirname [info script]] theme dark.tcl]
|
||||
|
||||
|
||||
if {[tk windowingsystem] == "win32"} {
|
||||
set static ""
|
||||
} else {
|
||||
set static " static"
|
||||
}
|
||||
|
||||
font create SunValleyCaptionFont -family "Segoe UI Variable$static Small" -size -12
|
||||
font create SunValleyBodyFont -family "Segoe UI Variable$static Text" -size -14
|
||||
font create SunValleyBodyStrongFont -family "Segoe UI Variable$static Text Semibold" -size -14
|
||||
font create SunValleyBodyLargeFont -family "Segoe UI Variable$static Text" -size -18
|
||||
font create SunValleySubtitleFont -family "Segoe UI Variable$static Display Semibold" -size -20
|
||||
font create SunValleyTitleFont -family "Segoe UI Variable$static Display Semibold" -size -28
|
||||
font create SunValleyTitleLargeFont -family "Segoe UI Variable$static Display Semibold" -size -40
|
||||
font create SunValleyDisplayFont -family "Segoe UI Variable$static Display Semibold" -size -68
|
||||
|
||||
|
||||
proc config_entry_font {w} {
|
||||
set font_config [$w config -font]
|
||||
if {[lindex $font_config 3] != [lindex $font_config 4]} {
|
||||
return
|
||||
}
|
||||
if {[ttk::style theme use] in {"sun-valley-dark" "sun-valley-light"}} {
|
||||
$w configure -font SunValleyBodyFont
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
proc config_menus {w} {
|
||||
if {[tk windowingsystem] == "aqua" || [tk windowingsystem] == "win32"} {
|
||||
return
|
||||
}
|
||||
|
||||
set theme [ttk::style theme use]
|
||||
if {$theme == "sun-valley-dark"} {
|
||||
$w configure \
|
||||
-relief solid \
|
||||
-borderwidth 1 \
|
||||
-activeborderwidth 0 \
|
||||
-background "#292929" \
|
||||
-activebackground $ttk::theme::sv_dark::colors(-selbg) \
|
||||
-activeforeground $ttk::theme::sv_dark::colors(-selfg) \
|
||||
-selectcolor $ttk::theme::sv_dark::colors(-selfg)
|
||||
} elseif {$theme == "sun-valley-light"} {
|
||||
$w configure \
|
||||
-relief solid \
|
||||
-borderwidth 1 \
|
||||
-activeborderwidth 0 \
|
||||
-background "#e7e7e7" \
|
||||
-activebackground $ttk::theme::sv_light::colors(-selbg) \
|
||||
-activeforeground $ttk::theme::sv_light::colors(-selfg) \
|
||||
-selectcolor $ttk::theme::sv_light::colors(-selfg)
|
||||
}
|
||||
|
||||
if {[[winfo toplevel $w] cget -menu] != $w} {
|
||||
if {$theme == "sun-valley-dark"} {
|
||||
$w configure -borderwidth 0 -background $ttk::theme::sv_dark::colors(-bg)
|
||||
} elseif {$theme == "sun-valley-light"} {
|
||||
$w configure -borderwidth 0 -background $ttk::theme::sv_light::colors(-bg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
proc configure_colors {} {
|
||||
set theme [ttk::style theme use]
|
||||
if {$theme == "sun-valley-dark"} {
|
||||
ttk::style configure . \
|
||||
-background $ttk::theme::sv_dark::colors(-bg) \
|
||||
-foreground $ttk::theme::sv_dark::colors(-fg) \
|
||||
-troughcolor $ttk::theme::sv_dark::colors(-bg) \
|
||||
-focuscolor $ttk::theme::sv_dark::colors(-selbg) \
|
||||
-selectbackground $ttk::theme::sv_dark::colors(-selbg) \
|
||||
-selectforeground $ttk::theme::sv_dark::colors(-selfg) \
|
||||
-insertwidth 1 \
|
||||
-insertcolor $ttk::theme::sv_dark::colors(-fg) \
|
||||
-fieldbackground $ttk::theme::sv_dark::colors(-bg) \
|
||||
-font SunValleyBodyFont \
|
||||
-borderwidth 0 \
|
||||
-relief flat
|
||||
|
||||
tk_setPalette \
|
||||
background $ttk::theme::sv_dark::colors(-bg) \
|
||||
foreground $ttk::theme::sv_dark::colors(-fg) \
|
||||
highlightColor $ttk::theme::sv_dark::colors(-selbg) \
|
||||
selectBackground $ttk::theme::sv_dark::colors(-selbg) \
|
||||
selectForeground $ttk::theme::sv_dark::colors(-selfg) \
|
||||
activeBackground $ttk::theme::sv_dark::colors(-selbg) \
|
||||
activeForeground $ttk::theme::sv_dark::colors(-selfg)
|
||||
|
||||
ttk::style map . -foreground [list disabled $ttk::theme::sv_dark::colors(-disfg)]
|
||||
} elseif {$theme == "sun-valley-light"} {
|
||||
ttk::style configure . \
|
||||
-background $ttk::theme::sv_light::colors(-bg) \
|
||||
-foreground $ttk::theme::sv_light::colors(-fg) \
|
||||
-troughcolor $ttk::theme::sv_light::colors(-bg) \
|
||||
-focuscolor $ttk::theme::sv_light::colors(-selbg) \
|
||||
-selectbackground $ttk::theme::sv_light::colors(-selbg) \
|
||||
-selectforeground $ttk::theme::sv_light::colors(-selfg) \
|
||||
-insertwidth 1 \
|
||||
-insertcolor $ttk::theme::sv_light::colors(-fg) \
|
||||
-fieldbackground $ttk::theme::sv_light::colors(-bg) \
|
||||
-font SunValleyBodyFont \
|
||||
-borderwidth 0 \
|
||||
-relief flat
|
||||
|
||||
tk_setPalette \
|
||||
background $ttk::theme::sv_light::colors(-bg) \
|
||||
foreground $ttk::theme::sv_light::colors(-fg) \
|
||||
highlightColor $ttk::theme::sv_light::colors(-selbg) \
|
||||
selectBackground $ttk::theme::sv_light::colors(-selbg) \
|
||||
selectForeground $ttk::theme::sv_light::colors(-selfg) \
|
||||
activeBackground $ttk::theme::sv_light::colors(-selbg) \
|
||||
activeForeground $ttk::theme::sv_light::colors(-selfg)
|
||||
|
||||
ttk::style map . -foreground [list disabled $ttk::theme::sv_light::colors(-disfg)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bind [winfo class .] <<ThemeChanged>> {+configure_colors}
|
||||
bind TEntry <<ThemeChanged>> {+config_entry_font %W}
|
||||
bind TCombobox <<ThemeChanged>> {+config_entry_font %W}
|
||||
bind TSpinbox <<ThemeChanged>> {+config_entry_font %W}
|
||||
bind Menu <<ThemeChanged>> {+config_menus %W}
|
||||
+465
@@ -0,0 +1,465 @@
|
||||
source [file join [file dirname [info script]] sprites_dark.tcl]
|
||||
|
||||
namespace eval ttk::theme::sv_dark {
|
||||
package provide ttk::theme::sv_dark 2.5
|
||||
|
||||
array set colors {
|
||||
-fg "#fafafa"
|
||||
-bg "#1c1c1c"
|
||||
-disfg "#595959"
|
||||
-selfg "#ffffff"
|
||||
-selbg "#2f60d8"
|
||||
-accent "#57c8ff"
|
||||
}
|
||||
|
||||
proc load_images {imgfile} {
|
||||
variable I
|
||||
image create photo spritesheet -file $imgfile -format png
|
||||
foreach {name x y width height} $::spriteinfo {
|
||||
set I($name) [image create photo -width $width -height $height]
|
||||
$I($name) copy spritesheet -from $x $y [expr {$x+$width}] [expr {$y+$height}]
|
||||
}
|
||||
}
|
||||
|
||||
load_images [file join [file dirname [info script]] spritesheet_dark.png]
|
||||
|
||||
ttk::style theme create sun-valley-dark -parent clam -settings {
|
||||
|
||||
# Button
|
||||
ttk::style layout TButton {
|
||||
Button.button -children {
|
||||
Button.padding -children {
|
||||
Button.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TButton -padding {8 2 8 3} -anchor center -foreground $colors(-fg)
|
||||
ttk::style map TButton -foreground [list disabled "#7a7a7a" pressed "#d0d0d0"]
|
||||
|
||||
ttk::style element create Button.button image \
|
||||
[list $I(button-rest) \
|
||||
{selected disabled} $I(button-dis) \
|
||||
disabled $I(button-dis) \
|
||||
selected $I(button-rest) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Toolbutton
|
||||
ttk::style layout Toolbutton {
|
||||
Toolbutton.button -children {
|
||||
Toolbutton.padding -children {
|
||||
Toolbutton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure Toolbutton -padding {8 2 8 3} -anchor center
|
||||
|
||||
ttk::style element create Toolbutton.button image \
|
||||
[list $I(empty) \
|
||||
disabled $I(button-dis) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Accent.TButton
|
||||
ttk::style layout Accent.TButton {
|
||||
AccentButton.button -children {
|
||||
AccentButton.padding -children {
|
||||
AccentButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure Accent.TButton -padding {8 2 8 3} -anchor center -foreground "#000000"
|
||||
ttk::style map Accent.TButton -foreground [list pressed "#25536a" disabled "#a5a5a5"]
|
||||
|
||||
ttk::style element create AccentButton.button image \
|
||||
[list $I(button-accent-rest) \
|
||||
{selected disabled} $I(button-accent-dis) \
|
||||
disabled $I(button-accent-dis) \
|
||||
selected $I(button-accent-rest) \
|
||||
pressed $I(button-accent-pressed) \
|
||||
{active focus} $I(button-accent-focus-hover) \
|
||||
active $I(button-accent-hover) \
|
||||
focus $I(button-accent-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Menubutton
|
||||
ttk::style layout TMenubutton {
|
||||
Menubutton.button -children {
|
||||
Menubutton.padding -children {
|
||||
Menubutton.label -side left -expand 1
|
||||
Menubutton.indicator -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TMenubutton -padding {8 2 13 3}
|
||||
|
||||
ttk::style element create Menubutton.button image \
|
||||
[list $I(button-rest) \
|
||||
disabled $I(button-dis) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
ttk::style element create Menubutton.indicator image $I(down) -width 10 -sticky e
|
||||
|
||||
# OptionMenu
|
||||
ttk::style layout TOptionMenu {
|
||||
OptionMenu.button -children {
|
||||
OptionMenu.padding -children {
|
||||
OptionMenu.label -side left -expand 1
|
||||
OptionMenu.indicator -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TOptionMenu -padding {8 2 13 3}
|
||||
|
||||
ttk::style element create OptionMenu.button image \
|
||||
[list $I(button-rest) \
|
||||
disabled $I(button-dis) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
ttk::style element create OptionMenu.indicator image $I(down) -width 10 -sticky e
|
||||
|
||||
# Checkbutton
|
||||
ttk::style layout TCheckbutton {
|
||||
Checkbutton.button -children {
|
||||
Checkbutton.padding -children {
|
||||
Checkbutton.indicator -side left
|
||||
Checkbutton.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TCheckbutton -padding 4
|
||||
|
||||
ttk::style element create Checkbutton.indicator image \
|
||||
[list $I(check-unsel-rest) \
|
||||
{alternate disabled} $I(check-tri-dis) \
|
||||
{selected disabled} $I(check-dis) \
|
||||
disabled $I(check-unsel-dis) \
|
||||
{pressed alternate} $I(check-tri-hover) \
|
||||
{active focus alternate} $I(check-tri-focus-hover) \
|
||||
{active alternate} $I(check-tri-hover) \
|
||||
{focus alternate} $I(check-tri-focus) \
|
||||
alternate $I(check-tri-rest) \
|
||||
{pressed selected} $I(check-hover) \
|
||||
{active focus selected} $I(check-focus-hover) \
|
||||
{active selected} $I(check-hover) \
|
||||
{focus selected} $I(check-focus) \
|
||||
selected $I(check-rest) \
|
||||
{pressed !selected} $I(check-unsel-pressed) \
|
||||
{active focus} $I(check-unsel-focus-hover) \
|
||||
active $I(check-unsel-hover) \
|
||||
focus $I(check-unsel-focus) \
|
||||
] -width 26 -sticky w
|
||||
|
||||
# Switch.TCheckbutton
|
||||
ttk::style layout Switch.TCheckbutton {
|
||||
Switch.button -children {
|
||||
Switch.padding -children {
|
||||
Switch.indicator -side left
|
||||
Switch.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Switch.indicator image \
|
||||
[list $I(switch-off-rest) \
|
||||
{selected disabled} $I(switch-dis) \
|
||||
disabled $I(switch-off-dis) \
|
||||
{pressed selected} $I(switch-pressed) \
|
||||
{active focus selected} $I(switch-focus-hover) \
|
||||
{active selected} $I(switch-hover) \
|
||||
{focus selected} $I(switch-focus) \
|
||||
selected $I(switch-rest) \
|
||||
{pressed !selected} $I(switch-off-pressed) \
|
||||
{active focus} $I(switch-off-focus-hover) \
|
||||
active $I(switch-off-hover) \
|
||||
focus $I(switch-off-focus) \
|
||||
] -width 46 -sticky w
|
||||
|
||||
# Toggle.TButton
|
||||
ttk::style layout Toggle.TButton {
|
||||
ToggleButton.button -children {
|
||||
ToggleButton.padding -children {
|
||||
ToggleButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure Toggle.TButton -padding {8 2 8 3} -anchor center -foreground $colors(-fg)
|
||||
|
||||
ttk::style map Toggle.TButton -foreground \
|
||||
[list {selected disabled} "#a5a5a5" \
|
||||
{selected pressed} "#d0d0d0" \
|
||||
selected "#000000" \
|
||||
pressed "#25536a" \
|
||||
disabled "#7a7a7a"
|
||||
]
|
||||
|
||||
ttk::style element create ToggleButton.button image \
|
||||
[list $I(button-rest) \
|
||||
{selected disabled} $I(button-accent-dis) \
|
||||
disabled $I(button-dis) \
|
||||
{pressed selected} $I(button-rest) \
|
||||
{active focus selected} $I(button-accent-focus-hover) \
|
||||
{active selected} $I(button-accent-hover) \
|
||||
{focus selected} $I(button-accent-focus) \
|
||||
selected $I(button-accent-rest) \
|
||||
{pressed !selected} $I(button-accent-rest) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Radiobutton
|
||||
ttk::style layout TRadiobutton {
|
||||
Radiobutton.button -children {
|
||||
Radiobutton.padding -children {
|
||||
Radiobutton.indicator -side left
|
||||
Radiobutton.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TRadiobutton -padding 4
|
||||
|
||||
ttk::style element create Radiobutton.indicator image \
|
||||
[list $I(radio-unsel-rest) \
|
||||
{selected disabled} $I(radio-dis) \
|
||||
disabled $I(radio-unsel-dis) \
|
||||
{pressed selected} $I(radio-pressed) \
|
||||
{active focus selected} $I(radio-focus-hover) \
|
||||
{active selected} $I(radio-hover) \
|
||||
{focus selected} $I(radio-focus) \
|
||||
selected $I(radio-rest) \
|
||||
{pressed !selected} $I(radio-unsel-pressed) \
|
||||
{active focus} $I(radio-unsel-focus-hover) \
|
||||
active $I(radio-unsel-hover) \
|
||||
focus $I(radio-unsel-focus) \
|
||||
] -width 26 -sticky w
|
||||
|
||||
# Entry
|
||||
ttk::style configure TEntry -foreground $colors(-fg) -padding {6 1 4 2}
|
||||
ttk::style map TEntry -foreground [list disabled "#757575" pressed "#cfcfcf"]
|
||||
|
||||
ttk::style element create Entry.field image \
|
||||
[list $I(textbox-rest) \
|
||||
{focus hover !invalid} $I(textbox-focus) \
|
||||
invalid $I(textbox-error) \
|
||||
disabled $I(textbox-dis) \
|
||||
{focus !invalid} $I(textbox-focus) \
|
||||
hover $I(textbox-hover) \
|
||||
] -border 5 -sticky nsew
|
||||
|
||||
# Combobox
|
||||
ttk::style layout TCombobox {
|
||||
Combobox.field -sticky nsew -children {
|
||||
Combobox.arrow -side right -sticky ns
|
||||
Combobox.padding -sticky nsew -children {
|
||||
Combobox.textarea -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TCombobox -foreground $colors(-fg) -padding {6 1 0 2}
|
||||
ttk::style configure ComboboxPopdownFrame -borderwidth 1 -relief solid
|
||||
ttk::style map TCombobox -foreground [list disabled "#757575" pressed "#cfcfcf"]
|
||||
|
||||
ttk::style map TCombobox -selectbackground [list \
|
||||
{readonly hover} $colors(-selbg) \
|
||||
{readonly focus} $colors(-selbg) \
|
||||
] -selectforeground [list \
|
||||
{readonly hover} $colors(-selfg) \
|
||||
{readonly focus} $colors(-selfg) \
|
||||
]
|
||||
|
||||
ttk::style element create Combobox.field image \
|
||||
[list $I(textbox-rest) \
|
||||
{readonly focus} $I(button-focus) \
|
||||
{readonly disabled} $I(button-dis) \
|
||||
{readonly pressed} $I(button-pressed) \
|
||||
{readonly hover} $I(button-hover) \
|
||||
readonly $I(button-rest) \
|
||||
{focus hover !invalid} $I(textbox-focus) \
|
||||
invalid $I(textbox-error) \
|
||||
disabled $I(textbox-dis) \
|
||||
focus $I(textbox-focus) \
|
||||
{focus !invalid} $I(textbox-focus) \
|
||||
hover $I(textbox-hover) \
|
||||
] -border 5
|
||||
|
||||
ttk::style element create Combobox.arrow image $I(down) -width 34 -sticky {}
|
||||
|
||||
# Spinbox
|
||||
ttk::style layout TSpinbox {
|
||||
Spinbox.field -side top -sticky we -children {
|
||||
Spinbox.downarrow -side right -sticky ns
|
||||
Spinbox.uparrow -side right -sticky ns
|
||||
Spinbox.padding -sticky nswe -children {
|
||||
Spinbox.textarea -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TSpinbox -foreground $colors(-fg) -padding {6 1 0 2}
|
||||
ttk::style map TSpinbox -foreground [list disabled "#757575" pressed "#cfcfcf"]
|
||||
|
||||
ttk::style element create Spinbox.field image \
|
||||
[list $I(textbox-rest) \
|
||||
{focus hover !invalid} $I(textbox-focus) \
|
||||
invalid $I(textbox-error) \
|
||||
disabled $I(textbox-dis) \
|
||||
focus $I(textbox-focus) \
|
||||
{focus !invalid} $I(textbox-focus) \
|
||||
hover $I(textbox-hover) \
|
||||
] -border 5 -sticky nsew
|
||||
|
||||
ttk::style element create Spinbox.uparrow image $I(up) -width 34 -height 16 -sticky {}
|
||||
ttk::style element create Spinbox.downarrow image $I(down) -width 34 -height 16 -sticky {}
|
||||
|
||||
# Progressbar
|
||||
ttk::style element create Horizontal.Progressbar.trough image $I(progressbar-trough-hor) -border 1 -sticky ew
|
||||
ttk::style element create Horizontal.Progressbar.pbar image $I(progressbar-bar-hor) -border 2 -sticky ew
|
||||
|
||||
ttk::style element create Vertical.Progressbar.trough image $I(progressbar-trough-vert) -border 1 -sticky ns
|
||||
ttk::style element create Vertical.Progressbar.pbar image $I(progressbar-bar-vert) -border 2 -sticky ns
|
||||
|
||||
# Scale
|
||||
ttk::style element create Horizontal.Scale.trough image $I(slider-trough-hor) \
|
||||
-border 5 -padding 0 -sticky {ew}
|
||||
|
||||
ttk::style element create Vertical.Scale.trough image $I(slider-trough-vert) \
|
||||
-border 5 -padding 0 -sticky {ns}
|
||||
|
||||
ttk::style element create Scale.slider image \
|
||||
[list $I(slider-thumb-rest) \
|
||||
disabled $I(slider-thumb-dis) \
|
||||
pressed $I(slider-thumb-pressed) \
|
||||
{active focus} $I(slider-thumb-focus-hover) \
|
||||
active $I(slider-thumb-hover) \
|
||||
focus $I(slider-thumb-focus) \
|
||||
] -sticky {}
|
||||
|
||||
# Scrollbar
|
||||
ttk::style layout Vertical.TScrollbar {
|
||||
Vertical.Scrollbar.trough -sticky ns -children {
|
||||
Vertical.Scrollbar.uparrow -side top
|
||||
Vertical.Scrollbar.downarrow -side bottom
|
||||
Vertical.Scrollbar.thumb -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Horizontal.TScrollbar {
|
||||
Horizontal.Scrollbar.trough -sticky ew -children {
|
||||
Horizontal.Scrollbar.leftarrow -side left
|
||||
Horizontal.Scrollbar.rightarrow -side right
|
||||
Horizontal.Scrollbar.thumb -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Horizontal.Scrollbar.trough image $I(scrollbar-trough-hor) -sticky ew -border {6 0}
|
||||
ttk::style element create Horizontal.Scrollbar.thumb image $I(scrollbar-thumb-hor) -sticky ew -border {3 0}
|
||||
|
||||
ttk::style element create Horizontal.Scrollbar.rightarrow image $I(scrollbar-right) -sticky e -width 13
|
||||
ttk::style element create Horizontal.Scrollbar.leftarrow image $I(scrollbar-left) -sticky w -width 13
|
||||
|
||||
ttk::style element create Vertical.Scrollbar.trough image $I(scrollbar-trough-vert) -sticky ns -border {0 6}
|
||||
ttk::style element create Vertical.Scrollbar.thumb image $I(scrollbar-thumb-vert) -sticky ns -border {0 3}
|
||||
|
||||
ttk::style element create Vertical.Scrollbar.uparrow image $I(scrollbar-up) -sticky n -height 13
|
||||
ttk::style element create Vertical.Scrollbar.downarrow image $I(scrollbar-down) -sticky s -height 13
|
||||
|
||||
# Separator
|
||||
ttk::style element create Separator.separator image $I(sep) -width 1 -height 1
|
||||
|
||||
# Sizegrip
|
||||
ttk::style element create Sizegrip.sizegrip image $I(grip) -sticky nsew
|
||||
|
||||
# Card
|
||||
ttk::style layout Card.TFrame {
|
||||
Card.field {
|
||||
Card.padding -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Card.field image $I(card) -border 10 -padding 4 -sticky nsew
|
||||
|
||||
# Labelframe
|
||||
ttk::style layout TLabelframe {
|
||||
Labelframe.border {
|
||||
Labelframe.padding -expand 1 -children {
|
||||
Labelframe.label -side left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Labelframe.border image $I(card) -border 5 -padding 4 -sticky nsew
|
||||
ttk::style configure TLabelframe.Label -font SunValleyCaptionFont
|
||||
|
||||
# Notebook
|
||||
ttk::style layout TNotebook {
|
||||
Notebook.border -children {
|
||||
TNotebook.Tab -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TNotebook -padding 1
|
||||
ttk::style configure TNotebook.Tab -focuscolor $colors(-accent)
|
||||
ttk::style element create Notebook.border image $I(notebook-border) -border 5 -padding 5
|
||||
|
||||
ttk::style element create Notebook.tab image \
|
||||
[list $I(tab-rest) \
|
||||
selected $I(tab-selected) \
|
||||
active $I(tab-hover) \
|
||||
] -border 13 -padding {16 14 16 6} -height 32
|
||||
|
||||
# Treeview
|
||||
ttk::style configure Heading -font SunValleyCaptionFont
|
||||
ttk::style configure Treeview \
|
||||
-background $colors(-bg) \
|
||||
-rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 3}] \
|
||||
-font SunValleyBodyFont
|
||||
|
||||
ttk::style map Treeview -background {selected "#292929"} -foreground "selected $colors(-selfg)"
|
||||
|
||||
ttk::style element create Treeview.field image $I(card) -border 5 -width 0 -height 0
|
||||
|
||||
ttk::style element create Treeheading.cell image \
|
||||
[list $I(heading-rest) \
|
||||
pressed $I(heading-pressed) \
|
||||
active $I(heading-hover)
|
||||
] -border 5 -padding 14 -sticky nsew
|
||||
|
||||
ttk::style element create Treeitem.indicator image \
|
||||
[list $I(right) \
|
||||
user2 $I(empty) \
|
||||
user1 $I(down) \
|
||||
] -width 26 -sticky {}
|
||||
|
||||
# Panedwindow
|
||||
ttk::style configure Sash \
|
||||
-lightcolor "#9e9e9e" \
|
||||
-darkcolor "#9e9e9e" \
|
||||
-bordercolor "#9e9e9e" \
|
||||
-sashthickness 4 \
|
||||
-gripcount 20
|
||||
}
|
||||
}
|
||||
+469
@@ -0,0 +1,469 @@
|
||||
source [file join [file dirname [info script]] sprites_light.tcl]
|
||||
|
||||
namespace eval ttk::theme::sv_light {
|
||||
package provide ttk::theme::sv_light 2.5
|
||||
|
||||
array set colors {
|
||||
-fg "#1c1c1c"
|
||||
-bg "#fafafa"
|
||||
-disfg "#a0a0a0"
|
||||
-selfg "#ffffff"
|
||||
-selbg "#2f60d8"
|
||||
-accent "#005fb8"
|
||||
}
|
||||
|
||||
proc load_images {imgfile} {
|
||||
variable I
|
||||
image create photo spritesheet -file $imgfile -format png
|
||||
foreach {name x y width height} $::spriteinfo {
|
||||
set I($name) [image create photo -width $width -height $height]
|
||||
$I($name) copy spritesheet -from $x $y [expr {$x+$width}] [expr {$y+$height}]
|
||||
}
|
||||
}
|
||||
|
||||
load_images [file join [file dirname [info script]] spritesheet_light.png]
|
||||
|
||||
ttk::style theme create sun-valley-light -parent clam -settings {
|
||||
|
||||
# Button
|
||||
ttk::style layout TButton {
|
||||
Button.button -children {
|
||||
Button.padding -children {
|
||||
Button.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TButton -padding {8 2 8 3} -anchor center -foreground $colors(-fg)
|
||||
ttk::style map TButton -foreground [list disabled "#a2a2a2" pressed "#636363" active "#1a1a1a"]
|
||||
|
||||
ttk::style element create Button.button image \
|
||||
[list $I(button-rest) \
|
||||
{selected disabled} $I(button-dis) \
|
||||
disabled $I(button-dis) \
|
||||
selected $I(button-rest) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Toolbutton
|
||||
ttk::style layout Toolbutton {
|
||||
Toolbutton.button -children {
|
||||
Toolbutton.padding -children {
|
||||
Toolbutton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure Toolbutton -padding {8 2 8 3} -anchor center
|
||||
|
||||
ttk::style element create Toolbutton.button image \
|
||||
[list $I(empty) \
|
||||
disabled $I(button-dis) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Accent.TButton
|
||||
ttk::style layout Accent.TButton {
|
||||
AccentButton.button -children {
|
||||
AccentButton.padding -children {
|
||||
AccentButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure Accent.TButton -padding {8 2 8 3} -anchor center -foreground "#ffffff"
|
||||
ttk::style map Accent.TButton -foreground [list pressed "#c1d8ee" disabled "#ffffff"]
|
||||
|
||||
ttk::style element create AccentButton.button image \
|
||||
[list $I(button-accent-rest) \
|
||||
{selected disabled} $I(button-accent-dis) \
|
||||
disabled $I(button-accent-dis) \
|
||||
selected $I(button-accent-rest) \
|
||||
pressed $I(button-accent-pressed) \
|
||||
{active focus} $I(button-accent-focus-hover) \
|
||||
active $I(button-accent-hover) \
|
||||
focus $I(button-accent-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Menubutton
|
||||
ttk::style layout TMenubutton {
|
||||
Menubutton.button -children {
|
||||
Menubutton.padding -children {
|
||||
Menubutton.label -side left -expand 1
|
||||
Menubutton.indicator -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TMenubutton -padding {8 2 13 3}
|
||||
|
||||
ttk::style element create Menubutton.button image \
|
||||
[list $I(button-rest) \
|
||||
disabled $I(button-dis) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
ttk::style element create Menubutton.indicator image $I(down) -width 10 -sticky e
|
||||
|
||||
# OptionMenu
|
||||
ttk::style layout TOptionMenu {
|
||||
OptionMenu.button -children {
|
||||
OptionMenu.padding -children {
|
||||
OptionMenu.label -side left -expand 1
|
||||
OptionMenu.indicator -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TOptionMenu -padding {8 2 13 3}
|
||||
|
||||
ttk::style element create OptionMenu.button image \
|
||||
[list $I(button-rest) \
|
||||
disabled $I(button-dis) \
|
||||
pressed $I(button-pressed) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
ttk::style element create OptionMenu.indicator image $I(down) -width 10 -sticky e
|
||||
|
||||
# Checkbutton
|
||||
ttk::style layout TCheckbutton {
|
||||
Checkbutton.button -children {
|
||||
Checkbutton.padding -children {
|
||||
Checkbutton.indicator -side left
|
||||
Checkbutton.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TCheckbutton -padding 4
|
||||
|
||||
ttk::style element create Checkbutton.indicator image \
|
||||
[list $I(check-unsel-rest) \
|
||||
{alternate disabled} $I(check-tri-dis) \
|
||||
{selected disabled} $I(check-dis) \
|
||||
disabled $I(check-unsel-dis) \
|
||||
{pressed alternate} $I(check-tri-hover) \
|
||||
{active focus alternate} $I(check-tri-focus-hover) \
|
||||
{active alternate} $I(check-tri-hover) \
|
||||
{focus alternate} $I(check-tri-focus) \
|
||||
alternate $I(check-tri-rest) \
|
||||
{pressed selected} $I(check-hover) \
|
||||
{active focus selected} $I(check-focus-hover) \
|
||||
{active selected} $I(check-hover) \
|
||||
{focus selected} $I(check-focus) \
|
||||
selected $I(check-rest) \
|
||||
{pressed !selected} $I(check-unsel-pressed) \
|
||||
{active focus} $I(check-unsel-focus-hover) \
|
||||
active $I(check-unsel-hover) \
|
||||
focus $I(check-unsel-focus) \
|
||||
] -width 26 -sticky w
|
||||
|
||||
# Switch.TCheckbutton
|
||||
ttk::style layout Switch.TCheckbutton {
|
||||
Switch.button -children {
|
||||
Switch.padding -children {
|
||||
Switch.indicator -side left
|
||||
Switch.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Switch.indicator image \
|
||||
[list $I(switch-off-rest) \
|
||||
{selected disabled} $I(switch-dis) \
|
||||
disabled $I(switch-off-dis) \
|
||||
{pressed selected} $I(switch-pressed) \
|
||||
{active focus selected} $I(switch-focus-hover) \
|
||||
{active selected} $I(switch-hover) \
|
||||
{focus selected} $I(switch-focus) \
|
||||
selected $I(switch-rest) \
|
||||
{pressed !selected} $I(switch-off-pressed) \
|
||||
{active focus} $I(switch-off-focus-hover) \
|
||||
active $I(switch-off-hover) \
|
||||
focus $I(switch-off-focus) \
|
||||
] -width 46 -sticky w
|
||||
|
||||
# Toggle.TButton
|
||||
ttk::style layout Toggle.TButton {
|
||||
ToggleButton.button -children {
|
||||
ToggleButton.padding -children {
|
||||
ToggleButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure Toggle.TButton -padding {8 2 8 3} -anchor center -foreground $colors(-fg)
|
||||
|
||||
ttk::style map Toggle.TButton -foreground \
|
||||
[list {selected disabled} "#ffffff" \
|
||||
{selected pressed} "#636363" \
|
||||
selected "#ffffff" \
|
||||
pressed "#c1d8ee" \
|
||||
disabled "#a2a2a2" \
|
||||
active "#1a1a1a"
|
||||
]
|
||||
|
||||
ttk::style element create ToggleButton.button image \
|
||||
[list $I(button-rest) \
|
||||
{selected disabled} $I(button-accent-dis) \
|
||||
disabled $I(button-dis) \
|
||||
{pressed selected} $I(button-rest) \
|
||||
{active focus selected} $I(button-accent-focus-hover) \
|
||||
{active selected} $I(button-accent-hover) \
|
||||
{focus selected} $I(button-accent-focus) \
|
||||
selected $I(button-accent-rest) \
|
||||
{pressed !selected} $I(button-accent-rest) \
|
||||
{active focus} $I(button-focus-hover) \
|
||||
active $I(button-hover) \
|
||||
focus $I(button-focus) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Radiobutton
|
||||
ttk::style layout TRadiobutton {
|
||||
Radiobutton.button -children {
|
||||
Radiobutton.padding -children {
|
||||
Radiobutton.indicator -side left
|
||||
Radiobutton.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TRadiobutton -padding 4
|
||||
|
||||
ttk::style element create Radiobutton.indicator image \
|
||||
[list $I(radio-unsel-rest) \
|
||||
{selected disabled} $I(radio-dis) \
|
||||
disabled $I(radio-unsel-dis) \
|
||||
{pressed selected} $I(radio-pressed) \
|
||||
{active focus selected} $I(radio-focus-hover) \
|
||||
{active selected} $I(radio-hover) \
|
||||
{focus selected} $I(radio-focus) \
|
||||
selected $I(radio-rest) \
|
||||
{pressed !selected} $I(radio-unsel-pressed) \
|
||||
{active focus} $I(radio-unsel-focus-hover) \
|
||||
active $I(radio-unsel-hover) \
|
||||
focus $I(radio-unsel-focus) \
|
||||
] -width 26 -sticky w
|
||||
|
||||
# Entry
|
||||
ttk::style configure TEntry -foreground $colors(-fg) -padding {6 1 4 2}
|
||||
ttk::style map TEntry -foreground [list disabled $colors(-disfg) pressed "#636363" active "#626262"]
|
||||
|
||||
ttk::style element create Entry.field image \
|
||||
[list $I(textbox-rest) \
|
||||
{focus hover !invalid} $I(textbox-focus) \
|
||||
invalid $I(textbox-error) \
|
||||
disabled $I(textbox-dis) \
|
||||
{focus !invalid} $I(textbox-focus) \
|
||||
hover $I(textbox-hover) \
|
||||
] -border 5 -sticky nsew
|
||||
|
||||
# Combobox
|
||||
ttk::style layout TCombobox {
|
||||
Combobox.field -sticky nsew -children {
|
||||
Combobox.arrow -side right -sticky ns
|
||||
Combobox.padding -sticky nsew -children {
|
||||
Combobox.textarea -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TCombobox -foreground $colors(-fg) -padding {6 1 0 2}
|
||||
ttk::style configure ComboboxPopdownFrame -borderwidth 1 -relief solid
|
||||
ttk::style map TCombobox -foreground [list disabled $colors(-disfg) pressed "#636363" active "#626262"]
|
||||
|
||||
ttk::style map TCombobox -selectbackground [list \
|
||||
{readonly hover} $colors(-selbg) \
|
||||
{readonly focus} $colors(-selbg) \
|
||||
] -selectforeground [list \
|
||||
{readonly hover} $colors(-selfg) \
|
||||
{readonly focus} $colors(-selfg) \
|
||||
]
|
||||
|
||||
ttk::style element create Combobox.field image \
|
||||
[list $I(textbox-rest) \
|
||||
{readonly focus} $I(button-focus) \
|
||||
{readonly disabled} $I(button-dis) \
|
||||
{readonly pressed} $I(button-pressed) \
|
||||
{readonly hover} $I(button-hover) \
|
||||
readonly $I(button-rest) \
|
||||
{focus hover !invalid} $I(textbox-focus) \
|
||||
invalid $I(textbox-error) \
|
||||
disabled $I(textbox-dis) \
|
||||
focus $I(textbox-focus) \
|
||||
{focus !invalid} $I(textbox-focus) \
|
||||
hover $I(textbox-hover) \
|
||||
] -border 5
|
||||
|
||||
ttk::style element create Combobox.arrow image $I(down) -width 34 -sticky {}
|
||||
|
||||
# Spinbox
|
||||
ttk::style layout TSpinbox {
|
||||
Spinbox.field -side top -sticky we -children {
|
||||
Spinbox.downarrow -side right -sticky ns
|
||||
Spinbox.uparrow -side right -sticky ns
|
||||
Spinbox.padding -sticky nswe -children {
|
||||
Spinbox.textarea -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TSpinbox -foreground $colors(-fg) -padding {6 1 0 2}
|
||||
ttk::style map TSpinbox -foreground [list disabled $colors(-disfg) pressed "#636363" active "#626262"]
|
||||
|
||||
ttk::style element create Spinbox.field image \
|
||||
[list $I(textbox-rest) \
|
||||
{focus hover !invalid} $I(textbox-focus) \
|
||||
invalid $I(textbox-error) \
|
||||
disabled $I(textbox-dis) \
|
||||
focus $I(textbox-focus) \
|
||||
{focus !invalid} $I(textbox-focus) \
|
||||
hover $I(textbox-hover) \
|
||||
] -border 5 -sticky nsew
|
||||
|
||||
ttk::style element create Spinbox.uparrow image $I(up) -width 34 -height 16 -sticky {}
|
||||
ttk::style element create Spinbox.downarrow image $I(down) -width 34 -height 16 -sticky {}
|
||||
|
||||
# Progressbar
|
||||
ttk::style element create Horizontal.Progressbar.trough image $I(progressbar-trough-hor) \
|
||||
-border 1 -sticky ew
|
||||
ttk::style element create Horizontal.Progressbar.pbar image $I(progressbar-bar-hor) \
|
||||
-border 2 -sticky ew
|
||||
|
||||
ttk::style element create Vertical.Progressbar.trough image $I(progressbar-trough-vert) \
|
||||
-border 1 -sticky ns
|
||||
ttk::style element create Vertical.Progressbar.pbar image $I(progressbar-bar-vert) \
|
||||
-border 2 -sticky ns
|
||||
|
||||
# Scale
|
||||
ttk::style element create Horizontal.Scale.trough image $I(slider-trough-hor) \
|
||||
-border 5 -padding 0 -sticky {ew}
|
||||
|
||||
ttk::style element create Vertical.Scale.trough image $I(slider-trough-vert) \
|
||||
-border 5 -padding 0 -sticky {ns}
|
||||
|
||||
ttk::style element create Scale.slider image \
|
||||
[list $I(slider-thumb-rest) \
|
||||
disabled $I(slider-thumb-dis) \
|
||||
pressed $I(slider-thumb-pressed) \
|
||||
{active focus} $I(slider-thumb-focus-hover) \
|
||||
active $I(slider-thumb-hover) \
|
||||
focus $I(slider-thumb-focus) \
|
||||
] -sticky {}
|
||||
|
||||
# Scrollbar
|
||||
ttk::style layout Vertical.TScrollbar {
|
||||
Vertical.Scrollbar.trough -sticky ns -children {
|
||||
Vertical.Scrollbar.uparrow -side top
|
||||
Vertical.Scrollbar.downarrow -side bottom
|
||||
Vertical.Scrollbar.thumb -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Horizontal.TScrollbar {
|
||||
Horizontal.Scrollbar.trough -sticky ew -children {
|
||||
Horizontal.Scrollbar.leftarrow -side left
|
||||
Horizontal.Scrollbar.rightarrow -side right
|
||||
Horizontal.Scrollbar.thumb -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Horizontal.Scrollbar.trough image $I(scrollbar-trough-hor) -sticky ew -border {6 0}
|
||||
ttk::style element create Horizontal.Scrollbar.thumb image $I(scrollbar-thumb-hor) -sticky ew -border {3 0}
|
||||
|
||||
ttk::style element create Horizontal.Scrollbar.rightarrow image $I(scrollbar-right) -sticky e -width 13
|
||||
ttk::style element create Horizontal.Scrollbar.leftarrow image $I(scrollbar-left) -sticky w -width 13
|
||||
|
||||
ttk::style element create Vertical.Scrollbar.trough image $I(scrollbar-trough-vert) -sticky ns -border {0 6}
|
||||
ttk::style element create Vertical.Scrollbar.thumb image $I(scrollbar-thumb-vert) -sticky ns -border {0 3}
|
||||
|
||||
ttk::style element create Vertical.Scrollbar.uparrow image $I(scrollbar-up) -sticky n -height 13
|
||||
ttk::style element create Vertical.Scrollbar.downarrow image $I(scrollbar-down) -sticky s -height 13
|
||||
|
||||
# Separator
|
||||
ttk::style element create Separator.separator image $I(sep) -width 1 -height 1
|
||||
|
||||
# Sizegrip
|
||||
ttk::style element create Sizegrip.sizegrip image $I(grip) -sticky nsew
|
||||
|
||||
# Card
|
||||
ttk::style layout Card.TFrame {
|
||||
Card.field {
|
||||
Card.padding -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Card.field image $I(card) -border 10 -padding 4 -sticky nsew
|
||||
|
||||
# Labelframe
|
||||
ttk::style layout TLabelframe {
|
||||
Labelframe.border {
|
||||
Labelframe.padding -expand 1 -children {
|
||||
Labelframe.label -side left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style element create Labelframe.border image $I(card) -border 5 -padding 4 -sticky nsew
|
||||
ttk::style configure TLabelframe.Label -font SunValleyCaptionFont
|
||||
|
||||
# Notebook
|
||||
ttk::style layout TNotebook {
|
||||
Notebook.border -children {
|
||||
TNotebook.Tab -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style configure TNotebook -padding 1
|
||||
ttk::style configure TNotebook.Tab -focuscolor $colors(-accent)
|
||||
ttk::style element create Notebook.border image $I(notebook-border) -border 5 -padding 5
|
||||
|
||||
ttk::style element create Notebook.tab image \
|
||||
[list $I(tab-rest) \
|
||||
selected $I(tab-selected) \
|
||||
active $I(tab-hover) \
|
||||
] -border 13 -padding {16 14 16 6} -height 32
|
||||
|
||||
# Treeview
|
||||
ttk::style configure Heading -font SunValleyCaptionFont
|
||||
ttk::style configure Treeview \
|
||||
-background $colors(-bg) \
|
||||
-rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 3}] \
|
||||
-font SunValleyBodyFont
|
||||
|
||||
ttk::style map Treeview -background {selected "#e7e7e7"} -foreground {selected "#191919"}
|
||||
|
||||
ttk::style element create Treeview.field image $I(card) -border 5 -width 0 -height 0
|
||||
ttk::style element create Treeheading.cell image \
|
||||
[list $I(heading-rest) \
|
||||
pressed $I(heading-pressed) \
|
||||
active $I(heading-hover)
|
||||
] -border 5 -padding 14 -sticky nsew
|
||||
|
||||
ttk::style element create Treeitem.indicator image \
|
||||
[list $I(right) \
|
||||
user2 $I(empty) \
|
||||
user1 $I(down) \
|
||||
] -width 26 -sticky {}
|
||||
|
||||
# Panedwindow
|
||||
ttk::style configure Sash \
|
||||
-lightcolor "#676767" \
|
||||
-darkcolor "#676767" \
|
||||
-bordercolor "#676767" \
|
||||
-sashthickness 4 \
|
||||
-gripcount 20
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
set ::spriteinfo [list \
|
||||
card 0 0 50 50 \
|
||||
notebook-border 50 0 40 40 \
|
||||
switch-dis 50 40 40 20 \
|
||||
switch-focus-hover 0 50 40 20 \
|
||||
switch-focus 0 70 40 20 \
|
||||
switch-hover 40 60 40 20 \
|
||||
switch-off-dis 90 0 40 20 \
|
||||
switch-off-focus-hover 90 20 40 20 \
|
||||
switch-off-focus 90 40 40 20 \
|
||||
switch-off-hover 80 60 40 20 \
|
||||
switch-off-pressed 0 90 40 20 \
|
||||
switch-off-rest 40 80 40 20 \
|
||||
switch-pressed 80 80 40 20 \
|
||||
switch-rest 0 110 40 20 \
|
||||
tab-hover 130 0 32 32 \
|
||||
tab-rest 130 32 32 32 \
|
||||
tab-selected 120 64 32 32 \
|
||||
heading-hover 40 100 22 22 \
|
||||
heading-pressed 62 100 22 22 \
|
||||
heading-rest 84 100 22 22 \
|
||||
slider-thumb-dis 106 100 22 22 \
|
||||
slider-thumb-focus-hover 128 96 22 22 \
|
||||
slider-thumb-focus 0 130 22 22 \
|
||||
slider-thumb-hover 22 130 22 22 \
|
||||
slider-thumb-pressed 44 122 22 22 \
|
||||
slider-thumb-rest 66 122 22 22 \
|
||||
slider-trough-hor 88 122 22 22 \
|
||||
slider-trough-vert 110 122 22 22 \
|
||||
button-accent-dis 132 118 20 20 \
|
||||
button-accent-focus-hover 0 152 20 20 \
|
||||
button-accent-focus 20 152 20 20 \
|
||||
button-accent-hover 40 152 20 20 \
|
||||
button-accent-pressed 60 144 20 20 \
|
||||
button-accent-rest 80 144 20 20 \
|
||||
button-dis 100 144 20 20 \
|
||||
button-focus-hover 120 144 20 20 \
|
||||
button-focus 140 138 20 20 \
|
||||
button-hover 162 0 20 20 \
|
||||
button-pressed 162 20 20 20 \
|
||||
button-rest 162 40 20 20 \
|
||||
check-dis 162 60 20 20 \
|
||||
check-focus-hover 150 96 20 20 \
|
||||
check-focus 152 116 20 20 \
|
||||
check-hover 160 136 20 20 \
|
||||
check-pressed 0 172 20 20 \
|
||||
check-rest 20 172 20 20 \
|
||||
check-tri-dis 40 172 20 20 \
|
||||
check-tri-focus-hover 160 156 20 20 \
|
||||
check-tri-focus 140 158 20 20 \
|
||||
check-tri-hover 60 164 20 20 \
|
||||
check-tri-pressed 80 164 20 20 \
|
||||
check-tri-rest 100 164 20 20 \
|
||||
check-unsel-dis 120 164 20 20 \
|
||||
check-unsel-focus-hover 182 0 20 20 \
|
||||
check-unsel-focus 182 20 20 20 \
|
||||
check-unsel-hover 182 40 20 20 \
|
||||
check-unsel-pressed 182 60 20 20 \
|
||||
check-unsel-rest 180 80 20 20 \
|
||||
progressbar-bar-hor 180 100 20 5 \
|
||||
progressbar-bar-vert 172 80 5 20 \
|
||||
progressbar-trough-hor 152 80 20 5 \
|
||||
progressbar-trough-vert 172 100 5 20 \
|
||||
radio-dis 180 105 20 20 \
|
||||
radio-focus-hover 180 125 20 20 \
|
||||
radio-focus 180 145 20 20 \
|
||||
radio-hover 180 165 20 20 \
|
||||
radio-pressed 160 176 20 20 \
|
||||
radio-rest 140 178 20 20 \
|
||||
radio-unsel-dis 0 192 20 20 \
|
||||
radio-unsel-focus-hover 20 192 20 20 \
|
||||
radio-unsel-focus 40 192 20 20 \
|
||||
radio-unsel-hover 180 185 20 20 \
|
||||
radio-unsel-pressed 60 184 20 20 \
|
||||
radio-unsel-rest 80 184 20 20 \
|
||||
scrollbar-thumb-hor 160 196 20 12 \
|
||||
scrollbar-thumb-vert 100 184 12 20 \
|
||||
scrollbar-trough-hor 112 198 20 12 \
|
||||
scrollbar-trough-vert 202 0 12 20 \
|
||||
textbox-dis 0 212 20 20 \
|
||||
textbox-error 20 212 20 20 \
|
||||
textbox-focus 40 212 20 20 \
|
||||
textbox-hover 60 210 20 20 \
|
||||
textbox-rest 80 210 20 20 \
|
||||
down 40 50 10 5 \
|
||||
empty 152 64 10 10 \
|
||||
grip 152 85 10 10 \
|
||||
right 162 85 5 10 \
|
||||
sep 202 20 10 10 \
|
||||
up 40 55 10 5 \
|
||||
scrollbar-down 132 138 8 6 \
|
||||
scrollbar-left 44 144 6 8 \
|
||||
scrollbar-right 50 144 6 8 \
|
||||
scrollbar-up 172 120 8 6 \
|
||||
]
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
set ::spriteinfo [list \
|
||||
card 0 0 50 50 \
|
||||
notebook-border 50 0 40 40 \
|
||||
switch-dis 50 40 40 20 \
|
||||
switch-focus-hover 0 50 40 20 \
|
||||
switch-focus 0 70 40 20 \
|
||||
switch-hover 40 60 40 20 \
|
||||
switch-off-dis 90 0 40 20 \
|
||||
switch-off-focus-hover 90 20 40 20 \
|
||||
switch-off-focus 90 40 40 20 \
|
||||
switch-off-hover 80 60 40 20 \
|
||||
switch-off-pressed 0 90 40 20 \
|
||||
switch-off-rest 40 80 40 20 \
|
||||
switch-pressed 80 80 40 20 \
|
||||
switch-rest 0 110 40 20 \
|
||||
tab-hover 130 0 32 32 \
|
||||
tab-rest 130 32 32 32 \
|
||||
tab-selected 120 64 32 32 \
|
||||
heading-hover 40 100 22 22 \
|
||||
heading-pressed 62 100 22 22 \
|
||||
heading-rest 84 100 22 22 \
|
||||
slider-thumb-dis 106 100 22 22 \
|
||||
slider-thumb-focus-hover 128 96 22 22 \
|
||||
slider-thumb-focus 0 130 22 22 \
|
||||
slider-thumb-hover 22 130 22 22 \
|
||||
slider-thumb-pressed 44 122 22 22 \
|
||||
slider-thumb-rest 66 122 22 22 \
|
||||
slider-trough-hor 88 122 22 22 \
|
||||
slider-trough-vert 110 122 22 22 \
|
||||
button-accent-dis 132 118 20 20 \
|
||||
button-accent-focus-hover 0 152 20 20 \
|
||||
button-accent-focus 20 152 20 20 \
|
||||
button-accent-hover 40 152 20 20 \
|
||||
button-accent-pressed 60 144 20 20 \
|
||||
button-accent-rest 80 144 20 20 \
|
||||
button-dis 100 144 20 20 \
|
||||
button-focus-hover 120 144 20 20 \
|
||||
button-focus 140 138 20 20 \
|
||||
button-hover 162 0 20 20 \
|
||||
button-pressed 162 20 20 20 \
|
||||
button-rest 162 40 20 20 \
|
||||
check-dis 162 60 20 20 \
|
||||
check-focus-hover 150 96 20 20 \
|
||||
check-focus 152 116 20 20 \
|
||||
check-hover 160 136 20 20 \
|
||||
check-pressed 0 172 20 20 \
|
||||
check-rest 20 172 20 20 \
|
||||
check-tri-dis 40 172 20 20 \
|
||||
check-tri-focus-hover 160 156 20 20 \
|
||||
check-tri-focus 140 158 20 20 \
|
||||
check-tri-hover 60 164 20 20 \
|
||||
check-tri-pressed 80 164 20 20 \
|
||||
check-tri-rest 100 164 20 20 \
|
||||
check-unsel-dis 120 164 20 20 \
|
||||
check-unsel-focus-hover 182 0 20 20 \
|
||||
check-unsel-focus 182 20 20 20 \
|
||||
check-unsel-hover 182 40 20 20 \
|
||||
check-unsel-pressed 182 60 20 20 \
|
||||
check-unsel-rest 180 80 20 20 \
|
||||
progressbar-bar-hor 180 100 20 5 \
|
||||
progressbar-bar-vert 172 80 5 20 \
|
||||
progressbar-trough-hor 152 80 20 5 \
|
||||
progressbar-trough-vert 172 100 5 20 \
|
||||
radio-dis 180 105 20 20 \
|
||||
radio-focus-hover 180 125 20 20 \
|
||||
radio-focus 180 145 20 20 \
|
||||
radio-hover 180 165 20 20 \
|
||||
radio-pressed 160 176 20 20 \
|
||||
radio-rest 140 178 20 20 \
|
||||
radio-unsel-dis 0 192 20 20 \
|
||||
radio-unsel-focus-hover 20 192 20 20 \
|
||||
radio-unsel-focus 40 192 20 20 \
|
||||
radio-unsel-hover 180 185 20 20 \
|
||||
radio-unsel-pressed 60 184 20 20 \
|
||||
radio-unsel-rest 80 184 20 20 \
|
||||
scrollbar-thumb-hor 160 196 20 12 \
|
||||
scrollbar-thumb-vert 100 184 12 20 \
|
||||
scrollbar-trough-hor 112 198 20 12 \
|
||||
scrollbar-trough-vert 202 0 12 20 \
|
||||
textbox-dis 0 212 20 20 \
|
||||
textbox-error 20 212 20 20 \
|
||||
textbox-focus 40 212 20 20 \
|
||||
textbox-hover 60 210 20 20 \
|
||||
textbox-rest 80 210 20 20 \
|
||||
down 40 50 10 5 \
|
||||
empty 152 64 10 10 \
|
||||
grip 152 85 10 10 \
|
||||
right 162 85 5 10 \
|
||||
sep 202 20 10 10 \
|
||||
up 40 55 10 5 \
|
||||
scrollbar-down 132 138 8 6 \
|
||||
scrollbar-left 44 144 6 8 \
|
||||
scrollbar-right 50 144 6 8 \
|
||||
scrollbar-up 172 120 8 6 \
|
||||
]
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
+132
-30
@@ -3,7 +3,11 @@
|
||||
|
||||
Usage: gen.py --exefs build/extracted/v121/exefs --out generated/v121 [--modules main,subsdk0,sdk] [--jobs N]
|
||||
[--limit N] [--chunk-fns N] [--chunk-bytes B] [--big-fn B] [--patches FILE] [--v-locals K [--v-trust]]
|
||||
[--no-cache] [--fn-enter-all]
|
||||
[--no-cache] [--fn-enter-all] [--plugins NSO[,NSO...]]
|
||||
|
||||
--plugins places a mod's code modules (exlaunch plugins) after sdk as plugin0..N (recomp/layout.py) and lifts them with
|
||||
the game modules; their DT_INIT and init_array entries are seeds too (Module.init_functions). Without it the output is
|
||||
what it was before plugins existed.
|
||||
|
||||
Output, under --out:
|
||||
layout.h, layout.json module bases (recomp/layout.py)
|
||||
@@ -63,8 +67,8 @@ import patches # noqa: E402
|
||||
import regs # noqa: E402
|
||||
import vlocals # noqa: E402
|
||||
from check_content import GENERATED_MARKER # noqa: E402
|
||||
from layout import layout, write as write_layout # noqa: E402
|
||||
from lifter import hx # noqa: E402
|
||||
from layout import layout, plugin_files, write as write_layout # noqa: E402
|
||||
from lifter import Insn, hx # noqa: E402
|
||||
from module import Module # noqa: E402
|
||||
|
||||
TERMINATORS = ('b', 'br', 'ret', 'trap')
|
||||
@@ -85,6 +89,30 @@ def fname(a):
|
||||
return f'f_{a:x}'
|
||||
|
||||
|
||||
def orig_name(a):
|
||||
"""The unpatched copy of the function at a that a plugin's replace hook reaches as its original (patches.py `orig`)."""
|
||||
return f'fo_{a:x}'
|
||||
|
||||
|
||||
def open_module(name, path, base, table, plugin=False):
|
||||
"""Module name for lifting: a plugin with a `plugin` line of the patch table (recomp/patches.py) is lifted from its
|
||||
image after the init, its inline-hook stubs returning where they would branch to their trampolines."""
|
||||
p = table.plugins.get(name)
|
||||
if not p:
|
||||
return Module(name, path, base, 'c', plugin=plugin)
|
||||
image = Path(p['image']).read_bytes()
|
||||
mod = Module(name, path, base, 'c', plugin=True, image=image, rets=[o + 12 for o in p['stubs']],
|
||||
seeds=sorted(p['stubs'] | p['seeds']))
|
||||
t0, t1 = mod.nso.text[0], mod.nso.text[0] + mod.nso.text[1]
|
||||
if hashlib.sha256(image[t0:t1]).hexdigest() != p['sha256']:
|
||||
raise patches.PatchError(f'{name}: {p["image"]} is not the image whose .text the patch table names')
|
||||
for o in p['stubs']:
|
||||
w = int.from_bytes(image[o + 12:o + 16], 'little')
|
||||
if not mod.in_text(base + o) or w >> 26 != 0x05:
|
||||
raise patches.PatchError(f'{name}+{o:#x}: no inline-hook stub (its fourth word {w:08x} is no b)')
|
||||
return mod
|
||||
|
||||
|
||||
def header(what):
|
||||
return f'// {GENERATED_MARKER}: {what}, generated by recomp/gen.py from game code. Do not edit or commit.\n'
|
||||
|
||||
@@ -229,11 +257,13 @@ class Emitter:
|
||||
the C (an argument here, or anything else it reads) must go into the lift cache's key: chunk_key."""
|
||||
|
||||
def __init__(self, mod, starts, patched=None, reg_locals=regs.LOCALS, callee_saved=True, spins=None,
|
||||
v_locals=vlocals.LOCALS, v_trust=False, hooks=None, fn_enter_all=False):
|
||||
v_locals=vlocals.LOCALS, v_trust=False, hooks=None, fn_enter_all=False, picks=None, origs=None):
|
||||
self.mod = mod
|
||||
self.starts = starts
|
||||
self.patched = patched or {} # {address: [(set index, [replacement words])]} (recomp/patches.py)
|
||||
self.picks = picks or {} # {contested site: (pick index, {ordered set: value})} (recomp/patches.py)
|
||||
self.spins = spins or {} # {spin wait back-edge: its head} (recomp/patches.py `spin`)
|
||||
self.origs = origs or set() # functions also emitted unpatched, as orig_name() (recomp/patches.py `orig`)
|
||||
self.reg_locals = reg_locals # recomp/regs.py: registers per function in C locals
|
||||
self.kept = regs.CALLEE_SAVED if callee_saved else frozenset() # not reloaded after a call
|
||||
self.v_locals = v_locals # recomp/vlocals.py: V registers per function in C locals (0: all in c->v)
|
||||
@@ -241,6 +271,7 @@ class Emitter:
|
||||
# Functions that start with FN_ENTER (recomp/patches.py `hook`): None is every function
|
||||
self.hooks = None if fn_enter_all else hooks
|
||||
self.uses_patches = False
|
||||
self.uses_picks = False
|
||||
self.stats = Counter()
|
||||
self.unsupported = Counter()
|
||||
|
||||
@@ -288,9 +319,12 @@ class Emitter:
|
||||
alternative may branch (bl, b, b.cond / cbz / tbz, ret)."""
|
||||
out = []
|
||||
for _, words in self.patched[a]:
|
||||
lifted = [self.mod.lifter.lift(w, a) for w in words]
|
||||
# ('call', target): a plugin's inline hook (recomp/patches.py @call), before the site's own instruction
|
||||
lifted = [Insn('hook', target=w[1]) if isinstance(w, tuple) else self.mod.lifter.lift(w, a) for w in words]
|
||||
for j, r in enumerate(lifted):
|
||||
last = j == len(lifted) - 1
|
||||
if r.kind == 'hook' and not last:
|
||||
continue
|
||||
if r.kind != 'op' and not (last and r.kind in ('bl', 'b', 'bcond', 'ret')):
|
||||
raise patches.PatchError(f'{a:#x}: replacement word {words[j]:08x} is a {r.kind}')
|
||||
out.append(lifted)
|
||||
@@ -369,6 +403,22 @@ class Emitter:
|
||||
raise patches.PatchError(f'{a:#x}: a patched call that uses flags')
|
||||
return reads, alts[0][1]
|
||||
|
||||
def unpatched_copy(self, entry, end, refs):
|
||||
"""C of the function [entry, end) without its patched sites, named orig_name(entry): what a plugin's replace
|
||||
hook calls as the original (its trampoline, recomp/patches.py `orig`). Its own fall-back fb_ is renamed too."""
|
||||
kept = self.patched
|
||||
self.patched = {a: alts for a, alts in kept.items() if not entry <= a < end}
|
||||
try:
|
||||
lines, r = self.function(entry, end)
|
||||
finally:
|
||||
self.patched = kept
|
||||
refs |= r
|
||||
text = '\n'.join(lines).replace(f'fb_{entry:x}(', f'fbo_{entry:x}(')
|
||||
head = f'void {fname(entry)}(Cpu *c) {{'
|
||||
if head not in text:
|
||||
raise patches.PatchError(f'{entry:#x}: no function head to rename for its unpatched copy')
|
||||
return text.replace(head, f'void {orig_name(entry)}(Cpu *c) {{', 1)
|
||||
|
||||
def function(self, entry, end):
|
||||
"""(lines of C, referenced function starts) for the guest function [entry, end)."""
|
||||
mod, starts = self.mod, self.starts
|
||||
@@ -451,16 +501,26 @@ class Emitter:
|
||||
return f'if ({fx(i, r.cond)}) {{ {jump(r.target, i)} }}'
|
||||
if r.kind == 'ret':
|
||||
return f'{spill}return;'
|
||||
if r.kind == 'hook':
|
||||
# a call that writes no x30, the whole Cpu current before it and read back after it: the stub saves and
|
||||
# restores x30 itself, and the callback may change any register through exlaunch's hook context
|
||||
refs.add(r.target)
|
||||
self.stats['plugin_hook_calls'] += 1
|
||||
return f'{spill}{fname(r.target)}(c);{reload}'
|
||||
raise patches.PatchError(f'{a:#x}: patched instruction is a {r.kind}')
|
||||
|
||||
def patch(i, ins, a):
|
||||
"""if (switch) { replacement } else if ... else { original } for a patched site (recomp/patches.py)."""
|
||||
"""if (switch) { replacement } else if ... else { original } for a patched site (recomp/patches.py); an
|
||||
ordered set of a contested site tests the site's pick byte instead of its switch."""
|
||||
if ins.kind not in ('op', 'bl', 'b', 'bcond'):
|
||||
raise patches.PatchError(f'{a:#x}: patched instruction is a {ins.kind}')
|
||||
line = ' '
|
||||
n, values = self.picks.get(a, (None, {}))
|
||||
for (k, _), words in zip(self.patched[a], self.replacements(a)):
|
||||
line += f' if (rt_patch_on[{k}]) {{ {" ".join(one(i, r, a) for r in words)} }} else'
|
||||
test = f'rt_patch_pick[{n}] == {values[k]}' if k in values else f'rt_patch_on[{k}]'
|
||||
line += f' if ({test}) {{ {" ".join(one(i, r, a) for r in words)} }} else'
|
||||
self.uses_patches = True
|
||||
self.uses_picks |= bool(values)
|
||||
self.stats['patched_sites'] += 1
|
||||
return f'{line} {{ {one(i, ins, a)} }}'
|
||||
|
||||
@@ -537,15 +597,19 @@ class Emitter:
|
||||
def chunk_text(name, number, emitter, fns):
|
||||
"""C text of one chunk. fns: [(entry, end)]."""
|
||||
body, refs = [], set()
|
||||
emitter.uses_patches = False
|
||||
emitter.uses_patches = emitter.uses_picks = False
|
||||
for entry, end in fns:
|
||||
lines, r = emitter.function(entry, end)
|
||||
body.append('\n'.join(lines))
|
||||
refs |= r
|
||||
if entry in emitter.origs:
|
||||
body.append(emitter.unpatched_copy(entry, end, refs))
|
||||
# Every referenced function gets a prototype, including ones defined later in this chunk.
|
||||
protos = ''.join(f'void {fname(r)}(Cpu *c);\n' for r in sorted(refs))
|
||||
if emitter.uses_patches:
|
||||
protos += 'extern uint8_t rt_patch_on[];\n'
|
||||
if emitter.uses_picks:
|
||||
protos += 'extern uint8_t rt_patch_pick[];\n'
|
||||
vdef = '#define RT_VLOCALS 1\n' if emitter.v_locals else '' # runtime/simd.h: the V-locals accessors
|
||||
return (header(f'{name} chunk {number:04d}') + vdef + '#include "cpu.h"\n#include "simd.h"\n\n' + protos
|
||||
+ '\n' + '\n\n'.join(body) + '\n')
|
||||
@@ -606,7 +670,7 @@ def _emitter(name):
|
||||
e = _W['emitters'].get(name)
|
||||
if e is None:
|
||||
path, base = _W['mods'][name]
|
||||
mod = Module(name, path, base, 'c')
|
||||
mod = open_module(name, path, base, _W['patches'])
|
||||
# Module.read is how the jump tables (recomp/jumptables.py _eval) read .text and .rodata at lift time: the
|
||||
# bytes it returns become part of the generated code, so <mod>/folded.txt lists them
|
||||
read, reads = mod.read, _W['reads'].setdefault(name, [])
|
||||
@@ -618,7 +682,9 @@ def _emitter(name):
|
||||
e = _W['emitters'][name] = Emitter(mod, set(_W['starts'][name].tolist()),
|
||||
_W['patches'].for_module(name, base),
|
||||
spins=_W['patches'].spins_for(name, base),
|
||||
hooks=_W['patches'].hooks_for(name, base), **_W['opts'])
|
||||
hooks=_W['patches'].hooks_for(name, base),
|
||||
picks=_W['patches'].picks_for(name, base),
|
||||
origs=_W['patches'].origs_for(name, base), **_W['opts'])
|
||||
return e
|
||||
|
||||
|
||||
@@ -663,13 +729,19 @@ def _emit_chunk(task):
|
||||
|
||||
# ------------------------------------------------------------------------------------------------ driver
|
||||
|
||||
def table_text(name, addrs):
|
||||
def table_text(name, addrs, extra=None):
|
||||
"""<mod>_table.c: the function starts and their C; extra {address: C function name} adds entries of functions
|
||||
lifted elsewhere (a plugin's trampoline reaching the unpatched copy of a game function, recomp/patches.py `orig`)."""
|
||||
extra = extra or {}
|
||||
names = {a: fname(a) for a in addrs if a not in extra}
|
||||
names.update(extra)
|
||||
addrs = sorted(names)
|
||||
lines = [header(f'{name} function table'), '#include "cpu.h"\n\n']
|
||||
lines += [f'void {fname(a)}(Cpu *c);\n' for a in addrs]
|
||||
lines += [f'void {names[a]}(Cpu *c);\n' for a in addrs]
|
||||
lines.append(f'\nconst uint64_t {name}_fn_addrs[] = {{\n')
|
||||
lines.append(',\n'.join(hx(a) for a in addrs))
|
||||
lines.append(f'\n}};\nconst GuestFn {name}_fn_ptrs[] = {{\n')
|
||||
lines.append(',\n'.join(fname(a) for a in addrs))
|
||||
lines.append(',\n'.join(names[a] for a in addrs))
|
||||
lines.append(f'\n}};\nconst uint64_t {name}_fn_count = {len(addrs)};\n')
|
||||
return ''.join(lines)
|
||||
|
||||
@@ -733,16 +805,23 @@ def in_span(addrs, lo, hi):
|
||||
return addrs[bisect.bisect_left(addrs, lo):bisect.bisect_left(addrs, hi)]
|
||||
|
||||
|
||||
def chunk_key(mod_key, number, fns, patched, site_addrs, spins, spin_addrs, hook_addrs):
|
||||
def chunk_key(mod_key, number, fns, patched, site_addrs, spins, spin_addrs, hook_addrs, picks=None, origs=None):
|
||||
"""Key of one chunk: its module, number (in its header) and functions, and the patch sites (set index and
|
||||
replacement words, @page resolved, so the patch page is in them), spin waits and hooked functions inside its
|
||||
address range; hook_addrs None (FN_ENTER in every function) keys apart from an empty list. Every input of the
|
||||
chunk text that is not in generator_key or module_key must be added here, with a case in
|
||||
tests/lift_cache_test.py."""
|
||||
replacement words, @page resolved, so the patch page is in them), the pick index and values of its contested
|
||||
sites, spin waits and hooked functions inside its address range; hook_addrs None (FN_ENTER in every function) keys
|
||||
apart from an empty list. Every input of the chunk text that is not in generator_key or module_key must be added
|
||||
here, with a case in tests/lift_cache_test.py."""
|
||||
lo, hi = fns[0][0], fns[-1][1]
|
||||
sites = [[a, [[k, words] for k, words in patched[a]]] for a in in_span(site_addrs, lo, hi)]
|
||||
in_chunk = in_span(site_addrs, lo, hi)
|
||||
sites = [[a, [[k, [list(w) if isinstance(w, tuple) else w for w in words]] for k, words in patched[a]]]
|
||||
for a in in_chunk]
|
||||
hooks = None if hook_addrs is None else in_span(hook_addrs, lo, hi)
|
||||
return _key(mod_key, number, fns, sites, [[b, spins[b]] for b in in_span(spin_addrs, lo, hi)], hooks)
|
||||
contested = [[a, picks[a][0], sorted(picks[a][1].items())] for a in in_chunk if a in (picks or {})]
|
||||
parts = [mod_key, number, fns, sites, [[b, spins[b]] for b in in_span(spin_addrs, lo, hi)], hooks, contested]
|
||||
copies = [e for e, _ in fns if e in (origs or ())]
|
||||
if copies: # none: the key it had before plugins
|
||||
parts.append(copies)
|
||||
return _key(*parts)
|
||||
|
||||
|
||||
def _entry_check(file, entry):
|
||||
@@ -842,7 +921,10 @@ def main():
|
||||
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
ap.add_argument('--exefs', type=Path, required=True)
|
||||
ap.add_argument('--out', type=Path, required=True)
|
||||
ap.add_argument('--modules', default='main,subsdk0,sdk')
|
||||
ap.add_argument('--modules', default='main,subsdk0,sdk', help='modules to lift (default main,subsdk0,sdk and every '
|
||||
'--plugins module)')
|
||||
ap.add_argument('--plugins', default='', help='comma-separated plugin NSOs (exefs/subsdk* of a mod), in mod load '
|
||||
'order: lifted as plugin0..N after sdk')
|
||||
ap.add_argument('--jobs', type=int, help='emit workers (default: by free memory and CPU count)')
|
||||
ap.add_argument('--limit', type=int, default=0, help='emit only the first N functions of each module')
|
||||
ap.add_argument('--chunk-fns', type=int, default=3000, help='functions per chunk at most')
|
||||
@@ -876,11 +958,13 @@ def main():
|
||||
gen_key = generator_key(opts)
|
||||
|
||||
t0 = time.perf_counter()
|
||||
mods = layout(args.exefs)
|
||||
write_layout(mods, args.out)
|
||||
plugins = [Path(p) for p in args.plugins.split(',') if p]
|
||||
mods = layout(args.exefs, plugins)
|
||||
files = plugin_files(plugins)
|
||||
write_layout(mods, args.out, files)
|
||||
table = patches.load(args.patches, mods) if args.patches else patches.Table()
|
||||
write_if_changed(args.out / 'patches.h', patches.header_text(table, GENERATED_MARKER))
|
||||
want = args.modules.split(',')
|
||||
want = args.modules.split(',') + list(files)
|
||||
unknown = set(want) - {n for n, _, _ in mods}
|
||||
if unknown:
|
||||
raise SystemExit(f'not in {args.exefs}: {", ".join(sorted(unknown))}')
|
||||
@@ -890,8 +974,8 @@ def main():
|
||||
if name not in want:
|
||||
continue
|
||||
t = time.perf_counter()
|
||||
path = args.exefs / name
|
||||
mod = Module(name, path, base, 'c')
|
||||
path = Path(files[name][0]) if name in files else args.exefs / name
|
||||
mod = open_module(name, path, base, table, plugin=name in files)
|
||||
patches.check(table, mod, name)
|
||||
starts, dstats = discover(mod)
|
||||
est = estimate_sizes(mod, starts)
|
||||
@@ -901,8 +985,25 @@ def main():
|
||||
chunks = partition(est[:n], args.chunk_fns, args.chunk_bytes, args.big_fn)
|
||||
moddir = args.out / name
|
||||
moddir.mkdir(parents=True, exist_ok=True)
|
||||
extra = table.orig_entries(name, {n: b for n, b, _ in mods})
|
||||
if extra: # a trampoline reaches another function's unpatched copy, not a lift of its own words
|
||||
keep = ~np.isin(abs_starts, np.array(sorted(extra), dtype=abs_starts.dtype))
|
||||
starts, est, abs_starts = starts[keep], est[keep], abs_starts[keep]
|
||||
n = len(starts) if not args.limit else min(args.limit, len(starts))
|
||||
ends = np.append(abs_starts[1:], mod.hi)
|
||||
chunks = partition(est[:n], args.chunk_fns, args.chunk_bytes, args.big_fn)
|
||||
missing = sorted(base + o for o in (table.plugins.get(name) or {}).get('seeds', ())
|
||||
if base + o not in set(abs_starts.tolist()))
|
||||
if missing:
|
||||
raise SystemExit(f'{name}: the seeds {", ".join(hex(a) for a in missing)} are no function starts')
|
||||
mkey = module_key(gen_key, name, path, base, abs_starts)
|
||||
patched, spins = table.for_module(name, base), table.spins_for(name, base)
|
||||
if table.plugin_inputs(name):
|
||||
mkey = _key(mkey, table.plugin_inputs(name), _sha256(Path(table.plugins[name]['image']).read_bytes()))
|
||||
patched, spins, picks = table.for_module(name, base), table.spins_for(name, base), table.picks_for(name, base)
|
||||
origs = table.origs_for(name, base)
|
||||
bad = sorted(origs - set(abs_starts.tolist()))
|
||||
if bad:
|
||||
raise SystemExit(f'{args.patches}: orig {", ".join(hex(a) for a in bad)} is no function start of {name}')
|
||||
site_addrs, spin_addrs = sorted(patched), sorted(spins)
|
||||
hooks = None if args.fn_enter_all else table.hooks_for(name, base)
|
||||
stray = sorted(set(hooks or ()) - set(abs_starts.tolist()))
|
||||
@@ -912,11 +1013,11 @@ def main():
|
||||
hook_addrs = None if hooks is None else sorted(hooks)
|
||||
for number, (i0, i1) in enumerate(chunks):
|
||||
fns = list(zip(abs_starts[i0:i1].tolist(), ends[i0:i1].tolist()))
|
||||
key = chunk_key(mkey, number, fns, patched, site_addrs, spins, spin_addrs, hook_addrs)
|
||||
key = chunk_key(mkey, number, fns, patched, site_addrs, spins, spin_addrs, hook_addrs, picks, origs)
|
||||
tasks.append((int(est[i0:i1].sum()), (name, number, str(moddir / f'{name}_{number:04d}.c'), fns, key)))
|
||||
paths[name] = (str(path), base)
|
||||
starts_abs[name] = abs_starts
|
||||
info[name] = {'base': base, 'lo': mod.lo, 'hi': mod.hi, 'emitted': abs_starts[:n].tolist(),
|
||||
info[name] = {'base': base, 'lo': mod.lo, 'hi': mod.hi, 'emitted': abs_starts[:n].tolist(), 'extra': extra,
|
||||
'chunks': len(chunks), 'discover': dstats, 'discover_seconds': time.perf_counter() - t,
|
||||
'moddir': moddir}
|
||||
print(f'{name}: {dstats["functions"]} functions ({dstats["seeds"]} seeds, {dstats["rounds"]} rounds), '
|
||||
@@ -981,7 +1082,8 @@ def main():
|
||||
stats.update(r['stats'])
|
||||
unsupported.update(r['unsupported'])
|
||||
t = time.perf_counter()
|
||||
table_written = write_if_changed(moddir / f'{name}_table.c', table_text(name, d['emitted']))
|
||||
table_written = write_if_changed(moddir / f'{name}_table.c', table_text(
|
||||
name, d['emitted'], {t: orig_name(f) for t, f in d['extra'].items()}))
|
||||
write_if_changed(moddir / 'folded.txt', folded_text(name, merge_ranges(folded[name])))
|
||||
removed = remove_stale(moddir, name, d['chunks'], errors)
|
||||
manifest = {
|
||||
|
||||
+35
-13
@@ -6,9 +6,12 @@ calls layout() and writes the result into generated/<version>/layout.h and layou
|
||||
build read.
|
||||
|
||||
Modules are placed in Horizon's load order (rtld is dropped; the host links the modules):
|
||||
main, subsdk0..9, sdk. Each base is aligned to 2 MiB. Everything must stay below 2^39, the limit of the addresses
|
||||
IPC buffers can encode.
|
||||
main, subsdk0..9, sdk. A mod's code modules (exlaunch plugins such as an exefs/subsdk9) follow sdk as plugin0, plugin1,
|
||||
... in mod load order, so the game modules keep their bases with or without them (after the plugin design in #845 by
|
||||
itaskaev2). Each base is aligned to 2 MiB. Everything must stay below 2^39, the limit of the addresses IPC buffers can
|
||||
encode.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
@@ -24,14 +27,18 @@ def align_up(v, a=ALIGN):
|
||||
return (v + a - 1) & ~(a - 1)
|
||||
|
||||
|
||||
def layout(exefs):
|
||||
"""[(name, base, size)] for the modules present in the ExeFS directory, in load order."""
|
||||
def plugin_name(i):
|
||||
return f'plugin{i}'
|
||||
|
||||
|
||||
def layout(exefs, plugins=()):
|
||||
"""[(name, base, size)] for the modules present in the ExeFS directory, then the plugin NSOs (paths, in mod load
|
||||
order) as plugin0..N, in load order."""
|
||||
exefs = Path(exefs)
|
||||
paths = [(name, exefs / name) for name in ORDER if (exefs / name).exists()]
|
||||
paths += [(plugin_name(i), Path(p)) for i, p in enumerate(plugins)]
|
||||
out, base = [], FIRST_BASE
|
||||
for name in ORDER:
|
||||
path = exefs / name
|
||||
if not path.exists():
|
||||
continue
|
||||
for name, path in paths:
|
||||
size = Nso(str(path)).size
|
||||
out.append((name, base, size))
|
||||
base = align_up(base + size)
|
||||
@@ -40,12 +47,27 @@ def layout(exefs):
|
||||
return out
|
||||
|
||||
|
||||
def write(mods, outdir):
|
||||
"""layout.json for Python tools and layout.h for the runtime."""
|
||||
def plugin_files(plugins):
|
||||
"""{plugin<N>: (absolute path, SHA-256 of the NSO)} for layout.json: the build and the runtime read a plugin from its
|
||||
mod folder, not from the ExeFS directory, and check that it is the file the code was lifted from."""
|
||||
return {plugin_name(i): (Path(p).resolve().as_posix(), hashlib.sha256(Path(p).read_bytes()).hexdigest())
|
||||
for i, p in enumerate(plugins)}
|
||||
|
||||
|
||||
def write(mods, outdir, files=None):
|
||||
"""layout.json for Python tools and layout.h for the runtime. files: plugin_files() for the plugin entries, which
|
||||
carry them as "file" and "sha256"; without plugins both files are what they were before plugins existed."""
|
||||
files = files or {}
|
||||
outdir = Path(outdir)
|
||||
outdir.mkdir(parents=True, exist_ok=True)
|
||||
(outdir / 'layout.json').write_text(json.dumps(
|
||||
[{'name': n, 'base': f'{b:#x}', 'size': f'{s:#x}'} for n, b, s in mods], indent=1) + '\n')
|
||||
|
||||
def entry(n, b, s):
|
||||
e = {'name': n, 'base': f'{b:#x}', 'size': f'{s:#x}'}
|
||||
if n in files:
|
||||
e['file'], e['sha256'] = files[n]
|
||||
return e
|
||||
|
||||
(outdir / 'layout.json').write_text(json.dumps([entry(n, b, s) for n, b, s in mods], indent=1) + '\n')
|
||||
lines = ['// Module layout chosen by recomp/layout.py. Generated; do not edit.', '#pragma once', '']
|
||||
for n, b, s in mods:
|
||||
lines.append(f'#define MOD_{n.upper()}_BASE {b:#x}ull')
|
||||
@@ -56,6 +78,6 @@ def write(mods, outdir):
|
||||
|
||||
|
||||
def read(outdir):
|
||||
"""[(name, base, size)] from a layout.json written by write()."""
|
||||
"""[(name, base, size)] from a layout.json written by write() (a plugin's file and hash left out)."""
|
||||
data = json.loads((Path(outdir) / 'layout.json').read_text())
|
||||
return [(m['name'], int(m['base'], 16), int(m['size'], 16)) for m in data]
|
||||
+37
-4
@@ -10,8 +10,9 @@ from collections import OrderedDict
|
||||
import numpy as np
|
||||
|
||||
from lifter import Insn, Lifter, Unsupported, hx
|
||||
from nso import Nso, R_AARCH64_RELATIVE
|
||||
from nso import DT_INIT, DT_INIT_ARRAY, DT_INIT_ARRAYSZ, Nso, R_AARCH64_RELATIVE
|
||||
|
||||
RET = 0xD65F03C0
|
||||
LIFT_CACHE = 1 << 16 # lifted instructions kept per module; analyses revisit nearby addresses only
|
||||
|
||||
|
||||
@@ -33,12 +34,27 @@ def _read_encoded(img, off, enc, pc_base):
|
||||
|
||||
|
||||
class Module:
|
||||
def __init__(self, name, path, base, simd='c'):
|
||||
def __init__(self, name, path, base, simd='c', plugin=False, image=None, rets=(), seeds=()):
|
||||
"""image, rets, seeds: a plugin's lift (recomp/patches.py `plugin`): its .text is taken from image (the plugin's
|
||||
image after its init, holding the hook stubs and trampolines the file has as zeros), the words at the image
|
||||
offsets rets become `ret` (an inline-hook stub's b to its trampoline), and the image offsets seeds are function
|
||||
starts too."""
|
||||
self.name = name
|
||||
self.nso = Nso(str(path))
|
||||
self.base = base
|
||||
self.plugin = plugin # a mod's code module (recomp/layout.py plugin<N>): its init functions are seeds too
|
||||
n = self.nso
|
||||
self.image = bytes(n.image)
|
||||
if image is not None:
|
||||
t0, t1 = n.text[0], n.text[0] + n.text[1]
|
||||
if len(image) < t1:
|
||||
raise ValueError(f'{name}: the image after the init is shorter than its .text')
|
||||
img = bytearray(self.image)
|
||||
img[t0:t1] = image[t0:t1]
|
||||
for o in rets:
|
||||
img[o:o + 4] = RET.to_bytes(4, 'little')
|
||||
self.image = bytes(img)
|
||||
self.extra_seeds = [base + o for o in seeds]
|
||||
self.lo = base + n.text[0]
|
||||
self.hi = self.lo + n.text[1]
|
||||
self.words = np.frombuffer(self.image, dtype='<u4', count=n.text[1] // 4, offset=n.text[0])
|
||||
@@ -83,7 +99,7 @@ class Module:
|
||||
def eh_frame_functions(self):
|
||||
"""Function starts from .eh_frame_hdr's binary search table (absolute addresses)."""
|
||||
img, hdr = self.image, self.nso.eh_start
|
||||
if not hdr or hdr >= len(img):
|
||||
if not hdr or hdr >= len(img) or self.nso.eh_end <= hdr: # MOD0 with an empty .eh_frame_hdr range (exlaunch)
|
||||
return []
|
||||
_, ptr_enc, cnt_enc, tbl_enc = img[hdr:hdr + 4]
|
||||
off = hdr + 4
|
||||
@@ -100,9 +116,26 @@ class Module:
|
||||
starts.append(self.base + loc)
|
||||
return starts
|
||||
|
||||
def init_functions(self):
|
||||
"""DT_INIT and the DT_INIT_ARRAY entries (absolute addresses). rtld calls DT_INIT only; the module's DT_INIT
|
||||
runs the array through blr (SDK and exlaunch modules alike), so the entries are seeds too. An entry holds its
|
||||
target as the addend of its R_AARCH64_RELATIVE relocation, or as the word itself when no relocation names it."""
|
||||
dyn, out = self.nso.dyn, []
|
||||
if dyn.get(DT_INIT):
|
||||
out.append(self.base + dyn[DT_INIT])
|
||||
if dyn.get(DT_INIT_ARRAY):
|
||||
addends = {off: add for off, typ, _, add in self.nso.relocs if typ == R_AARCH64_RELATIVE}
|
||||
for off in range(dyn[DT_INIT_ARRAY], dyn[DT_INIT_ARRAY] + dyn.get(DT_INIT_ARRAYSZ, 0), 8):
|
||||
out.append(self.base + addends.get(off, self.nso.u64(off)))
|
||||
return out
|
||||
|
||||
def seeds(self):
|
||||
"""Known function starts: .eh_frame_hdr, exported FUNC symbols, R_AARCH64_RELATIVE targets in .text."""
|
||||
"""Known function starts: .eh_frame_hdr, exported FUNC symbols, R_AARCH64_RELATIVE targets in .text; for a
|
||||
plugin also its init functions (exlaunch's DT_INIT starts inside a function discovery would merge it into)."""
|
||||
starts = set(self.eh_frame_functions())
|
||||
if self.plugin:
|
||||
starts.update(self.init_functions())
|
||||
starts.update(self.extra_seeds)
|
||||
for _, info, shndx, value, _ in self.nso.syms:
|
||||
if shndx and (info & 0xF) == 2:
|
||||
starts.add(self.base + value)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ from collections import Counter
|
||||
import lz4.block
|
||||
|
||||
DT_NULL, DT_NEEDED, DT_PLTRELSZ, DT_HASH, DT_STRTAB, DT_SYMTAB, DT_RELA, DT_RELASZ = 0, 1, 2, 4, 5, 6, 7, 8
|
||||
DT_STRSZ, DT_JMPREL, DT_RELACOUNT = 10, 23, 0x6FFFFFF9
|
||||
DT_STRSZ, DT_INIT, DT_JMPREL, DT_INIT_ARRAY, DT_INIT_ARRAYSZ, DT_RELACOUNT = 10, 12, 23, 25, 27, 0x6FFFFFF9
|
||||
DT_RELRSZ, DT_RELR, DT_GNU_HASH = 0x23, 0x24, 0x6FFFFEF5
|
||||
R_AARCH64_ABS64, R_AARCH64_GLOB_DAT, R_AARCH64_JUMP_SLOT, R_AARCH64_RELATIVE = 257, 1025, 1026, 1027
|
||||
|
||||
|
||||
@@ -103,6 +103,11 @@ set pooloff TOTK_POOL_OFFSET_PATCH 1
|
||||
site pooloff main 9b93a8 93407f22 2a1903e2
|
||||
site pooloff main 9b93c4 8b39c101 8b394101
|
||||
|
||||
# Fixed scene tier: the 1.1.0 controller (main+0xce8d74, 1.2.1 main+0xcc26f4) returns its scale through w23 in
|
||||
# the shared epilogue. res_dynres_live enables this set when dynamic_res is off, preserving the configured render_scale.
|
||||
set fixres TOTK_FIXED_RES_PATCH 0
|
||||
site fixres main ce9280 2a1703e9 52a7f009 # mov w9, w23 -> mov w9, #0x3f800000 (1.0f)
|
||||
|
||||
# Sun shadow map: the size rounded here is used for width (+0x3d8), height (+0x3f8) and viewport together.
|
||||
# runtime/resolution.c shadow_init supplies the fixed size at page +92; the default remains the game's size.
|
||||
site shadow main d0760c 11001d6b @page:x11 b9405d6b 11001d6b
|
||||
@@ -114,6 +119,23 @@ site cascade main 1158040 52a84408 @page:x8 b9404508
|
||||
site cascade main 11580c8 52a85408 @page:x8 b9404908
|
||||
site cascade main 115814c 52a86408 @page:x8 b9404d08
|
||||
|
||||
# High-frame-rate climbing (#35, #276, #1001): r is in s9 in the local 1.1.0 controller at main+0x1927948.
|
||||
# The shipping formula multiplies by -0.181, doubles with fadd, then adds 1.272; keep its rounding and [0.5, 1.5] clamp.
|
||||
# For r<1 use the 1.2.1 climb h(r,u), u=max(page+0,r); the normal 30 Hz factor stays unchanged.
|
||||
# runtime/frame_rate.c disables climb when realtime=0; TOTK_CLIMB_FIX=0 keeps the original instruction.
|
||||
# A 96-byte, 16-byte-aligned stack frame saves x8 and full q5/q6/q7/q16/q17; only s0/s1 are outputs.
|
||||
set climb TOTK_CLIMB_FIX 1
|
||||
site climb main 19279f0 1e2f1001 d10183ff f90003e8 ad009be5 ad01c3e7 3d8017f1 @page:x8 bd400111 1e296a31 1e2e1005 1e3138a5 52862508 72a7e308 1e270106 1e2608a5 1e2528a5 529a1ca8 72a7f448 1e270106 1e2628a5 1e201006 1e2678a5 52946dc8 72a7e528 1e270106 1e3118c6 52828248 72a7dfe8 1e270107 1e2728c6 529573e8 72a7b5a8 1e270107 1f1118e6 1e283a27 2f00e410 1e3068e7 1e261010 1f1098e6 1e241010 1e3078c6 1e2668a5 1e256800 1e2f1001 1e256821 3dc017f1 ad41c3e7 ad409be5 f94003e8 910183ff
|
||||
|
||||
# Gear rotation check (#330, #984): main+0x213eec4, vtable 0x347e8e8 slot +0x110.
|
||||
# AI dispatchers 0x1205b90 / 0x2ae29ac pass a context with frame delta at +8; keep it in the already-saved s12.
|
||||
# Scale RotateStartDeg/30 by that delta for all three angle compares: 0x213f10c/0x213f174/0x213f1b0.
|
||||
# The second site saves full q4 in a 16-byte stack slot, without relying on a later callee killing it.
|
||||
# This set does not read the patch page and works with realtime=0; TOTK_HIGHFPS_FIX=0 keeps both original sites.
|
||||
set gears TOTK_HIGHFPS_FIX 1
|
||||
site gears main 213eee4 f9402001 bd40082c f9402001
|
||||
site gears main 213f0d4 1e24180c 3c9f0fe4 1e241804 1e2c088c 3cc107e4
|
||||
|
||||
# Spin waits, from tools/spin_waits.py --exefs build/extracted/v110/exefs --patches recomp/patches-v110.txt: loops that only
|
||||
# another thread can end; their back-edges pass rt_spin_gate (runtime/kernel.c), TOTK_SPIN=0 keeps the core.
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ set output TOTK_PATCH_OUTPUT 0
|
||||
set scene TOTK_PATCH_SCENE 0
|
||||
set shadow TOTK_PATCH_SHADOW 0
|
||||
set grass TOTK_PATCH_GRASS 0
|
||||
set cascade TOTK_PATCH_CASCADE 0
|
||||
|
||||
# 60 fps: the adaptive present-interval controller (main+0x8f26c8, 1.0.0 0x8f6bec) gets the minimum interval 1.
|
||||
site fps60 main 8f273c 6b08015f 7100055f # clamp: cmp w10, #1 (was cmp w10, w8 = minimum)
|
||||
@@ -132,6 +133,22 @@ site aspect main 12521cc bd414260 f81f0fea @page:x10 bd403940 f84107ea # ldr s0
|
||||
site aspect main 19b36f0 1e211800 f81f0fea @page:x10 bd403940 f84107ea # fdiv s0, s0, s1 (viewport)
|
||||
site aspect main 1ecdf68 1e211800 f81f0fea @page:x10 bd403940 f84107ea # fdiv s0, s0, s1 (viewport)
|
||||
|
||||
# Field of view (runtime/resolution.c res_fov_live writes TOTK_FOV / 100 to page +60 and switches the set). The same two
|
||||
# camera routines as the aspect set (update main+0xcb4208, setup main+0x1252024; 1.4.3 main+0x628460, main+0xb432bc)
|
||||
# load the camera's vertical view angle (+0x13c, radians) a few words before the ratio and hand it to sead's perspective
|
||||
# projection (+0xa0, then sinf / cosf / tanf of half of it at +0xa4..+0xac); 1.4.3's setup reads the same fields through
|
||||
# x22 = camera + 0xd8. Eight more places fill a perspective projection the same way, 1.4.3 has the same eight, and
|
||||
# neither version patches them: one more inlined copy that scales an angle of another object (main+0x6c5548, 1.4.3
|
||||
# main+0x4e9754), three projection routines (main+0xdde89c, main+0x1141ce8, main+0x1a5e994; 1.4.3 main+0xc02690,
|
||||
# main+0xd42730, main+0x27d53d8) and four that fill a projection on the stack (main+0x7800f0, main+0x7805fc,
|
||||
# main+0xc764cc, main+0x21ee474; 1.4.3 main+0x63e2b4, main+0x63e744, main+0x79344, main+0x2804fec). The replacement is
|
||||
# the one of patches-v143.txt (word for word the sites of patches-v110.txt): it loads the angle as before and
|
||||
# multiplies it by the factor on the page; s8 holds the factor because the next instruction (fmul s8, s0, s1) overwrites
|
||||
# it, and x10 is kept on the stack.
|
||||
set fov TOTK_FOV_PATCH 0
|
||||
site fov main cb4ad8 bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea # ldr s0, [x19, #0x13c] (camera update)
|
||||
site fov main 1252194 bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea # ldr s0, [x19, #0x13c] (camera setup)
|
||||
|
||||
# Texture pool offsets past 2 GiB (MacNativeGames ca311e2d). The texture loader keeps a texture's place in its pool as a
|
||||
# 32-bit offset (main+0xad4294: sub x25, x9, x10, stored as the word w25) and widens it as a signed number for
|
||||
# nvnTextureBuilderSetStorage's offset and for SetPackagedTextureData's source (the pool's CPU address + offset). The
|
||||
@@ -1128,6 +1145,18 @@ spin sdk 3d3250 3d3270 # 9 instructions; loads
|
||||
# computation). Found by a write watch on the size field (the writer was this function, and no other).
|
||||
site shadow main cec22c 11001d6b @page:x11 b9405d6b 11001d6b # add w11, w11, #7 -> adrp x11, page; ldr w11, [x11, #92]; add w11, w11, #7
|
||||
|
||||
# Sun shadow cascade distances (runtime/resolution.c res_shadow_range switches the set on; issue #606). On 1.2.1 the
|
||||
# depth shadow parameters (depth_shadow_near_0_0..3 and depth_shadow_far_0, whose constructor defaults at
|
||||
# main+0x114c2f8.. are 20, 40, 80, 160 and 2000 m) do not reach the sun's cascades: the game's shadow controller sets
|
||||
# bit 1 of the scene's depth shadow flags when it starts (main+0xc7b0e8), and with that bit the per-view update
|
||||
# (main+0xa2cff4) skips its copy of those parameters into the cascade boundaries. The controller writes the boundaries
|
||||
# itself each frame in main+0xcebdf4: d[0] at main+0xcec2ac, d[1..n-1] at main+0xcec314 and the far d[n] at
|
||||
# main+0xcec36c (d = [cascade set + 0x308], read by main+0xa2d6ec). The set multiplies d[1..n] where they are stored,
|
||||
# by page +64 (20 m times shadow_range / 100) over 20; d[0], the first cascade's start, stays. x3, s16 and s17 are
|
||||
# dead at both sites.
|
||||
site cascade main cec314 bd000446 @page:x3 bd404070 1e269011 1e311a10 1e3008d0 bd000450 # str s6, [x2, #4] -> adrp x3, page; ldr s16, [x3, #64]; fmov s17, #20.0; fdiv s16, s16, s17; fmul s16, s6, s16; str s16, [x2, #4]
|
||||
site cascade main cec36c bc29d945 @page:x3 bd404070 1e269011 1e311a10 1e3008b0 bc29d950 # str s5, [x10, w9, sxtw #2] -> the same with fmul s16, s5, s16; str s16, [x10, w9, sxtw #2]
|
||||
|
||||
# Grass range (runtime/resolution.c res_grass_range; patches-v143.txt describes the set and the page). The near grass
|
||||
# map's constructor loads its extent, step and texture sizes at main+0xfe58b4..0xfe5950, and main+0x1a30a28 sets the
|
||||
# extent to 62.5 or 31.25 m, as on 1.4.3.
|
||||
@@ -1151,3 +1180,32 @@ site optref main 1622bec b4000188 937ffd09 8a290108 b4000188 # cbz x8 -> asr x
|
||||
set ability TOTK_ABILITY_GUARD 1
|
||||
site ability main 1622bf0 f9400115 94c424dc # ldr x21, [x8] -> bl page+0xf60
|
||||
site ability main 1622bf4 b4000155 aa0903f5 b4000155 # cbz x21 -> mov x21, x9; cbz x21 (x9 dead after it)
|
||||
|
||||
# Sound command lists above 200 updates a second (issue #337). The game thread hands its sound commands to the audio
|
||||
# thread in lists: 16 of them, of which 4 are always held (one being filled by the game thread, the others on the audio
|
||||
# thread's side), so at most 12 wait in the command ring. The game thread submits at most one list per update
|
||||
# (main+0x9bd144, when a free list is there), and the audio thread takes one per pass of its loop, one 5 ms audio frame:
|
||||
# after a list main+0x883780 goes on past the ring's check (b 0x883318). Above about 200 updates a second the ring
|
||||
# fills. A guard in the game (main+0x9bcdc4, at the end of each update) 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 goes back to 0 whenever a free
|
||||
# list is there (0x9bce00), which takes two audio frames between two updates: the game thread picks up one of the two
|
||||
# lists, the other is still free at the guard. At every multiple of 300 (10 s at 30 fps, 1.25 s at 240) the guard clears
|
||||
# the sound command switch, the byte at [[engine + 0x1a0] + 8] (main+0x2268bfc), and stops every active voice
|
||||
# (main+0x226f29c). The switch is set to 1 only by its constructor (main+0xf31ce8, from the engine's init
|
||||
# main+0xf31530), so the game stays silent until it is restarted. By this reading the guard fires only when the audio
|
||||
# frames come evenly, 5 ms apart, through 300 updates in a row at more than 200 a second: that is the mixer pacing its
|
||||
# render thread by its own timer (runtime/audio_mixer.c, audio_mixer_pace_ns), with audio = none or while a device takes
|
||||
# nothing. While a device paces the rendering the frames come in bursts after each device period: on Linux with
|
||||
# PipeWire's 1024-frame periods 76% of the frames were measured 4 ms after the one before (audren.c, gap_ns), two of
|
||||
# them fall between two updates several times a second, and the game kept its sound in every run. On Windows gap_ns is 0
|
||||
# and the frames of a burst are rendered back to back: read from the code, not measured here. A device with periods of
|
||||
# 240 frames or less was not tried and may pace as evenly as the timer. The count and the switch have not been read in a
|
||||
# run. The site sends the audio thread back to the ring's check (0x8832e8, where the game's own 0x883c18 also branches;
|
||||
# x21, the engine, is not written between the check and the site), so it takes every queued list in the pass and the
|
||||
# ring does not stay full. Measured on 1.2.1 at fps_limit 240 (Linux, PipeWire), same save and input script, seconds
|
||||
# with sound in the mix with the set off and on: without a device 6 of 119 and 111 of 119; with a device 111 of 119 and
|
||||
# 112 of 119; with the game's stream paused for 5 s from outside (pw-cli, not a real device stalling) while the game ran
|
||||
# at 240 fps 4 of 120 (silent from the pause on, also after the device resumed) and 113 of 119. A pause of 2 s silenced
|
||||
# the game with the set off in two runs of two, a pause of 1 s in none of one.
|
||||
set audiodrain TOTK_AUDIO_DRAIN_FIX 1
|
||||
site audiodrain main 883780 17fffee6 17fffeda # b 0x883318 -> b 0x8832e8
|
||||
@@ -1104,6 +1104,18 @@ site cascade main 6fabb8 52a83408 @page:x8 b9404108 # mov w8, #20.0 -> ldr w8
|
||||
site cascade main 6fac40 52a84408 @page:x8 b9404508 # mov w8, #40.0 -> ldr w8, [page+68]
|
||||
site cascade main 6facc8 52a85408 @page:x8 b9404908 # mov w8, #80.0 -> ldr w8, [page+72]
|
||||
site cascade main 6fad4c 52a86408 @page:x8 b9404d08 # mov w8, #160.0 -> ldr w8, [page+76]
|
||||
# The four sites above reach the cascades only through the copy of the parameters into the cascade boundaries
|
||||
# (main+0x5680ec, in the per-view update). The game's shadow controller sets bit 1 of the scene's depth shadow flags
|
||||
# when it starts (main+0xb74494), with that bit the per-view update skips the copy (main+0x567f6c), and the controller
|
||||
# writes the boundaries itself each frame in main+0x68318c: d[0] at main+0x683680, d[1..n-1] at main+0x6836ec and the
|
||||
# far d[n] at main+0x683740 (d = [cascade set + 0x308]). In Hyrule Field the four sites alone leave the cascades as
|
||||
# they are at 100 (issue #606 has the same on 1.2.1). These two multiply d[1..n] where the controller stores them, by
|
||||
# page +64 (20 m times shadow_range / 100) over 20; d[0], the first cascade's start, stays. The function computes the
|
||||
# boundaries from the controller's own fields and its arguments and reads neither the parameters nor d, so a boundary
|
||||
# is scaled once on either path. x25 (written at main+0x683704 before any read), x16, s18 and s19 are dead at the
|
||||
# sites.
|
||||
site cascade main 6836ec bd000711 @page:x25 bd404332 1e269013 1e331a52 1e320a32 bd000712 # str s17, [x24, #4] -> adrp x25, page; ldr s18, [x25, #64]; fmov s19, #20.0; fdiv s18, s18, s19; fmul s18, s17, s18; str s18, [x24, #4]
|
||||
site cascade main 683740 bc2ed9b0 @page:x16 bd404212 1e269013 1e331a52 1e320a12 bc2ed9b2 # str s16, [x13, w14, sxtw #2] -> the same through x16 with fmul s18, s16, s18; str s18, [x13, w14, sxtw #2]
|
||||
|
||||
# Climbing (issues #35, #276, #1001): the climb controller's velocity step (main+0x1f49754, shared by wall and ladder
|
||||
# climbing, climb jumps and climb-overs) multiplies the requested velocity by a factor that makes up for a movement loss
|
||||
@@ -1173,7 +1185,69 @@ set report TOTK_REPORT_GUARD 1
|
||||
site report main a22d8 2a010571 2a010571 37f80341 # orr w17, w11, w1, lsl #1; tbnz w1, #31, 0xa2340
|
||||
site report main a2310 531f7821 530f7c24 531f7821 35000184 # lsr w4, w1, #15; lsl w1, w1, #1; cbnz w4, 0xa2340
|
||||
|
||||
# Depth query results one frame older (TOTK_SYNC_AHEAD). A compute pass at the start of each frame samples the scene
|
||||
# depth for the world queries and writes their results, with the frame number of the request, into a 23232-byte
|
||||
# CPU-cached buffer that main+0x6e1220 invalidates and reads two frames later. It takes the results as this frame's
|
||||
# (bit 2 of obj+0x10) only when the number at buffer +0x58e4 is exactly the frame counter (obj+0x14) - 2. With
|
||||
# sync_ahead the game's frame wait covers the frame before, so on frames where the GPU runs behind the number read is
|
||||
# the counter - 3 (the frame after it has not come back yet) and the results were refused: in shrines the reflections
|
||||
# of the lamps on the floor went out on those frames, every other frame where the GPU was slow, which looked like
|
||||
# flicker at some camera angles. The set also accepts the counter - 3: d = counter - 2 - number, unsigned d <= 1.
|
||||
# Waiting for that frame when the buffer is invalidated (vk_memory.c vk_mem_shadow_read) also ends the flicker, but
|
||||
# gives back the frame rate sync_ahead brings (63 against 86 fps on a field macro at 4K).
|
||||
# w11 is loaded again on both paths at 0x6e1340 before any read; x8, the number's address, stays for 0x6e1420.
|
||||
set qstamp TOTK_SYNC_AHEAD 0
|
||||
site qstamp main 6e1320 6b0b015f 4b0b014b 7100057f # cmp w10, w11 -> sub w11, w10, w11; cmp w11, #1
|
||||
site qstamp main 6e1324 540000c1 540000c8 # b.ne 0x6e133c -> b.hi 0x6e133c
|
||||
|
||||
# Function-entry hooks (FN_ENTER, runtime/cpu.h): only these functions check g_fnprof on entry, the others carry no
|
||||
# hook. main+0x585bd0 sets the render size (runtime/resolution.c SET_RENDER_SIZE): res_fn_hit takes the renderer from
|
||||
# the game's own call at start, so a DLSS mode can change while the game runs.
|
||||
hook main 585bd0
|
||||
|
||||
# Sound command lists above 200 updates a second (issue #337): as in patches-v121.txt, which also says when the game's
|
||||
# guard fires. The audio thread's check of the command ring is main+0x148aec, which wants x8 = the engine (as 0x148ae0
|
||||
# loads it from [x19]); after a list the site goes back to it instead of on to 0x148b14, with the two instructions the
|
||||
# game itself has at 0x149700. Measured on 1.4.3 at fps_limit 240 (Linux, PipeWire), same save and input script, seconds
|
||||
# with sound in the mix: without a device 3 of 119 with the set off and 113 of 120 with it on; with a device 111 of 119
|
||||
# with the set off; with the game's stream paused for 5 s from outside at 240 fps, in 60 s runs, 3 of 59 with the set
|
||||
# off (silent from the pause on) and 51 of 59 with it on; a pause of 2 s with the set off, 4 of 59.
|
||||
set audiodrain TOTK_AUDIO_DRAIN_FIX 1
|
||||
site audiodrain main 149244 17fffe34 f9400268 17fffe2a # b 0x148b14 -> ldr x8, [x19]; b 0x148aec
|
||||
|
||||
# Tenbez Shrine launchers (issue #1215). The two DgnObj_BoxShutter_4x4x4 that throw the stone ball across the room move
|
||||
# 3 m at Speed (1.0 m per 30 Hz frame, 30 m/s): their AI (AI/ShutterFence.root.ainb) advances the target by Speed *
|
||||
# frame ratio each frame and sets the kinematic body's velocity to reach it. The shorter the frame, the slower the ball
|
||||
# leaves. Measured on the flight's apex (the ball rests at y = -4.42): 6.33 at 30 fps, 6.11 at 45, 6.00 at 60, 5.79 at
|
||||
# 90, 5.61 at 120. Below about 6.1 the ball lands more and more often on the rim of the receiving launcher instead
|
||||
# of its seat, and the next shots juggle it there or knock it into the pit. The data suggest Nintendo tuned this by
|
||||
# hand for a 60 fps build ("Ounce", which looks like the Switch 2): in
|
||||
# the shrine's map both actors carry SpeedForOunce = 1.01 and shouldUseOunceSpeed, read by the node
|
||||
# QueryBlackboardGetF32FromActorForOunce (also in AI/ShutterFence_WithVibration.root.ainb of the
|
||||
# FldObj_RuinStoneWall_A_20/30_Shutter walls, where the flag is never set). The Switch build of the node ignores the
|
||||
# pair: its evaluation (main+0x25e557c) looks up the base key alone. With 1.01 the apex is 6.20 at 60 fps, but 5.96 at 90 and
|
||||
# 5.81 at 120, so the site scales by the frame instead. It is where the evaluation loads the value: when the node's
|
||||
# shouldUseOunceKey input (+0x58) is true, the value is multiplied by 1 + 0.065 * (1 - ratio)^2, ratio being the time
|
||||
# object's +0x38 (the frame in 30 Hz frames; [[main+0x3ad27c8] + 0xc8], the object the set bounce reads) clamped to
|
||||
# 0..1. That is 1.016 at 60 fps and 1.037 at 120, and exactly 1 at 30 fps and below. Measured apex with it: 6.25 at
|
||||
# 45 fps, 6.33 at 60, 6.23 at 90, 6.33 at 120, 6.35 at 144. Every other user of the node has the input false and gets
|
||||
# its value unchanged. x9, x10 and s1-s4 are free: after the site the function only moves x19 to x0, restores the
|
||||
# saved registers and tail-calls the output setter (main+0xb9b818), which reads x0 and s0. Its own switch,
|
||||
# shutter_fix (TOTK_SHUTTER_FIX); 0 runs the game's instruction.
|
||||
set shutter TOTK_SHUTTER_FIX 1
|
||||
site shutter main 25e55d0 bc605900 bc605900 f9402ea9 927ef529 39400129 1e230123 b000a76a f943e54a f940654a bd403941 1e2e1002 1e213841 2f00e404 1e246821 1e227821 1e210821 5283d709 72a7b0a9 1e270124 1e240821 1e230821 1f010000
|
||||
# ldr s0, [x8, w0, uxtw #2]; ldr x9, [x21, #0x58]; and x9, x9, #~3; ldrb w9, [x9]; ucvtf s3, w9 (the input, 0 or 1);
|
||||
# adrp x10, main+0x3ad2000; ldr x10, [x10, #0x7c8]; ldr x10, [x10, #0xc8]; ldr s1, [x10, #0x38] (ratio);
|
||||
# fmov s2, #1.0; fsub s1, s2, s1; movi d4, #0; fmaxnm s1, s1, s4; fminnm s1, s1, s2; fmul s1, s1, s1;
|
||||
# mov w9, #0x1eb8; movk w9, #0x3d85, lsl #16; fmov s4, w9 (0.065); fmul s1, s1, s4; fmul s1, s1, s3;
|
||||
# fmadd s0, s0, s1, s0
|
||||
|
||||
# Free camera (runtime/freecam.c freecam_hook, page +0xf50). The camera component update (main+0x628460, the routine of
|
||||
# the first fov and aspect sites) copies the component's eye, target and up into its sead camera; every path to that
|
||||
# copy runs this load of the component's link first. The hook performs the load and, while the free camera is on,
|
||||
# writes the component's one-shot eye and target overrides (+0x180, +0x198). The function saves x30 in its prologue, so
|
||||
# the bl's link write is harmless. Off by default (freecam_patch, the Free camera row of the Controls tab, read at start):
|
||||
# with it off the site runs the game's load and nothing else. It sits at the end of the table, so the sets before it
|
||||
# keep their numbers.
|
||||
set freecam TOTK_FREECAM_PATCH 0
|
||||
site freecam main 6286d4 f9400e68 94d2de1f # ldr x8, [x19, #0x18]
|
||||
+174
-14
@@ -3,13 +3,19 @@
|
||||
Lifted code cannot be byte-patched when the game runs, so a patch is applied when the C is generated. A patch file
|
||||
(gen.py --patches) has these kinds of lines; `#` starts a comment, fields are separated by whitespace:
|
||||
|
||||
set <name> <env> <default> a patch set: a run-time switch <env>=0/1, <default> when it is unset
|
||||
set <name> <env> <default> [ordered] a patch set: a run-time switch <env>=0/1, <default> when it is unset
|
||||
site <set> <module> <address> <original> <replacement> [<replacement> ...]
|
||||
|
||||
spin <module> <head> <back-edge> [<back-edge> ...]
|
||||
|
||||
hook <module> <function> [<function> ...]
|
||||
|
||||
plugin <set> <module> <text sha256> <image>
|
||||
expect <set> <module> <offset> <old> <new>
|
||||
stub <module> <offset>
|
||||
seed <module> <offset> [<offset> ...]
|
||||
orig <set> <module> <offset> <function module> <function offset>
|
||||
|
||||
<address> is a module offset (hex), <original> the instruction word the module has there (checked; a mismatch stops
|
||||
the generator), each <replacement> an instruction word (hex) or `@page:x<n>`, which is `adrp x<n>, <patch page>`
|
||||
encoded for the site's address. The patch page is the first 4 KiB page after main's image (layout.py leaves the rest
|
||||
@@ -22,16 +28,50 @@ the field-of-view factor (runtime/resolution.c res_fov_live, set fov), +92..95 t
|
||||
The replacement words are lifted at the site's address in place of the original instruction, and the generated C reads
|
||||
`if (rt_patch_on[<set>]) { replacement } else { original }`: one byte load and a branch per executed site. Several
|
||||
sets may patch one address (cheats that write different values there): `if (a) {..} else if (b) {..} else {..}`, the
|
||||
first set in file order wins. The original may be any instruction but br, blr and ret; a replacement's last word may be
|
||||
first set in file order wins.
|
||||
|
||||
An `ordered` set belongs to something the player puts in an order (a mod of the Mods tab: tools/exefs_patches.py marks
|
||||
its sets so). A site that two or more ordered sets patch is contested: the run time, not the file order, picks which
|
||||
of them runs. Each contested site gets a byte rt_patch_pick[<n>] (n counts the contested sites, by module name and
|
||||
offset), and each of its ordered alternatives tests `rt_patch_pick[<n>] == <j>`, j being the alternative's place
|
||||
among the site's ordered sets in file order (1 up; 0 runs none of them): one byte load for the whole group. The
|
||||
runtime fills the bytes from the sets that are on and their ranks (runtime/patches.c rt_patch_picks: the lowest rank
|
||||
wins, a tie goes to the set later in the file). The other alternatives of a contested site keep their place and
|
||||
their rt_patch_on test, so a cheat before the mods' sets still wins while it is on. A site with at most one ordered
|
||||
set, and a table without contested sites, is emitted exactly as without the keyword.
|
||||
|
||||
The original may be any instruction but br, blr and ret; a replacement's last word may be
|
||||
a bl (lifted with the site's return address), a b or b.cond / cbz / tbz (its target joins the function's labels when
|
||||
inside it) or a ret; earlier words must not branch. Every alternative of a site writes the same flags. The generator
|
||||
writes patches.h (set names, switches, the page address) next to layout.h for the runtime.
|
||||
writes patches.h (set names, switches, the page address, the contested sites) next to layout.h for the runtime.
|
||||
|
||||
A `spin` line names a spin wait found by tools/spin_waits.py: a loop with head <head> that only another thread can end,
|
||||
and the direct branches back to it (module offsets). Each back-edge (checked: a b, b.cond, cbz / cbnz or tbz / tbnz to
|
||||
<head>) is lifted as `rt_spin_gate(c, <head>); goto <head>`, which keeps every register and only adds time
|
||||
(runtime/kernel.c kern_spin_gate).
|
||||
|
||||
The plugin lines carry a mod's exlaunch plugin (layout.py plugin<N>), whose init runs at every start
|
||||
(runtime/plugin_init.c) and whose hooks are sites of its set (tools/exefs_plugins.py writes them from the plugin service
|
||||
run's record; the design follows #845 by itaskaev2):
|
||||
- `plugin`: <module> belongs to the set <set>; it is lifted from <image>, the plugin's image after its init (the
|
||||
service run's plugin<N>.img), whose .text holds the hook stubs and trampolines the NSO file has as zeros. <text
|
||||
sha256> is that .text's hash: the runtime compares it with the .text its own run of the init leaves, and keeps the
|
||||
set off when they differ.
|
||||
- `expect`: one word the init writes into a game module (the hook branches into main's .text); the runtime compares
|
||||
the words its run of the init wrote with these, all or nothing per plugin.
|
||||
- `stub`: an exlaunch inline-hook entry stub (stur x30; bl impl; ldur x30; b trampoline; .quad callback). Its fourth
|
||||
word is lifted as a `ret`: the generated site calls the stub and runs its own original instruction after it
|
||||
(`@call` below), so the trampoline (the original relocated, b site+4) never runs.
|
||||
- `seed`: function starts of the module the lift must have (the callbacks, the hook impls, branch targets).
|
||||
- `orig`: the plugin calls its replace hook's original through the trampoline at <module>+<offset>; the generator
|
||||
lifts the function at <function module>+<function offset> a second time without its patched sites
|
||||
(fo_<address>) and lists that copy at the trampoline's address in <module>'s function table, so the call reaches
|
||||
the original code and not the hook again.
|
||||
A replacement word `@call:<module>+<offset>` is a call of the function there that writes no x30: every register in
|
||||
the Cpu at the call and all read back after it (the callback may change any of them, as exlaunch's hook context
|
||||
allows); the flags stay as they were. It may stand before the site's last word, which is then the original
|
||||
instruction.
|
||||
|
||||
A `hook` line names guest functions (module offsets of function starts; gen.py stops on any other address) whose
|
||||
entry the runtime watches: their lifted C starts with FN_ENTER (runtime/cpu.h), a load of g_fnprof and a predicted
|
||||
branch to fnprof_hit while the runtime sets it. A table with hook lines puts FN_ENTER into these functions only; a table
|
||||
@@ -40,6 +80,7 @@ without any keeps it in every function, as does gen.py --fn-enter-all (a whole-g
|
||||
from pathlib import Path
|
||||
|
||||
PAGE = 0x1000
|
||||
PICK_MAX = 255 # ordered sets on one site: rt_patch_pick is a byte, 0 for none
|
||||
|
||||
|
||||
class PatchError(ValueError):
|
||||
@@ -56,15 +97,58 @@ def adrp(pc, target, rd):
|
||||
|
||||
class Table:
|
||||
"""sets: [(name, env, default)]; sites: {module: {offset: [(set index, [word | ('page', reg)], original)]}} (the
|
||||
alternatives of a site in file order); page. What the generated C takes from here (for_module, spins_for, hooks_for)
|
||||
is in the lift cache's key (recomp/gen.py chunk_key); a new kind of line the Emitter reads must go there too."""
|
||||
alternatives of a site in file order); page; ordered: the indices of the ordered sets. What the generated C takes
|
||||
from here (for_module, picks_for, spins_for, hooks_for) is in the lift cache's key (recomp/gen.py chunk_key); a new
|
||||
kind of line the Emitter reads must go there too."""
|
||||
|
||||
def __init__(self, sets=(), sites=None, page=0, spins=None, hooks=None):
|
||||
def __init__(self, sets=(), sites=None, page=0, spins=None, hooks=None, ordered=(), plugins=None):
|
||||
self.sets = list(sets)
|
||||
self.sites = sites or {}
|
||||
self.page = page
|
||||
self.spins = spins or {} # {module: {back-edge offset: head offset}}
|
||||
self.hooks = hooks or {} # {module: {function offset}}; empty: FN_ENTER in every function
|
||||
self.ordered = set(ordered)
|
||||
# {module: {'set', 'sha256', 'image', 'expect': [(module, offset, old, new)], 'stubs': {offset},
|
||||
# 'seeds': {offset}, 'origs': {trampoline offset: (function module, function offset)}}}; empty without
|
||||
# plugin lines
|
||||
self.plugins = plugins or {}
|
||||
self.bases = {} # {module: base} of the layout load() read
|
||||
|
||||
def plugin_inputs(self, name):
|
||||
"""What the lift of module name takes from its plugin lines (for the lift cache's key), or None."""
|
||||
p = self.plugins.get(name)
|
||||
if not p:
|
||||
return None
|
||||
return [p['image'], p['sha256'], sorted(p['stubs']), sorted(p['seeds']), sorted(p['origs'])]
|
||||
|
||||
def origs_for(self, name, base):
|
||||
"""The absolute addresses of module name's functions that a plugin's `orig` line copies."""
|
||||
return {base + fo for p in self.plugins.values() for fm, fo in p['origs'].values() if fm == name}
|
||||
|
||||
def orig_entries(self, name, bases):
|
||||
"""{trampoline address in module name: absolute address of the function it reaches} (`orig`)."""
|
||||
p = self.plugins.get(name)
|
||||
if not p:
|
||||
return {}
|
||||
return {bases[name] + t: bases[fm] + fo for t, (fm, fo) in p['origs'].items()}
|
||||
|
||||
def picks(self):
|
||||
"""The contested sites, by module name and offset: [(module, offset, [ordered set index in file order])]; the
|
||||
list index is the site's rt_patch_pick byte."""
|
||||
out = []
|
||||
for name in sorted(self.sites):
|
||||
for off in sorted(self.sites[name]):
|
||||
sets = [k for k, _, _ in self.sites[name][off] if k in self.ordered]
|
||||
if len(sets) > 1:
|
||||
if len(sets) > PICK_MAX:
|
||||
raise PatchError(f'{name}+{off:#x}: {len(sets)} ordered sets, at most {PICK_MAX}')
|
||||
out.append((name, off, sets))
|
||||
return out
|
||||
|
||||
def picks_for(self, name, base):
|
||||
"""{absolute address of a contested site: (its pick index, {ordered set index: the value that runs it})}."""
|
||||
return {base + off: (n, {k: j + 1 for j, k in enumerate(sets)})
|
||||
for n, (mod, off, sets) in enumerate(self.picks()) if mod == name}
|
||||
|
||||
def hooks_for(self, name, base):
|
||||
"""The absolute addresses of the module's hooked functions, or None when the table has no hook line at all
|
||||
@@ -77,29 +161,42 @@ class Table:
|
||||
"""{absolute back-edge address: absolute head address}."""
|
||||
return {base + b: base + h for b, h in self.spins.get(name, {}).items()}
|
||||
|
||||
def for_module(self, name, base):
|
||||
"""{absolute address: [(set index, [words])]} with @page resolved."""
|
||||
def for_module(self, name, base, bases=None):
|
||||
"""{absolute address: [(set index, [words])]} with @page resolved; an @call word becomes ('call', absolute
|
||||
address), which needs bases ({module: base})."""
|
||||
out = {}
|
||||
|
||||
def word(a, w):
|
||||
if not isinstance(w, tuple):
|
||||
return w
|
||||
if w[0] == 'page':
|
||||
return adrp(a, self.page, w[1])
|
||||
known = bases or self.bases
|
||||
if w[1] not in known:
|
||||
raise PatchError(f'{name}+{a - base:#x}: @call into {w[1]}, which is not in the layout')
|
||||
return ('call', known[w[1]] + w[2])
|
||||
|
||||
for off, alts in self.sites.get(name, {}).items():
|
||||
a = base + off
|
||||
out[a] = [(k, [adrp(a, self.page, w[1]) if isinstance(w, tuple) else w for w in repl])
|
||||
for k, repl, _ in alts]
|
||||
out[a] = [(k, [word(a, w) for w in repl]) for k, repl, _ in alts]
|
||||
return out
|
||||
|
||||
|
||||
def load(path, mods):
|
||||
"""Table from a patch file; mods is layout() output [(name, base, size)]."""
|
||||
sets, index, sites, spins, hooks = [], {}, {}, {}, {}
|
||||
sets, index, sites, spins, hooks, ordered, plugins = [], {}, {}, {}, {}, set(), {}
|
||||
bases = {n: (b, s) for n, b, s in mods}
|
||||
for no, raw in enumerate(Path(path).read_text().splitlines(), 1):
|
||||
for no, raw in enumerate(Path(path).read_text(encoding='utf-8').splitlines(), 1):
|
||||
f = raw.split('#', 1)[0].split()
|
||||
if not f:
|
||||
continue
|
||||
where = f'{path}:{no}'
|
||||
if f[0] == 'set' and len(f) == 4:
|
||||
if f[0] == 'set' and (len(f) == 4 or len(f) == 5 and f[4] == 'ordered'):
|
||||
if f[1] in index:
|
||||
raise PatchError(f'{where}: set {f[1]} defined twice')
|
||||
index[f[1]] = len(sets)
|
||||
if len(f) == 5:
|
||||
ordered.add(len(sets))
|
||||
sets.append((f[1], f[2], int(f[3])))
|
||||
elif f[0] == 'site' and len(f) >= 6:
|
||||
if f[1] not in index:
|
||||
@@ -111,6 +208,11 @@ def load(path, mods):
|
||||
for w in f[5:]:
|
||||
if w.startswith('@page:x'):
|
||||
repl.append(('page', int(w[7:])))
|
||||
elif w.startswith('@call:') and '+' in w:
|
||||
target, at = w[6:].split('+', 1)
|
||||
if target not in bases:
|
||||
raise PatchError(f'{where}: @call into {target}, which is not in the layout')
|
||||
repl.append(('call', target, int(at, 16)))
|
||||
else:
|
||||
repl.append(int(w, 16))
|
||||
alts = sites.setdefault(f[2], {}).setdefault(off, [])
|
||||
@@ -128,6 +230,15 @@ def load(path, mods):
|
||||
if b in mod:
|
||||
raise PatchError(f'{where}: {f[1]}+{b:#x} is a back-edge twice')
|
||||
mod[b] = head
|
||||
elif f[0] == 'plugin' and len(f) == 5:
|
||||
if f[1] not in index or f[2] not in bases:
|
||||
raise PatchError(f'{where}: unknown set {f[1]} or module {f[2]}')
|
||||
if f[2] in plugins:
|
||||
raise PatchError(f'{where}: module {f[2]} has two plugin lines')
|
||||
plugins[f[2]] = {'set': index[f[1]], 'sha256': f[3], 'image': f[4], 'expect': [], 'stubs': set(),
|
||||
'seeds': set(), 'origs': {}}
|
||||
elif f[0] in ('expect', 'stub', 'seed', 'orig'):
|
||||
plugin_line(f, where, index, bases, plugins)
|
||||
elif f[0] == 'hook' and len(f) >= 3:
|
||||
if f[1] not in bases:
|
||||
raise PatchError(f'{where}: module {f[1]} not in the layout')
|
||||
@@ -139,7 +250,36 @@ def load(path, mods):
|
||||
nxt = min((b for _, b, _ in mods if b > base), default=None)
|
||||
if nxt is not None and page + PAGE > nxt:
|
||||
raise PatchError(f'no room for the patch page after main ({page:#x})')
|
||||
return Table(sets, sites, page, spins, hooks)
|
||||
table = Table(sets, sites, page, spins, hooks, ordered, plugins)
|
||||
table.bases = {n: b for n, (b, _) in bases.items()}
|
||||
return table
|
||||
|
||||
|
||||
def plugin_line(f, where, index, bases, plugins):
|
||||
"""An expect, stub, seed or orig line into the plugin entry it belongs to (its `plugin` line comes first)."""
|
||||
def plugin(name):
|
||||
if name not in plugins:
|
||||
raise PatchError(f'{where}: {name} has no plugin line before this one')
|
||||
return plugins[name]
|
||||
|
||||
if f[0] == 'expect' and len(f) == 6:
|
||||
if f[1] not in index or f[2] not in bases:
|
||||
raise PatchError(f'{where}: unknown set {f[1]} or module {f[2]}')
|
||||
owner = [p for p in plugins.values() if p['set'] == index[f[1]]]
|
||||
if not owner:
|
||||
raise PatchError(f'{where}: set {f[1]} owns no plugin')
|
||||
owner[0]['expect'].append((f[2], int(f[3], 16), int(f[4], 16), int(f[5], 16)))
|
||||
elif f[0] == 'stub' and len(f) == 3:
|
||||
plugin(f[1])['stubs'].add(int(f[2], 16))
|
||||
elif f[0] == 'seed' and len(f) >= 3:
|
||||
plugin(f[1])['seeds'].update(int(o, 16) for o in f[2:])
|
||||
elif f[0] == 'orig' and len(f) == 6:
|
||||
p = plugin(f[2])
|
||||
if f[1] not in index or p['set'] != index[f[1]] or f[4] not in bases:
|
||||
raise PatchError(f'{where}: orig of set {f[1]} for {f[2]}, which another set owns, or module {f[4]}')
|
||||
p['origs'][int(f[3], 16)] = (f[4], int(f[5], 16))
|
||||
else:
|
||||
raise PatchError(f'{where}: cannot parse {" ".join(f)!r}')
|
||||
|
||||
|
||||
def check(table, mod, name):
|
||||
@@ -175,4 +315,24 @@ def header_text(table, marker):
|
||||
'// X(index, name, env switch, default)',
|
||||
'#define RT_PATCH_SETS(X) ' + ' '.join(f'X({i}, {n}, "{e}", {d})' for i, (n, e, d) in
|
||||
enumerate(table.sets)), '']
|
||||
if table.plugins: # none: the header is what it was before plugins
|
||||
names = sorted(table.plugins)
|
||||
writes = [f'X({i}, "{m}", {o:#x}, {old:#010x}u, {new:#010x}u)' for i, n in enumerate(names)
|
||||
for m, o, old, new in sorted(table.plugins[n]['expect'])]
|
||||
lines += [f'#define RT_PLUGIN_COUNT {len(names)}',
|
||||
'// X(index, module, its set, SHA-256 of its .text after the init)',
|
||||
'#define RT_PLUGINS(X) ' + ' '.join(f'X({i}, "{n}", {table.plugins[n]["set"]}, '
|
||||
f'"{table.plugins[n]["sha256"]}")' for i, n in enumerate(names)),
|
||||
f'#define RT_PLUGIN_WRITE_COUNT {len(writes)}',
|
||||
'// X(plugin index, module, offset, old word, new word): what the init writes into game modules',
|
||||
'#define RT_PLUGIN_WRITES(X) ' + ' '.join(writes),
|
||||
'// X(module, offset): the hook entries (seed lines) TOTK_PLUGIN_TRACE counts (runtime/plugin_init.c)',
|
||||
'#define RT_PLUGIN_ROOTS(X) ' + ' '.join(f'X("{n}", {o:#x})' for n in names
|
||||
for o in sorted(table.plugins[n]['seeds'])), '']
|
||||
picks = table.picks()
|
||||
if picks: # none: the header is what it was before ordered sets
|
||||
lines += [f'#define RT_PATCH_PICK_COUNT {len(picks)}',
|
||||
'// X(index, module, module offset, its ordered sets in the order its C tests them: rt_patch_pick 1 up)',
|
||||
'#define RT_PATCH_PICKS(X) ' + ' '.join(f'X({i}, "{m}", {o:#x}, {", ".join(map(str, s))})'
|
||||
for i, (m, o, s) in enumerate(picks)), '']
|
||||
return '\n'.join(lines)
|
||||
+39
-5
@@ -30,6 +30,7 @@
|
||||
#define CHECKPOINT_RET (RT_V143 ? 0xbdb48cull : RT_V110 ? 0xeb8c14ull : 0xe7a954ull)
|
||||
#define NVN_RET (RT_V143 ? 0xbe0360ull : RT_V110 ? 0xebcdecull : 0xe7eb2cull)
|
||||
#define CTOR_DONE 2 // a module's constructor flag after its DT_INIT ran the init_array
|
||||
#define CTOR_WAITING 1 // after a DT_INIT that musl deferred (sdk's, called before main's)
|
||||
|
||||
// The init_array sizes (1.1.0 and 1.2.1: counted in the modules; 1.4.3: DT_INIT_ARRAYSZ); MacNativeGames' boot check
|
||||
// expects the same. The three tables carry the same rows, so cb_module_inits walks them by the size of one.
|
||||
@@ -40,6 +41,7 @@ static const InitCount inits_143[] = {{"main", 10717}, {"subsdk0", 45}, {"sdk",
|
||||
#define expected_inits (RT_V143 ? inits_143 : RT_V110 ? inits_110 : inits_121)
|
||||
|
||||
static volatile int32_t inits_done, checkpoint_seen;
|
||||
static int sdk_first; // a mod plugin ran: sdk's DT_INIT came first (cb_module_inits)
|
||||
uint64_t rt_guest_start_ns;
|
||||
|
||||
static const RtLoaded *module_named(const char *name) {
|
||||
@@ -77,15 +79,28 @@ static void cb_loader_ready(Cpu *c) {
|
||||
// afterwards (MacNativeGames loader.c:458-462).
|
||||
static void cb_module_inits(Cpu *c) {
|
||||
if (plat_cas32(&inits_done, 0, 0)) rt_fatal("boot: module constructors requested twice");
|
||||
if (rt_config()->plugin_init) plugin_init_run(c, module_named("sdk")); // the plugin service run ends there
|
||||
// A mod plugin's init runs after sdk's and before the game's (plugin_init.c plugins_start): sdk's DT_INIT then
|
||||
// comes first, as on the Switch; without a plugin the order stays main, subsdk0, sdk. Called first, sdk's DT_INIT
|
||||
// only registers sdk with its own musl (__nnmusl_init_dso returns 1: deferred), and main's DT_INIT then finishes
|
||||
// sdk from musl's list of waiting modules (the log shows sdk's RELRO protected and 44 pages of sdk's data written
|
||||
// during it on 1.4.3): sdk's flag stays 1 and its DT_INIT is not called again (a second call would protect its
|
||||
// locked RELRO again, and the SDK aborts).
|
||||
sdk_first = plugins_start(c, module_named("sdk"));
|
||||
for (unsigned k = 0; k < sizeof inits_121 / sizeof *inits_121; k++) {
|
||||
const RtLoaded *m = module_named(expected_inits[k].name);
|
||||
uint64_t entries = m->init_array_size / 8;
|
||||
if (!m->init) rt_fatal("boot: %s has no DT_INIT", m->name);
|
||||
rt_log("boot: ENTER %s DT_INIT (%llu init_array entries)", m->name, (unsigned long long)entries);
|
||||
rt_call(c, m->init, 0);
|
||||
int deferred = sdk_first && m == module_named("sdk");
|
||||
if (!deferred) {
|
||||
rt_log("boot: ENTER %s DT_INIT (%llu init_array entries)", m->name, (unsigned long long)entries);
|
||||
rt_call(c, m->init, 0);
|
||||
}
|
||||
uint32_t state = ctor_state(m);
|
||||
rt_logf("boot: DT_INIT %s state=%u (%llu)\n", m->name, state, (unsigned long long)entries);
|
||||
if (state != CTOR_DONE) rt_fatal("boot: %s DT_INIT left its constructor flag at %u, not 2", m->name, state);
|
||||
if (state != (deferred ? CTOR_WAITING : CTOR_DONE))
|
||||
rt_fatal("boot: %s DT_INIT left its constructor flag at %u, not %d", m->name, state,
|
||||
deferred ? CTOR_WAITING : CTOR_DONE);
|
||||
if (entries != expected_inits[k].entries)
|
||||
rt_fatal("boot: %s has %llu init_array entries, this game version has %llu", m->name, (unsigned long long)entries,
|
||||
(unsigned long long)expected_inits[k].entries);
|
||||
@@ -118,8 +133,9 @@ void rt_boot_event(const char *what, Cpu *c, const char *detail) {
|
||||
rt_fatal("boot: checkpoint %s reached from %s, expected main+%#llx", detail, at,
|
||||
(unsigned long long)CHECKPOINT_RET);
|
||||
if (!plat_cas32(&inits_done, 0, 0)) rt_fatal("boot: checkpoint %s before DT_INIT", detail);
|
||||
for (int i = 0; i < ldr_count(); i++)
|
||||
if (ctor_state(ldr_module(i)) != CTOR_DONE)
|
||||
for (int i = 0; i < ldr_count(); i++) // a plugin's init does not run at play time (plugin_init.c)
|
||||
if (!ldr_module(i)->plugin && ctor_state(ldr_module(i)) != CTOR_DONE &&
|
||||
!(sdk_first && !strcmp(ldr_module(i)->name, "sdk") && ctor_state(ldr_module(i)) == CTOR_WAITING))
|
||||
rt_fatal("boot: checkpoint %s: %s constructor flag reads %u", detail, ldr_module(i)->name,
|
||||
ctor_state(ldr_module(i)));
|
||||
plat_xchg32(&checkpoint_seen, 1);
|
||||
@@ -341,11 +357,29 @@ static void prewarm_main(void *arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
// --plugin-init DIR: the modules load and nn::init::Start runs as at boot, and its module-init callback runs sdk's
|
||||
// DT_INIT and each plugin's instead of the game's constructors, writes the record and exits (plugin_init.c). No game
|
||||
// constructor, nnMain, shader prewarm, graphics or audio runs.
|
||||
void rt_boot_plugin_init(void) {
|
||||
check_npdm();
|
||||
plugin_init_setup();
|
||||
ldr_load(rt_config()->exefs);
|
||||
rt_patches_init(); // the generated code reads the patch page
|
||||
cb_addr[0] = hostfn_register("<rtld loader_ready>", cb_loader_ready);
|
||||
cb_addr[1] = hostfn_register("<rtld module_inits>", cb_module_inits);
|
||||
cb_addr[2] = hostfn_register("<rtld module_finis>", cb_module_finis);
|
||||
hostfn_seal();
|
||||
rt_guest_start_ns = kern_now_ns();
|
||||
kern_run_on_guest_main(guest_main);
|
||||
rt_fatal("boot: the guest main thread ended");
|
||||
}
|
||||
|
||||
void rt_boot(void) {
|
||||
check_npdm();
|
||||
if (!rt_config()->shot) vk_pipeline_async_enable(); // a --shot image must not depend on build timing
|
||||
// Shaders and pipelines recorded in earlier runs are made ready while the modules load; the guest waits for them.
|
||||
PlatThread *warm = plat_thread_new(prewarm_main, NULL, "prewarm");
|
||||
plugins_setup(); // a mod plugin's environment (plugin_init.c), before its imports bind
|
||||
ldr_load(rt_config()->exefs);
|
||||
rt_patches_init();
|
||||
mods_exefs_switch(); // after the patch sets' settings: an enabled mod's ExeFS patches on
|
||||
|
||||
+79
-50
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "input_map.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define PREFIX "TOTK_"
|
||||
@@ -32,72 +33,73 @@ static int save_ok = 1; // the last cfg_save_to wrote (o
|
||||
// logged as unknown. A new variable goes here too, or its ini key logs a harmless "unknown key" line, and gets a
|
||||
// description in totk.ini.example or docs/settings.md (tests/settings_doc_check.py checks both).
|
||||
static const char *const known[] = {
|
||||
"AB", "ABILITY_GUARD", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"AB", "ABILITY_GUARD", "ADDR_REPORT", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_DRAIN_FIX", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"BACKGROUND_WINDOW", "BIND_A", "BIND_B", "BIND_DOWN", "BIND_L", "BIND_LCLICK", "BIND_LEFT", "BIND_LSTICK_DOWN", "BIND_LSTICK_LEFT",
|
||||
"BIND_LSTICK_RIGHT", "BIND_LSTICK_UP", "BIND_MINUS",
|
||||
"BIND_PLUS", "BIND_R", "BIND_RCLICK", "BIND_RIGHT", "BIND_RSTICK_DOWN", "BIND_RSTICK_LEFT", "BIND_RSTICK_RIGHT", "BIND_RSTICK_UP",
|
||||
"BIND_SHAKE",
|
||||
"BIND_INC", "BIND_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y",
|
||||
"BIND_ZL", "BIND_ZR", "BLOCK_VIEWS_3D", "CLIMB_FIX", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COLOR_CONTRAST", "COLOR_GAMMA",
|
||||
"BIND_ZL", "BIND_ZR", "BARRIER_MERGE", "BLOCK_VIEWS_3D", "CLIMB_FIX", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COLOR_CONTRAST", "COLOR_GAMMA",
|
||||
"COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT",
|
||||
"DESC_TEMPLATE", "DESWIZZLE", "DEVICE_PROFILE", "DIALOGUE_CLICK", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DUMP_LOG", "DYNAMIC_RES", "DYN_DELTA", "EXEFS", "FEEDBACK", "FIXED_RES_PATCH", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES",
|
||||
"FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLUSH_SPAN", "FOV", "FOV_PATCH", "FPS60", "FPS_LIMIT", "FRAME_QUEUE",
|
||||
"FREEZE_IDLE", "FREE_CORES",
|
||||
"DESC_TEMPLATE", "DESWIZZLE", "DEVICE_PROFILE", "DIALOGUE_CLICK", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_JITTER", "DLAA_EFFECTS_AFTER", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_FIXED_EXPOSURE", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DUMP_LOG", "DYNAMIC_RES", "DYN_DELTA", "EXEFS", "FEEDBACK", "FG_DEBUG", "FG_OBJECTS", "FG_SHOT", "FG_SHOT_DIR", "FG_TEST", "FG_TIMES", "FIXED_RES_PATCH", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES",
|
||||
"FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLUSH_SPAN", "FOV", "FOV_PATCH", "FPS60", "FPS_LIMIT", "FRAME_GEN", "FRAME_QUEUE", "FREECAM_KEY", "FREECAM_PAD", "FREECAM_PATCH",
|
||||
"FREEZE_IDLE", "FREE_CORES", "FSR3_DEBUG", "FSR3_VIEW", "FSR_SHARPNESS",
|
||||
"FULLSCREEN", "FXAA",
|
||||
"GAMEPLAY_DISTANCE_SENSITIVITY", "GAMEPLAY_ITEM_AD", "GAMEPLAY_ITEM_SENSITIVITY", "GAMEPLAY_ITEM_WHEEL",
|
||||
"GAMEPLAY_MAP_ZOOM", "GAMEPLAY_MAP_ZOOM_SENSITIVITY", "GAMEPLAY_ROTATION_SENSITIVITY", "GAMEPLAY_TWEAKS_ENABLED",
|
||||
"GAMEPLAY_ULTRAHAND_C_AXIS", "GAMEPLAY_ULTRAHAND_DISTANCE", "GAMEPLAY_ULTRAHAND_ROTATE", "GAMEPLAY_WEAPON_SENSITIVITY",
|
||||
"GAMEPLAY_WEAPON_WHEEL",
|
||||
"GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "GRASS_RANGE",
|
||||
"GYRO_BIAS_PAD", "GYRO_BIAS_X", "GYRO_BIAS_Y", "GYRO_BIAS_Z", "GYRO_CALIBRATION", "HDR", "HDR_GAME_NITS", "HDR_HUE",
|
||||
"HDR_PEAK_NITS", "HDR_UI_NITS", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "KSPIN_US", "LANG", "LIB_PREBUILD",
|
||||
"GYRO_AUTO_BIAS", "GYRO_BIAS_PAD", "GYRO_BIAS_X", "GYRO_BIAS_Y", "GYRO_BIAS_Z", "GYRO_CALIBRATION", "HDR", "HDR_GAME_NITS", "HDR_HUE",
|
||||
"HDR_PEAK_NITS", "HDR_UI_NITS", "HIGHFPS_FIX", "HUD_WIDTH", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "KSPIN_US", "LANG", "LIB_PREBUILD",
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LOD_STEADY", "LSTICK_DEADZONE", "MAP_CLICK", "MEMORY", "MEMX", "MENU_LANG", "MENU_TEST", "MENU_FONT_FONTCONFIG",
|
||||
"MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_NO_CODE", "MODS_ORDER", "MODS_REBUILD", "MODS_WITHOUT_CODE", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
"MV_SURVEY",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "POINTER_IMAGE",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_CENSUS", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "PLUGIN_TICK_OFFSET", "PLUGIN_TRACE", "POINTER_IMAGE",
|
||||
"PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_BENCH", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "QUICKLOAD_KEY", "QUICKSAVE", "QUICKSAVE_KEY", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
"RENDER_SCALE", "REPLAY_ASYNC", "REPLAY_CHUNKS", "REPLAY_CHUNK_DRAWS", "REPLAY_SKEW_US", "REPLAY_STATE_CHECK", "REPLAY_WORKERS",
|
||||
"REPLAY_CHECK", "REPORT_GUARD", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",
|
||||
"ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SHADER_CACHE",
|
||||
"SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR",
|
||||
"ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SCENE_UPSCALER", "SHADER_CACHE",
|
||||
"SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHUTTER_FIX",
|
||||
"SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS",
|
||||
"SWKBD_ANSWER", "SYNC_AHEAD",
|
||||
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64",
|
||||
"VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VMA_BLOCK_MIB", "VOLUME", "VOLUME_MUSIC", "VOLUME_SFX", "VOLUME_VOICE", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS",
|
||||
"WALK_KEY", "WALK_SCALE", "WB_EXACT", "WB_FENCE_LIMIT", "WB_MERGE", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS",
|
||||
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64",
|
||||
"VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VMA_BLOCK_MIB", "VOLUME", "VOLUME_MASK_BIAS", "VOLUME_MUSIC", "VOLUME_SFX", "VOLUME_VOICE", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS",
|
||||
"WALK_KEY", "WALK_SCALE", "WB_EAGER", "WB_EXACT", "WB_FENCE_LIMIT", "WB_MERGE", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS",
|
||||
"ZSTD_CHECK", "ZSTD_NATIVE",
|
||||
};
|
||||
|
||||
// The totk.ini section a key cfg_set may write goes to when the file lacks it (totk.ini.example's sections).
|
||||
static const struct { const char *key, *section; } sections[] = {
|
||||
{"FPS_LIMIT", "frame rate"}, {"FPS60", "frame rate"}, {"FRAME_QUEUE", "frame rate"},
|
||||
{"FPS_LIMIT", "frame rate"}, {"FPS60", "frame rate"}, {"FRAME_QUEUE", "frame rate"}, {"FRAME_GEN", "frame rate"},
|
||||
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
||||
{"CLIMB_FIX", "frame rate"},
|
||||
{"CLIMB_FIX", "frame rate"}, {"AUDIO_DRAIN_FIX", "frame rate"}, {"SHUTTER_FIX", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"HUD_WIDTH", "display"},
|
||||
{"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
{"LOD_STEADY", "display"}, {"COLOR_PRESET", "display"},
|
||||
{"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"},
|
||||
{"COLOR_GAMMA", "display"}, {"HDR", "display"}, {"HDR_PEAK_NITS", "display"}, {"HDR_GAME_NITS", "display"},
|
||||
{"HDR_UI_NITS", "display"}, {"HDR_HUE", "display"}, {"SHADOW_RES", "display"},
|
||||
{"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"DLSS_CHAR_MASK", "display"}, {"REFLEX", "display"}, {"FXAA", "display"},
|
||||
{"SCENE_UPSCALER", "display"}, {"DLAA", "display"}, {"DLSS", "display"}, {"FSR_SHARPNESS", "display"}, {"DLSS_PRESET", "display"}, {"DLSS_CHAR_MASK", "display"}, {"DLSS_FIXED_EXPOSURE", "display"}, {"DLAA_EFFECTS_AFTER", "display"}, {"REFLEX", "display"}, {"FXAA", "display"},
|
||||
{"DEVICE_PROFILE", "display"}, {"ASSUME_FOCUS", "display"},
|
||||
{"DISCORD_RPC", "discord"}, {"DISCORD_APP_ID", "discord"}, {"DISCORD_IMAGE", "discord"},
|
||||
{"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"GRASS_RANGE", "display"}, {"CONTACT_SHADOWS", "display"},
|
||||
{"PCSS", "display"},
|
||||
{"MODS_DIR", "mods"}, {"MODS_ORDER", "mods"}, {"MODS_DISABLED", "mods"}, {"MODS_REBUILD", "mods"},
|
||||
{"MODS_DIR", "mods"}, {"MODS_ORDER", "mods"}, {"MODS_DISABLED", "mods"}, {"MODS_NO_CODE", "mods"}, {"MODS_REBUILD", "mods"}, {"MODS_WITHOUT_CODE", "mods"},
|
||||
{"TEX_HEAP_EXTRA_MB", "mods"},
|
||||
{"MENU_LANG", "language"}, {"MENU_FONT_FONTCONFIG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
|
||||
{"VOLUME", "audio"}, {"VOLUME_MUSIC", "audio"}, {"VOLUME_SFX", "audio"}, {"VOLUME_VOICE", "audio"}, {"AUDIO_CHANNELS", "audio"},
|
||||
{"AUDIO_DEVICE", "audio"},
|
||||
{"MOTION", "input"}, {"GYRO_CALIBRATION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
|
||||
{"MOTION", "input"}, {"GYRO_CALIBRATION", "input"}, {"GYRO_AUTO_BIAS", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
|
||||
{"GYRO_BIAS_X", "input"}, {"GYRO_BIAS_Y", "input"}, {"GYRO_BIAS_Z", "input"}, {"GYRO_BIAS_PAD", "input"},
|
||||
{"PAD_LAYOUT", "input"}, {"PROMPTS", "input"}, {"STICK_DEADZONE", "input"}, {"LSTICK_DEADZONE", "input"}, {"RSTICK_DEADZONE", "input"},
|
||||
{"STICK_SENS", "input"},
|
||||
{"MENU_CURSOR", "input"}, {"MAP_CLICK", "input"}, {"DIALOGUE_CLICK", "input"}, {"POINTER_IMAGE", "input"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"INPUT_RECORD", "input"},
|
||||
{"MENU_CURSOR", "input"}, {"MAP_CLICK", "input"}, {"DIALOGUE_CLICK", "input"}, {"POINTER_IMAGE", "input"}, {"QUICKSAVE", "input"}, {"QUICKSAVE_KEY", "input"}, {"QUICKLOAD_KEY", "input"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"FREECAM_PATCH", "input"}, {"FREECAM_PAD", "input"}, {"FREECAM_KEY", "input"}, {"INPUT_RECORD", "input"},
|
||||
{"BIND_A", "input"}, {"BIND_B", "input"}, {"BIND_X", "input"}, {"BIND_Y", "input"}, {"BIND_LCLICK", "input"},
|
||||
{"BIND_RCLICK", "input"}, {"BIND_L", "input"}, {"BIND_R", "input"}, {"BIND_ZL", "input"}, {"BIND_ZR", "input"},
|
||||
{"BIND_PLUS", "input"}, {"BIND_MINUS", "input"}, {"BIND_LEFT", "input"}, {"BIND_UP", "input"},
|
||||
@@ -106,16 +108,16 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"BIND_RSTICK_UP", "input"}, {"BIND_RSTICK_RIGHT", "input"}, {"BIND_RSTICK_DOWN", "input"}, {"BIND_SHAKE", "input"},
|
||||
{"ASYNC_PREEMPT", "performance"}, {"REPLAY_ASYNC", "performance"}, {"REPLAY_WORKERS", "performance"}, {"FREE_CORES", "performance"},
|
||||
{"TIMER_1MS", "performance"}, {"PIPE_WAIT", "performance"}, {"PIPE_SKIP", "performance"},
|
||||
{"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"PIPE_PREBUILD", "performance"},
|
||||
{"BARRIER_MERGE", "performance"}, {"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"PIPE_PREBUILD", "performance"},
|
||||
{"PREWARM_XLATE", "performance"}, {"GPL", "performance"}, {"ASTC", "performance"}, {"MEMORY", "performance"},
|
||||
{"TEX_ALIAS", "performance"}, {"TEX_VRAM_PRESSURE", "performance"}, {"TEX_RELEASED_MIB", "performance"}, {"TEX_BLOCK_MIB", "performance"}, {"VMA_BLOCK_MIB", "performance"}, {"ASTC_BC", "performance"}, {"LOD_GUARD", "performance"}, {"FIX_C0", "performance"}, {"FIX_ZERO", "performance"},
|
||||
{"BIND_SKIP", "performance"}, {"SHADER_MEMO", "performance"}, {"PIPE_MEMO", "performance"}, {"MEMX", "performance"}, {"BIND_INC", "performance"}, {"TEX_MEMO", "performance"}, {"VB_USED", "performance"}, {"DESC_TEMPLATE", "performance"},
|
||||
{"SYNC_AHEAD", "performance"}, {"SHADOW_DEFER", "performance"}, {"PUSH_SKIP", "performance"}, {"SPLIT_DRAWS", "performance"}, {"SPLIT_US", "performance"}, {"VK_VALIDATION", "performance"},
|
||||
{"VK_DYN_VERTEX", "performance"}, {"VK_DYN_A2C", "performance"}, {"VK_SUBGROUP_PIN", "performance"},
|
||||
{"OPTREF_GUARD", "performance"}, {"ABILITY_GUARD", "performance"}, {"REPORT_GUARD", "performance"},
|
||||
{"TRACE", "diagnostics"}, {"FLIGHT", "diagnostics"}, {"PASS_CRUMBS", "diagnostics"}, {"FLIGHT_SPIKE_MS", "diagnostics"},
|
||||
{"WB_FENCE_LIMIT", "diagnostics"}, {"WB_MERGE", "diagnostics"}, {"WB_EXACT", "diagnostics"},
|
||||
{"MV_SURVEY", "diagnostics"},
|
||||
{"TRACE", "diagnostics"}, {"FLIGHT", "diagnostics"}, {"PASS_CRUMBS", "diagnostics"}, {"ADDR_REPORT", "diagnostics"}, {"FLIGHT_SPIKE_MS", "diagnostics"},
|
||||
{"WB_FENCE_LIMIT", "diagnostics"}, {"WB_MERGE", "diagnostics"}, {"WB_EXACT", "diagnostics"}, {"WB_EAGER", "diagnostics"},
|
||||
{"MV_SURVEY", "diagnostics"}, {"PLUGIN_TRACE", "diagnostics"},
|
||||
{"GAMEPLAY_TWEAKS_ENABLED", "gameplay tweaks"}, {"GAMEPLAY_ULTRAHAND_ROTATE", "gameplay tweaks"},
|
||||
{"GAMEPLAY_ULTRAHAND_C_AXIS", "gameplay tweaks"}, {"GAMEPLAY_ULTRAHAND_DISTANCE", "gameplay tweaks"},
|
||||
{"GAMEPLAY_ITEM_WHEEL", "gameplay tweaks"}, {"GAMEPLAY_ITEM_AD", "gameplay tweaks"},
|
||||
@@ -136,10 +138,13 @@ static const CfgMeta metas[] = {
|
||||
{"VK_PRESENT", "mailbox", "mailbox|fifo|immediate", LIVE}, {"GPU_INDEX", "", NULL, RESTART},
|
||||
{"PERF_OVERLAY", "off", "off|fps|full", LIVE},
|
||||
{"OUTPUT_RES", "1920x1080", NULL, RESTART}, {"RENDER_SCALE", "game", "game|50|67|75|100|125|150|200", RESTART},
|
||||
{"HUD_WIDTH", "full", "full|21:9|16:9", RESTART},
|
||||
{"DYNAMIC_RES", "1", "0|1", LIVE}, // resolution.c res_dynres_live
|
||||
{"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE},
|
||||
{"DLAA", "0", "0|1", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE},
|
||||
{"DLSS_PRESET", "default", "default|k|j", LIVE},
|
||||
{"SCENE_UPSCALER", "off", "off|dlss|fsr3", RESTART}, {"DLAA", "0", "0|1", RESTART},
|
||||
{"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE},
|
||||
{"FSR_SHARPNESS", "80", "0..100", LIVE}, // vk_dlaa.c fsr_evaluate
|
||||
{"DLSS_PRESET", "default", "default|k|j", LIVE}, {"DLSS_FIXED_EXPOSURE", "0", "0|1", LIVE}, {"DLAA_EFFECTS_AFTER", "0", "0|1", LIVE},
|
||||
{"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"REFLEX", "off", "off|on|boost", RESTART}, {"FXAA", "1", "0|1", LIVE},
|
||||
{"LOD_STEADY", "0", "0|1", RESTART}, // sets steady
|
||||
{"ASPECT", "fit", "fit|stretch", LIVE}, {"MOVIE_ASPECT", "keep", "keep|stretch", LIVE}, {"FOV", "100", "70..140", LIVE},
|
||||
@@ -158,23 +163,26 @@ static const CfgMeta metas[] = {
|
||||
{"PCSS", "0", "0..200", RESTART},
|
||||
// Game
|
||||
{"FPS_LIMIT", "60", "30|40|45|60|90|120|144|display", LIVE}, {"FPS60", "1", "0|1", LIVE}, {"FRAME_QUEUE", "0", "0|1", LIVE},
|
||||
{"FRAME_GEN", "off", "off|fsr3", LIVE}, // the generator; vk_fg.cpp vk_fg_engine maps it
|
||||
{"REALTIME", "1", "0|1", RESTART}, {"CLOTH_REALTIME", "1", "0|1", RESTART},
|
||||
{"MODS_REBUILD", "auto", "auto|off", RESTART},
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART}, {"CLIMB_FIX", "1", "0|1", RESTART},
|
||||
{"MODS_WITHOUT_CODE", "0", "0|1", RESTART}, // 1: a mod is used without the code module it cannot run (mods.c)
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART}, {"CLIMB_FIX", "1", "0|1", RESTART}, {"AUDIO_DRAIN_FIX", "1", "0|1", RESTART},
|
||||
{"SHUTTER_FIX", "1", "0|1", RESTART},
|
||||
{"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR", RESTART},
|
||||
{"OPERATION_MODE", "docked", "docked|handheld", RESTART},
|
||||
{"ASSUME_FOCUS", "1", "0|1", LIVE}, // read on every focus change (ov_system.c)
|
||||
// Sound, Controls, Menu
|
||||
{"VOLUME", "100", "0..100", LIVE}, {"VOLUME_MUSIC", "100", "0..100", LIVE}, {"VOLUME_SFX", "100", "0..100", LIVE}, {"VOLUME_VOICE", "100", "0..100", LIVE}, {"AUDIO_CHANNELS", "stereo", "auto|stereo|5.1", RESTART},
|
||||
{"AUDIO_DEVICE", "", NULL, LIVE}, // audio_mixer.c output_worker: a device name, empty for the system default
|
||||
{"MOTION", "1", "0|1", LIVE}, {"GYRO_CALIBRATION", "1", "0|1", LIVE},
|
||||
{"MOTION", "1", "0|1", LIVE}, {"GYRO_CALIBRATION", "1", "0|1", LIVE}, {"GYRO_AUTO_BIAS", "0", "0|1", LIVE},
|
||||
{"RUMBLE_STRENGTH", "130", "0..300", LIVE}, {"RUMBLE_CURVE", "0.6", "0.2..1.5", LIVE},
|
||||
// Written by the Calibrate gyro row (motion_fusion.c save_bias), not by hand; read by input.c pad_bias_select when a
|
||||
// controller connects and gyro_bias_pad names it.
|
||||
{"GYRO_BIAS_X", "", NULL, RESTART}, {"GYRO_BIAS_Y", "", NULL, RESTART}, {"GYRO_BIAS_Z", "", NULL, RESTART},
|
||||
{"GYRO_BIAS_PAD", "", NULL, RESTART},
|
||||
{"RUMBLE_TRIGGERS", "0", "0|1", LIVE}, {"PAD_LAYOUT", "auto", "auto|nintendo|xbox", LIVE},
|
||||
{"PROMPTS", "nintendo", "nintendo|xbox|pc", RESTART},
|
||||
{"PROMPTS", "nintendo", "nintendo|xbox|playstation|pc", RESTART},
|
||||
{"STICK_DEADZONE", "8", "0..50", LIVE}, {"STICK_SENS", "1", "0.1..3", RESTART},
|
||||
{"LSTICK_DEADZONE", "", "0..50", LIVE}, {"RSTICK_DEADZONE", "", "0..50", LIVE},
|
||||
{"MOUSE_MODE", "direct", "stick|direct", LIVE},
|
||||
@@ -182,7 +190,11 @@ static const CfgMeta metas[] = {
|
||||
{"MAP_CLICK", "0", "0|1", LIVE}, // input.c: the left mouse button is A on the Purah Pad's map
|
||||
{"DIALOGUE_CLICK", "0", "0|1", LIVE}, // menu_cursor.c: in a dialogue box left click is B, right click A
|
||||
{"POINTER_IMAGE", "0", "0|1", LIVE}, // input_win.c / input_sdl.c: the game window's own pointer (cursor_art.c)
|
||||
{"QUICKSAVE", "0", "0|1", LIVE}, // quicksave.c: one key saves (an autosave), another loads it
|
||||
{"QUICKSAVE_KEY", "f6", NULL, LIVE}, {"QUICKLOAD_KEY", "f7", NULL, LIVE}, // Half-Life's keys; a key name or none
|
||||
{"WALK_KEY", "none", NULL, LIVE}, {"WALK_SCALE", "0.51", "0.2..0.9", LIVE},
|
||||
// freecam.c: the patch set of its hook (off: the game's camera code as shipped), then the combo and key that step it
|
||||
{"FREECAM_PATCH", "0", "0|1", RESTART}, {"FREECAM_PAD", "none", NULL, LIVE}, {"FREECAM_KEY", "none", NULL, LIVE},
|
||||
// Gameplay Tweaks
|
||||
{"GAMEPLAY_TWEAKS_ENABLED", "0", "0|1", LIVE},
|
||||
{"GAMEPLAY_ULTRAHAND_ROTATE", "1", "0|1", LIVE}, {"GAMEPLAY_ULTRAHAND_C_AXIS", "1", "0|1", LIVE},
|
||||
@@ -205,11 +217,11 @@ static const CfgMeta metas[] = {
|
||||
{"REPLAY_WORKERS", "0", "0..16", RESTART}, {"REPLAY_CHUNKS", "0", "0..64", RESTART},
|
||||
{"REPLAY_CHUNK_DRAWS", "128", "1..100000", RESTART}, {"REPLAY_STATE_CHECK", "0", "0|1", RESTART},
|
||||
{"REPLAY_SKEW_US", "0", "0..100000", RESTART},
|
||||
{"SYNC_AHEAD", "0", "0|1", RESTART}, {"SHADOW_DEFER", "1", "0|1", RESTART},
|
||||
{"SYNC_AHEAD", "0", "0|1|check", RESTART}, {"SHADOW_DEFER", "1", "0|1", RESTART},
|
||||
{"FREE_CORES", "0", "0|1", RESTART}, {"TIMER_1MS", "1", "0|1", RESTART},
|
||||
// shaders and pipelines
|
||||
{"PIPE_WAIT", "default", "default|draw", RESTART}, {"PIPE_SKIP", "fullscreen", "strict|any|fullscreen", RESTART},
|
||||
{"LIB_PREBUILD", "1", "0|1", RESTART}, {"LIB_PREBUILD_THREADS", "", "1..64", RESTART},
|
||||
{"BARRIER_MERGE", "0", "0|1", RESTART}, {"LIB_PREBUILD", "1", "0|1", RESTART}, {"LIB_PREBUILD_THREADS", "", "1..64", RESTART},
|
||||
{"PIPE_PREBUILD", "1", "0|1", RESTART}, {"PREWARM_XLATE", "", "1..64", RESTART}, {"GPL", "1", "0|1", RESTART},
|
||||
// textures and memory
|
||||
{"ASTC", "auto", "auto|gpu|native|cpu", RESTART}, {"MEMORY", "auto", "auto|import|mirror|verify", RESTART},
|
||||
@@ -230,7 +242,10 @@ static const CfgMeta metas[] = {
|
||||
// diagnostics
|
||||
{"TRACE", "", NULL, RESTART}, {"FLIGHT", "0", "0|1", RESTART}, {"FLIGHT_SPIKE_MS", "100", "0..60000", RESTART},
|
||||
{"WB_FENCE_LIMIT", "65536", "0..1073741824", RESTART}, {"WB_MERGE", "1", "0|1", RESTART}, {"WB_EXACT", "1", "0|1", RESTART},
|
||||
{"WB_EAGER", "1", "0|1|check", RESTART}, // vk_texture.c: part of sync_ahead; 0 and check for comparing
|
||||
{"PASS_CRUMBS", "", "0|1", RESTART}, // vk_crumbs.c pass marks; unset: VK_AMD_buffer_marker only
|
||||
{"ADDR_REPORT", "0", "0|1", RESTART}, // vk_device.c GPU address map for device faults
|
||||
{"PLUGIN_TRACE", "0", "0|1", RESTART}, // plugin_init.c: the first call of each mod plugin hook entry
|
||||
{"INPUT_RECORD", "", NULL, RESTART},
|
||||
};
|
||||
|
||||
@@ -383,8 +398,8 @@ static const char *raw_get(const char *name) {
|
||||
// picture between black bars. The sizes are the ones the installer lays the HUD out for (installer/steps.py
|
||||
// ASPECT_SIZES, ui/menu.cpp row_output_res): of the display's shape within 1%, the smallest at least 1080 high that fits
|
||||
// the display, else the largest that fits. A 16:9 display, an unknown one or one of another shape keeps 1920x1080.
|
||||
// Xbox and keyboard prompts need their folder for that size's shape too (romfs-patches-xbox-<w>x<h>, -xbox-label-,
|
||||
// -pc-, written by installer/steps.py Shapes for the style totk.ini selects and the connected displays' shapes): they
|
||||
// Xbox, PlayStation and keyboard prompts need their folder for that size's shape too (romfs-patches-<style>-<w>x<h>,
|
||||
// written by installer/steps.py Shapes for the style totk.ini selects and the connected displays' shapes): they
|
||||
// keep 1920x1080 when it is missing, as in a source build without make_romfs_patches.py --prompts <style> --aspect or
|
||||
// after a switch of prompts in the menu, where a default of another shape would trade the prompts the player chose for
|
||||
// the Switch ones.
|
||||
@@ -414,22 +429,21 @@ int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]) {
|
||||
}
|
||||
|
||||
static char screen_res[16]; // set once by cfg_init, "" for none
|
||||
// romfs-patches-xbox-, romfs-patches-xbox-label- and romfs-patches-pc-<screen_res> have a manifest (set once by
|
||||
// cfg_init)
|
||||
static const char *const screen_folders[3] = {"romfs-patches-xbox", "romfs-patches-xbox-label", "romfs-patches-pc"};
|
||||
static int screen_prompts[3];
|
||||
// Which pad and keyboard prompts' folders have a manifest at screen_res's shape (<folder>-<screen_res>; set once by
|
||||
// cfg_init): the folders input_map.c input_prompts_folder names
|
||||
static const char *const screen_folders[5] = {"romfs-patches-xbox", "romfs-patches-xbox-label",
|
||||
"romfs-patches-playstation", "romfs-patches-playstation-xbox",
|
||||
"romfs-patches-pc"};
|
||||
static int screen_prompts[5];
|
||||
|
||||
// Whether the prompts in effect have their folder at screen_res. The same picks as input_map.c input_prompts_pick and
|
||||
// input_prompts_folder: an unknown or empty value is the Nintendo prompts, an unset one Xbox while the pad layout is
|
||||
// "xbox_prompts"; the Xbox prompts take romfs-patches-xbox with the Nintendo pad layout (or "xbox_prompts") and
|
||||
// romfs-patches-xbox-label with any other.
|
||||
// Whether the prompts in effect have their folder at screen_res: the folder input_map.c input_prompts_pick and
|
||||
// input_prompts_folder pick at start. The game's own prompts need none.
|
||||
static int shape_keeps_prompts(void) {
|
||||
const char *p = raw_get(PREFIX "PROMPTS"), *l = raw_get(PREFIX "PAD_LAYOUT");
|
||||
if (p && *p && !strcasecmp(p, "pc")) return screen_prompts[2];
|
||||
int xbox = p && *p ? !strcasecmp(p, "xbox") : l && !strcasecmp(l, "xbox_prompts");
|
||||
if (!xbox) return 1;
|
||||
int by_position = l && (!strcasecmp(l, "nintendo") || !strcasecmp(l, "xbox_prompts"));
|
||||
return screen_prompts[by_position ? 0 : 1];
|
||||
const char *layout = raw_get(PREFIX "PAD_LAYOUT");
|
||||
const char *want = input_prompts_folder(input_prompts_pick(raw_get(PREFIX "PROMPTS"), layout), layout);
|
||||
for (int i = 0; want && i < 5; i++)
|
||||
if (!strcmp(screen_folders[i], want)) return screen_prompts[i];
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void screen_default(void) {
|
||||
@@ -447,13 +461,20 @@ static void screen_default(void) {
|
||||
if (best < 0) best = fit;
|
||||
if (best < 0) return;
|
||||
snprintf(screen_res, sizeof screen_res, "%ux%u", SHAPED[best][0], SHAPED[best][1]);
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 5; i++)
|
||||
screen_prompts[i] = romfs_shaped_prompts_ready(screen_folders[i], SHAPED[best][0], SHAPED[best][1]);
|
||||
if (!raw_get(PREFIX "OUTPUT_RES") && shape_keeps_prompts())
|
||||
rt_log("cfg: the display is %dx%d: output_res defaults to %s, its shape (totk.ini output_res sets another)", sw,
|
||||
sh, screen_res);
|
||||
}
|
||||
|
||||
int cfg_screen_size(unsigned out[2]) {
|
||||
unsigned w = 0, h = 0;
|
||||
if (raw_get(PREFIX "OUTPUT_RES") || !screen_res[0] || sscanf(screen_res, "%ux%u", &w, &h) != 2) return 0;
|
||||
out[0] = w, out[1] = h;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *cfg_get(const char *name) {
|
||||
const char *v = raw_get(name);
|
||||
if (v || strncmp(name, PREFIX, PREFIX_LEN)) return v;
|
||||
@@ -839,3 +860,11 @@ void cfg_init(void) {
|
||||
rt_log("cfg: device profile Steam Deck: defaults for the keys totk.ini does not set (TOTK_DEVICE_PROFILE=desktop "
|
||||
"turns it off)");
|
||||
}
|
||||
|
||||
// scene_upscaler, or for a totk.ini that predates it the dlaa switch it replaced: dlaa = 1 is DLSS, anything else off.
|
||||
// FSR 3.1 is never the answer for a player who did not pick it. An unknown value is off.
|
||||
const char *cfg_scene_upscaler(void) {
|
||||
if (!cfg_is_set("TOTK_SCENE_UPSCALER")) return cfg_bool("TOTK_DLAA") ? "dlss" : "off";
|
||||
const char *v = cfg_value("TOTK_SCENE_UPSCALER");
|
||||
return !strcmp(v, "dlss") ? "dlss" : !strcmp(v, "fsr3") ? "fsr3" : "off";
|
||||
}
|
||||
@@ -26,6 +26,12 @@ int cfg_is_set(const char *name);
|
||||
// The folder size of w x h's shape (cfg.c SHAPED: the closest aspect ratio within 1%, the first of equal ones), the
|
||||
// one romfs-patches-<w>x<h> the setup writes for it. 0 for 16:9 and for a shape without a UI layout.
|
||||
int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]);
|
||||
// The size output_res defaults to on this display (its shape, cfg.c screen_default) while the player set no
|
||||
// output_res, also when the default stays 1920x1080 because that shape lacks the prompts' folder. The generator the game
|
||||
// starts for missing folders (romfs.c romfs_folders_prepare) makes them for this size, so after a prompts change the
|
||||
// next start takes the display's shape again. 0 when the player set output_res, a device profile is in use or the
|
||||
// display is 16:9.
|
||||
int cfg_screen_size(unsigned out[2]);
|
||||
// The device profile in use, "deck" or "desktop" (TOTK_DEVICE_PROFILE, else what the machine is).
|
||||
const char *cfg_device_profile(void);
|
||||
// Writes the keys cfg_set changed since the last save into totk.ini next to totk.exe (cfg_save_to: the file at path).
|
||||
@@ -63,3 +69,15 @@ const char *cfg_value(const char *name);
|
||||
int cfg_int(const char *name);
|
||||
double cfg_double(const char *name);
|
||||
int cfg_bool(const char *name);
|
||||
// The 3D scene upscaler the settings name now: "off", "dlss" or "fsr3" (scene_upscaler; without it dlaa = 1 is "dlss").
|
||||
// The engine in use is the one named at start (vk_dlaa.c vk_upscaler_engine).
|
||||
const char *cfg_scene_upscaler(void);
|
||||
// vk_dlaa.c, the 3D scene upscaler (scene_upscaler): the engine picked at start (UPSCALER_*),
|
||||
// 1 while the settings still name it (the menu switches it off at once), the engine that is running (it
|
||||
// ran and has not failed; 0 none), and why an engine cannot run here (UPSCALER_MISSING_*, 0 it can).
|
||||
enum { UPSCALER_OFF, UPSCALER_DLSS, UPSCALER_FSR3 };
|
||||
enum { UPSCALER_MISSING_GPU = 1, UPSCALER_MISSING_DLL };
|
||||
int vk_upscaler_engine(void);
|
||||
int vk_upscaler_on(void);
|
||||
int vk_upscaler_running(void);
|
||||
int vk_upscaler_missing(int engine);
|
||||
+79
-2
@@ -6,6 +6,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "fs.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "input_map.h"
|
||||
@@ -135,6 +136,9 @@ int probe_cfg(void) {
|
||||
CHECK(m && EQ(m->def, "1") && m->live, "meta: fps60 defaults to 1 and is live");
|
||||
m = cfg_meta("ASYNC_PREEMPT");
|
||||
CHECK(m && EQ(m->values, "0|1|2") && !m->live, "meta: async_preempt takes 0|1|2 and needs a restart");
|
||||
m = cfg_meta("HUD_WIDTH");
|
||||
CHECK(m && EQ(m->def, "full") && EQ(m->values, "full|21:9|16:9") && !m->live,
|
||||
"meta: HUD width defaults to full and changes after restart");
|
||||
m = cfg_meta("totk_vk_present");
|
||||
CHECK(m && EQ(m->key, "VK_PRESENT") && EQ(m->values, "mailbox|fifo|immediate") && m->live,
|
||||
"meta: prefix and case are accepted");
|
||||
@@ -330,14 +334,27 @@ int probe_cfg(void) {
|
||||
EQ(input_prompts_folder(PROMPTS_XBOX, "auto"), "romfs-patches-xbox-label") &&
|
||||
EQ(input_prompts_folder(PROMPTS_XBOX, NULL), "romfs-patches-xbox-label"),
|
||||
"prompts: the face buttons by position for the Nintendo layout, by label for xbox and auto");
|
||||
CHECK(input_prompts_pick("PlayStation", "nintendo") == PROMPTS_PLAYSTATION &&
|
||||
input_prompts_pick("playstation", "xbox") == PROMPTS_PLAYSTATION &&
|
||||
input_prompts_pick("ps", "auto") == PROMPTS_PLAYSTATION,
|
||||
"prompts: PlayStation, any case");
|
||||
CHECK(EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "nintendo"), "romfs-patches-playstation") &&
|
||||
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "xbox_prompts"), "romfs-patches-playstation") &&
|
||||
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "xbox"), "romfs-patches-playstation-xbox") &&
|
||||
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "auto"), "romfs-patches-playstation-xbox") &&
|
||||
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, NULL), "romfs-patches-playstation-xbox"),
|
||||
"prompts: the PlayStation shapes by position for the Nintendo layout, by label for xbox and auto");
|
||||
// romfs-patches-xbox shows A as B (tests/romfs_prompts_test.py checks the folders' contents). It is right exactly
|
||||
// where the layout puts A on the east button, which an Xbox pad labels B.
|
||||
// where the layout puts A on the east button, which an Xbox pad labels B. The PlayStation folder shows A as the
|
||||
// circle there, so its name follows the same split.
|
||||
input_map_reset();
|
||||
static const char *const layouts[] = {"nintendo", "xbox", "auto", "xbox_prompts"};
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int a_east = input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_EAST] = 1}, input_pad_layout_pick(layouts[i], 0)) == 1ull << B_A;
|
||||
CHECK(a_east == EQ(input_prompts_folder(PROMPTS_XBOX, layouts[i]), "romfs-patches-xbox"),
|
||||
"prompts: the folder names A as B exactly when the layout puts A on the button labelled B");
|
||||
CHECK(a_east == EQ(input_prompts_folder(PROMPTS_PLAYSTATION, layouts[i]), "romfs-patches-playstation"),
|
||||
"prompts: the PlayStation folder puts A on the circle exactly when the layout puts A on the east button");
|
||||
}
|
||||
// One folder per screen shape (cfg.c cfg_shape_size, installer/screens.py shape_size): the closest aspect ratio of
|
||||
// SHAPED within 1%, the first of equal ones; 16:9 and unlisted shapes have none.
|
||||
@@ -363,12 +380,68 @@ int probe_cfg(void) {
|
||||
}
|
||||
snprintf(f, sizeof f, "%s/romfs-index.bin", dir);
|
||||
plat_setenv("TOTK_ROMFS_INDEX", f);
|
||||
plat_setenv("TOTK_HUD_WIDTH", NULL);
|
||||
static const char *const capped[] = {"romfs-patches-2560x1080-hud16x9",
|
||||
"romfs-patches-xbox-2560x1080-hud16x9",
|
||||
"romfs-patches-3840x1080-hud21x9"};
|
||||
for (size_t i = 0; i < sizeof capped / sizeof *capped; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, capped[i]);
|
||||
plat_file_delete(f);
|
||||
}
|
||||
cfg_set("TOTK_HUD_WIDTH", "full");
|
||||
CHECK(romfs_shaped_ready(2560, 1080) && romfs_shaped_ready(5120, 2160) && !romfs_shaped_ready(3440, 1440),
|
||||
"shape: 5120x2160 finds 2560x1080's layout folder, 3440x1440 does not");
|
||||
CHECK(romfs_shaped_prompts_ready("romfs-patches-xbox", 5120, 2160) &&
|
||||
!romfs_shaped_prompts_ready("romfs-patches-xbox", 2560, 1080) &&
|
||||
!romfs_shaped_prompts_ready("romfs-patches-pc", 5120, 2160),
|
||||
"shape: an older install's exact-size prompts folder serves that size only");
|
||||
cfg_set("TOTK_HUD_WIDTH", "16:9");
|
||||
CHECK(romfs_shaped_ready(5120, 2160) && romfs_folders_missing(5120, 2160, NULL) == ROMFS_NEED_LAYOUT,
|
||||
"HUD: a full layout allows wide output but does not hide a missing selected cap");
|
||||
for (size_t i = 0; i < sizeof capped / sizeof *capped; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s", dir, capped[i]);
|
||||
plat_file_mkdir_p(f);
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, capped[i]);
|
||||
plat_file_write(f, "#\n", 2);
|
||||
}
|
||||
CHECK(romfs_folders_missing(5120, 2160, "romfs-patches-xbox") == ROMFS_NEED_PROMPTS &&
|
||||
romfs_folders_missing(5120, 2160, "romfs-patches-pc") ==
|
||||
(ROMFS_NEED_PROMPTS | ROMFS_NEED_SHAPED_PROMPTS),
|
||||
"HUD: canonical capped layouts serve aliases, including Xbox; missing PC prompts still need preparation");
|
||||
cfg_set("TOTK_HUD_WIDTH", "21:9");
|
||||
CHECK(romfs_folders_missing(5120, 2160, NULL) && !romfs_folders_missing(5120, 1440, NULL),
|
||||
"HUD: a different cap needs a different folder; 5120x1440 uses the 3840x1080 shape");
|
||||
cfg_set("TOTK_HUD_WIDTH", "full");
|
||||
CHECK(!romfs_shaped_ready(5120, 1440), "HUD: switching to full does not reuse a capped-only layout");
|
||||
cfg_set("TOTK_HUD_WIDTH", "21:9");
|
||||
CHECK(!romfs_folders_missing(1920, 1080, NULL), "HUD: 16:9 output ignores a wider cap");
|
||||
// The 16:9 prompts' folder is needed at every shape (an older setup or a failed step left it out); at 16:9
|
||||
// nothing shaped is
|
||||
CHECK(romfs_folders_missing(1920, 1080, "romfs-patches-playstation") == ROMFS_NEED_PROMPTS &&
|
||||
romfs_folders_missing(2560, 1440, "romfs-patches-playstation") == ROMFS_NEED_PROMPTS,
|
||||
"folders: missing 16:9 prompts are asked for at 16:9, without a shaped folder");
|
||||
snprintf(f, sizeof f, "%s/romfs-patches-playstation", dir);
|
||||
plat_file_mkdir_p(f);
|
||||
snprintf(f, sizeof f, "%s/romfs-patches-playstation/manifest.tsv", dir);
|
||||
plat_file_write(f, "#\n", 2);
|
||||
CHECK(!romfs_folders_missing(1920, 1080, "romfs-patches-playstation") &&
|
||||
(romfs_folders_missing(5120, 2160, "romfs-patches-playstation") &
|
||||
(ROMFS_NEED_PROMPTS | ROMFS_NEED_SHAPED_PROMPTS)) == ROMFS_NEED_SHAPED_PROMPTS,
|
||||
"folders: present 16:9 prompts leave only the shaped folder to make");
|
||||
plat_file_delete(f);
|
||||
plat_setenv("TOTK_ROMFS_PATCHES", "0");
|
||||
CHECK(!romfs_folders_missing(5120, 2160, NULL) && !romfs_folders_missing(1920, 1080, "romfs-patches-pc"),
|
||||
"HUD: explicit overlay overrides do not request generated layouts or prompts");
|
||||
plat_setenv("TOTK_ROMFS_PATCHES", NULL);
|
||||
// Without build-cache/rebuild.txt (a source build) nothing starts: the menu's notes keep "run the setup
|
||||
// again" and the start spawns nothing (romfs.c overlay_init)
|
||||
CHECK(!romfs_folders_can_prepare() && !romfs_folders_prepare(5120, 2160, "romfs-patches-pc"),
|
||||
"folders: no setup's tools, no generator");
|
||||
cfg_set("TOTK_HUD_WIDTH", "full");
|
||||
for (size_t i = 0; i < sizeof capped / sizeof *capped; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, capped[i]);
|
||||
plat_file_delete(f);
|
||||
}
|
||||
plat_setenv("TOTK_ROMFS_INDEX", NULL);
|
||||
}
|
||||
uint8_t pd[PAD_COUNT] = {0};
|
||||
@@ -496,7 +569,11 @@ int probe_cfg(void) {
|
||||
char name[96];
|
||||
snprintf(name, sizeof name, "TOTK_%s", m->key);
|
||||
plat_setenv(name, "");
|
||||
CHECK(EQ(cfg_value(name), m->def), "cfg_value returns the table default");
|
||||
// cfg_get may supply a display or device-profile default (notably OUTPUT_RES on an ultrawide monitor).
|
||||
// The metadata default is used only when those leave the setting unset.
|
||||
const char *effective = cfg_get(name);
|
||||
CHECK(EQ(cfg_value(name), effective && *effective ? effective : m->def),
|
||||
"cfg_value uses the effective default, falling back to the metadata table");
|
||||
int ok = 0;
|
||||
if (!m->values) ok = 1;
|
||||
else if (strstr(m->values, "..")) {
|
||||
|
||||
+16
-7
@@ -516,9 +516,13 @@ static void plain_name(char *s) {
|
||||
|
||||
// ---- rebuild: code cheats and ExeFS patches the build lacks
|
||||
// The setup writes build-cache\rebuild.txt (installer/steps.py write_rebuild_command), the command that starts its
|
||||
// window in rebuild mode on this install folder, one argument per line. When an enabled mod has code cheats this build
|
||||
// lacks (CHEAT_REBUILD) or ExeFS patch files it lacks (mods_exefs_pending), the game runs it and exits; the setup lifts
|
||||
// and compiles them in and starts the game again.
|
||||
// window in rebuild mode on this install folder, one argument per line. The build kit's command (installer/layout.py)
|
||||
// is relative to the install folder: its program is taken from this exe's folder, and the command runs with that
|
||||
// folder as its working folder, against which the setup resolves its other arguments. When an enabled mod has code
|
||||
// cheats this build
|
||||
// lacks (CHEAT_REBUILD) or ExeFS patch files it lacks (mods_exefs_pending), or the build has a mod plugin whose file is
|
||||
// gone (ldr_plugins_gone: its mod was removed), the game runs it and exits; the setup lifts and compiles them in (or the
|
||||
// plugin out) and starts the game again.
|
||||
// build-cache\rebuild.skip holds the key of the cheats a rebuild was started for: a rebuild that failed or was
|
||||
// cancelled leaves them unbuilt, and the same set does not start it again. TOTK_MODS_REBUILD=off never starts it.
|
||||
// Scripted runs (--seconds, --boot) never start it.
|
||||
@@ -532,7 +536,7 @@ static void rebuild_if_needed(const char *dir) {
|
||||
key = (key ^ fnv(c->info.key, strlen(c->info.key))) * 0x01000193u;
|
||||
key = (key ^ c->content) * 0x01000193u;
|
||||
}
|
||||
int patches = mods_exefs_pending(&key);
|
||||
int patches = mods_exefs_pending(&key) + ldr_plugins_gone(&key);
|
||||
if (!need && !patches) return;
|
||||
char cmd_path[PLAT_PATH_MAX + 64], skip_path[PLAT_PATH_MAX + 64], skip[16] = "", want[16];
|
||||
snprintf(cmd_path, sizeof cmd_path, "%sbuild-cache" SEP "rebuild.txt", dir);
|
||||
@@ -548,12 +552,13 @@ static void rebuild_if_needed(const char *dir) {
|
||||
char *cmd = why ? NULL : read_text(cmd_path);
|
||||
if (!why && !cmd) why = "no build-cache/rebuild.txt (a build without the setup)";
|
||||
if (why) {
|
||||
rt_log("cheats: %d code cheats and %d ExeFS patch files are not built into the game; no rebuild: %s", need,
|
||||
rt_log("cheats: %d code cheats and %d ExeFS patch files or plugins differ from the build; no rebuild: %s", need,
|
||||
patches, why);
|
||||
free(cmd);
|
||||
return;
|
||||
}
|
||||
const char *argv[32];
|
||||
char program[PLAT_PATH_MAX + 64];
|
||||
int argc = 0;
|
||||
for (char *line = cmd; line && *line && argc < 31;) {
|
||||
char *end = strchr(line, '\n'), *next = end ? end + 1 : NULL;
|
||||
@@ -564,13 +569,17 @@ static void rebuild_if_needed(const char *dir) {
|
||||
line = next;
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
// CreateProcess resolves a relative program against this process's working folder, which a shortcut may set
|
||||
if (argc && !plat_path_absolute(argv[0]) &&
|
||||
snprintf(program, sizeof program, "%s%s", dir, argv[0]) < (int)sizeof program)
|
||||
argv[0] = program;
|
||||
if (argc < 2 || !plat_file_write(skip_path, want, strlen(want))) {
|
||||
rt_log("cheats: %d code cheats and %d ExeFS patch files are not built into the game; cannot start the "
|
||||
rt_log("cheats: %d code cheats and %d ExeFS patch files or plugins differ from the build; cannot start the "
|
||||
"rebuild (%s)", need, patches, cmd_path);
|
||||
free(cmd);
|
||||
return;
|
||||
}
|
||||
rt_log("cheats: %d code cheats and %d ExeFS patch files are not built into the game; starting the rebuild: %s",
|
||||
rt_log("cheats: %d code cheats and %d ExeFS patch files or plugins differ from the build; starting the rebuild: %s",
|
||||
need, patches, argv[0]);
|
||||
int ok = plat_spawn(argv, dir);
|
||||
free(cmd);
|
||||
|
||||
+218
-199
@@ -1,9 +1,9 @@
|
||||
// Generated by tools/build_shaders.py from runtime/shaders/contact_shadow.comp; do not edit.
|
||||
// source sha256 88275d28f96ea19281dbcd08a440ff79821716210894596ffb05ba7bc572dc9a
|
||||
// source sha256 e44a73a42aed3d5c2ac3a0a7e8809234f6175f8e331d30f93331ae9ca32fda71
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
static const uint32_t contact_shadow_spv[] = {
|
||||
0x07230203, 0x00010300, 0x000d000b, 0x000003e4, 0x00000000, 0x00020011, 0x00000001, 0x00020011,
|
||||
0x07230203, 0x00010300, 0x000d000b, 0x0000040b, 0x00000000, 0x00020011, 0x00000001, 0x00020011,
|
||||
0x00000031, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
||||
0x00000000, 0x00000001, 0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x0000011f,
|
||||
0x00060010, 0x00000004, 0x00000011, 0x00000008, 0x00000008, 0x00000001, 0x00030047, 0x00000033,
|
||||
@@ -11,8 +11,9 @@ static const uint32_t contact_shadow_spv[] = {
|
||||
0x00000001, 0x00000023, 0x00000010, 0x00050048, 0x00000033, 0x00000002, 0x00000023, 0x00000020,
|
||||
0x00050048, 0x00000033, 0x00000003, 0x00000023, 0x00000030, 0x00040047, 0x00000086, 0x00000021,
|
||||
0x00000000, 0x00040047, 0x00000086, 0x00000022, 0x00000000, 0x00040047, 0x0000011f, 0x0000000b,
|
||||
0x0000001c, 0x00040047, 0x000001ff, 0x00000021, 0x00000001, 0x00040047, 0x000001ff, 0x00000022,
|
||||
0x00000000, 0x00040047, 0x0000021c, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021,
|
||||
0x0000001c, 0x00040047, 0x00000162, 0x00000021, 0x00000002, 0x00040047, 0x00000162, 0x00000022,
|
||||
0x00000000, 0x00040047, 0x00000172, 0x00000021, 0x00000001, 0x00040047, 0x00000172, 0x00000022,
|
||||
0x00000000, 0x00040047, 0x00000242, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021,
|
||||
0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006,
|
||||
0x00000002, 0x00040017, 0x0000000a, 0x00000006, 0x00000003, 0x00040015, 0x00000019, 0x00000020,
|
||||
0x00000001, 0x00040017, 0x0000001a, 0x00000019, 0x00000002, 0x0004002b, 0x00000006, 0x00000027,
|
||||
@@ -34,22 +35,23 @@ static const uint32_t contact_shadow_spv[] = {
|
||||
0x00000000, 0x00040017, 0x0000011d, 0x0000002c, 0x00000003, 0x00040020, 0x0000011e, 0x00000001,
|
||||
0x0000011d, 0x0004003b, 0x0000011e, 0x0000011f, 0x00000001, 0x00040017, 0x00000120, 0x0000002c,
|
||||
0x00000002, 0x0004002b, 0x00000006, 0x00000140, 0x3f7fbe77, 0x0004002b, 0x00000006, 0x0000014c,
|
||||
0x42a00000, 0x0004002b, 0x00000006, 0x00000161, 0x3e99999a, 0x0004002b, 0x0000002c, 0x00000173,
|
||||
0x00000003, 0x0004002b, 0x00000006, 0x00000179, 0x3ecccccd, 0x0004002b, 0x00000006, 0x0000017a,
|
||||
0x40400000, 0x0004002b, 0x00000006, 0x0000017e, 0x3e19999a, 0x0004002b, 0x00000006, 0x00000180,
|
||||
0x3c23d70a, 0x0004002b, 0x00000006, 0x00000189, 0x3e800000, 0x0004002b, 0x00000019, 0x00000198,
|
||||
0x00000010, 0x0004002b, 0x00000006, 0x000001a4, 0xbd4ccccd, 0x0005002c, 0x00000007, 0x000001ae,
|
||||
0x00000110, 0x00000110, 0x00040017, 0x000001af, 0x000000b1, 0x00000002, 0x0005002c, 0x00000007,
|
||||
0x000001b6, 0x00000029, 0x00000029, 0x0004002b, 0x00000006, 0x000001d2, 0x3ca3d70a, 0x0004002b,
|
||||
0x00000006, 0x000001d4, 0x3b03126f, 0x0004002b, 0x00000006, 0x000001e9, 0x42200000, 0x0004002b,
|
||||
0x00000019, 0x000001f7, 0x00000003, 0x00090019, 0x000001fd, 0x00000006, 0x00000001, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000002, 0x00000008, 0x00040020, 0x000001fe, 0x00000000, 0x000001fd,
|
||||
0x0004003b, 0x000001fe, 0x000001ff, 0x00000000, 0x0004002b, 0x0000002c, 0x0000021b, 0x00000008,
|
||||
0x0006002c, 0x0000011d, 0x0000021c, 0x0000021b, 0x0000021b, 0x0000003b, 0x0005002c, 0x00000007,
|
||||
0x000003df, 0x0000004e, 0x0000004e, 0x0005002c, 0x0000001a, 0x000003e0, 0x00000077, 0x00000077,
|
||||
0x0004002b, 0x00000006, 0x000003e2, 0x3dcccccd, 0x0004002b, 0x00000006, 0x000003e3, 0x3d800000,
|
||||
0x42a00000, 0x0004002b, 0x00000019, 0x0000015b, 0x00000003, 0x0004003b, 0x00000085, 0x00000162,
|
||||
0x00000000, 0x0004002b, 0x0000002c, 0x00000166, 0x00000003, 0x0004002b, 0x00000006, 0x0000016c,
|
||||
0x3fc00000, 0x00090019, 0x00000170, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000002, 0x00000008, 0x00040020, 0x00000171, 0x00000000, 0x00000170, 0x0004003b, 0x00000171,
|
||||
0x00000172, 0x00000000, 0x0004002b, 0x00000006, 0x0000018a, 0x3e99999a, 0x0004002b, 0x00000006,
|
||||
0x000001a1, 0x3ecccccd, 0x0004002b, 0x00000006, 0x000001a2, 0x40400000, 0x0004002b, 0x00000006,
|
||||
0x000001a6, 0x3e19999a, 0x0004002b, 0x00000006, 0x000001a8, 0x3c23d70a, 0x0004002b, 0x00000006,
|
||||
0x000001b1, 0x3e800000, 0x0004002b, 0x00000019, 0x000001c0, 0x00000010, 0x0004002b, 0x00000006,
|
||||
0x000001cc, 0xbd4ccccd, 0x0005002c, 0x00000007, 0x000001d6, 0x00000110, 0x00000110, 0x00040017,
|
||||
0x000001d7, 0x000000b1, 0x00000002, 0x0005002c, 0x00000007, 0x000001de, 0x00000029, 0x00000029,
|
||||
0x0004002b, 0x00000006, 0x000001fa, 0x3ca3d70a, 0x0004002b, 0x00000006, 0x000001fc, 0x3b03126f,
|
||||
0x0004002b, 0x00000006, 0x00000211, 0x42200000, 0x0004002b, 0x0000002c, 0x00000241, 0x00000008,
|
||||
0x0006002c, 0x0000011d, 0x00000242, 0x00000241, 0x00000241, 0x0000003b, 0x0005002c, 0x00000007,
|
||||
0x00000406, 0x0000004e, 0x0000004e, 0x0005002c, 0x0000001a, 0x00000407, 0x00000077, 0x00000077,
|
||||
0x0004002b, 0x00000006, 0x00000409, 0x3dcccccd, 0x0004002b, 0x00000006, 0x0000040a, 0x3d800000,
|
||||
0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x000300f7,
|
||||
0x0000021d, 0x00000000, 0x000300fb, 0x0000002d, 0x0000021e, 0x000200f8, 0x0000021e, 0x0004003d,
|
||||
0x00000243, 0x00000000, 0x000300fb, 0x0000002d, 0x00000244, 0x000200f8, 0x00000244, 0x0004003d,
|
||||
0x0000011d, 0x00000121, 0x0000011f, 0x0007004f, 0x00000120, 0x00000122, 0x00000121, 0x00000121,
|
||||
0x00000000, 0x00000001, 0x0004007c, 0x0000001a, 0x00000123, 0x00000122, 0x00050051, 0x00000019,
|
||||
0x00000125, 0x00000123, 0x00000000, 0x00060041, 0x00000037, 0x00000126, 0x00000035, 0x00000071,
|
||||
@@ -60,196 +62,213 @@ static const uint32_t contact_shadow_spv[] = {
|
||||
0x00060041, 0x00000037, 0x0000012f, 0x00000035, 0x00000071, 0x0000003b, 0x0004003d, 0x00000006,
|
||||
0x00000130, 0x0000012f, 0x0004006e, 0x00000019, 0x00000131, 0x00000130, 0x000500af, 0x000000b1,
|
||||
0x00000132, 0x0000012e, 0x00000131, 0x000200f9, 0x0000012c, 0x000200f8, 0x0000012c, 0x000700f5,
|
||||
0x000000b1, 0x00000133, 0x00000129, 0x0000021e, 0x00000132, 0x0000012b, 0x000300f7, 0x00000135,
|
||||
0x000000b1, 0x00000133, 0x00000129, 0x00000244, 0x00000132, 0x0000012b, 0x000300f7, 0x00000135,
|
||||
0x00000000, 0x000400fa, 0x00000133, 0x00000134, 0x00000135, 0x000200f8, 0x00000134, 0x000200f9,
|
||||
0x0000021d, 0x000200f8, 0x00000135, 0x0004003d, 0x00000084, 0x00000138, 0x00000086, 0x00040064,
|
||||
0x00000243, 0x000200f8, 0x00000135, 0x0004003d, 0x00000084, 0x00000138, 0x00000086, 0x00040064,
|
||||
0x00000083, 0x0000013a, 0x00000138, 0x0007005f, 0x00000032, 0x0000013b, 0x0000013a, 0x00000123,
|
||||
0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x0000013c, 0x0000013b, 0x00000000, 0x000500bc,
|
||||
0x000000b1, 0x0000013e, 0x0000013c, 0x00000110, 0x000500be, 0x000000b1, 0x00000141, 0x0000013c,
|
||||
0x00000140, 0x000500a6, 0x000000b1, 0x00000142, 0x0000013e, 0x00000141, 0x000300f7, 0x00000144,
|
||||
0x00000000, 0x000400fa, 0x00000142, 0x00000143, 0x00000144, 0x000200f8, 0x00000143, 0x000200f9,
|
||||
0x0000021d, 0x000200f8, 0x00000144, 0x00060041, 0x00000037, 0x00000148, 0x00000035, 0x00000036,
|
||||
0x00000243, 0x000200f8, 0x00000144, 0x00060041, 0x00000037, 0x00000148, 0x00000035, 0x00000036,
|
||||
0x0000004a, 0x0004003d, 0x00000006, 0x00000149, 0x00000148, 0x00050085, 0x00000006, 0x0000014a,
|
||||
0x0000013c, 0x00000149, 0x000500ba, 0x000000b1, 0x0000014d, 0x0000014a, 0x0000014c, 0x000300f7,
|
||||
0x0000014f, 0x00000000, 0x000400fa, 0x0000014d, 0x0000014e, 0x0000014f, 0x000200f8, 0x0000014e,
|
||||
0x000200f9, 0x0000021d, 0x000200f8, 0x0000014f, 0x0004006f, 0x00000007, 0x00000153, 0x00000123,
|
||||
0x00050081, 0x00000007, 0x00000155, 0x00000153, 0x000003df, 0x00050041, 0x00000072, 0x00000156,
|
||||
0x000200f9, 0x00000243, 0x000200f8, 0x0000014f, 0x0004006f, 0x00000007, 0x00000153, 0x00000123,
|
||||
0x00050081, 0x00000007, 0x00000155, 0x00000153, 0x00000406, 0x00050041, 0x00000072, 0x00000156,
|
||||
0x00000035, 0x00000071, 0x0004003d, 0x00000032, 0x00000157, 0x00000156, 0x0007004f, 0x00000007,
|
||||
0x00000158, 0x00000157, 0x00000157, 0x00000002, 0x00000003, 0x00050085, 0x00000007, 0x00000159,
|
||||
0x00000155, 0x00000158, 0x0005008e, 0x00000007, 0x00000226, 0x00000159, 0x00000027, 0x00050083,
|
||||
0x00000007, 0x00000228, 0x00000226, 0x000001b6, 0x00050051, 0x00000006, 0x0000022a, 0x00000228,
|
||||
0x00000000, 0x00050085, 0x00000006, 0x0000022c, 0x0000022a, 0x0000014a, 0x00060041, 0x00000037,
|
||||
0x0000022d, 0x00000035, 0x00000036, 0x0000002d, 0x0004003d, 0x00000006, 0x0000022e, 0x0000022d,
|
||||
0x00050088, 0x00000006, 0x0000022f, 0x0000022c, 0x0000022e, 0x00050051, 0x00000006, 0x00000231,
|
||||
0x00000228, 0x00000001, 0x0004007f, 0x00000006, 0x00000232, 0x00000231, 0x00050085, 0x00000006,
|
||||
0x00000234, 0x00000232, 0x0000014a, 0x00060041, 0x00000037, 0x00000235, 0x00000035, 0x00000036,
|
||||
0x0000003b, 0x0004003d, 0x00000006, 0x00000236, 0x00000235, 0x00050088, 0x00000006, 0x00000237,
|
||||
0x00000234, 0x00000236, 0x0004007f, 0x00000006, 0x00000239, 0x0000014a, 0x00060050, 0x0000000a,
|
||||
0x0000023a, 0x0000022f, 0x00000237, 0x00000239, 0x0007004f, 0x00000007, 0x00000250, 0x00000157,
|
||||
0x00000157, 0x00000000, 0x00000001, 0x0004006e, 0x0000001a, 0x00000251, 0x00000250, 0x00050082,
|
||||
0x0000001a, 0x00000253, 0x00000251, 0x000003e0, 0x00050082, 0x0000001a, 0x00000255, 0x00000123,
|
||||
0x0000009d, 0x0008000c, 0x0000001a, 0x000002c8, 0x00000001, 0x0000002d, 0x00000255, 0x00000070,
|
||||
0x00000253, 0x0004006f, 0x00000007, 0x000002ca, 0x000002c8, 0x00050081, 0x00000007, 0x000002cc,
|
||||
0x000002ca, 0x000003df, 0x00050085, 0x00000007, 0x000002d0, 0x000002cc, 0x00000158, 0x0004003d,
|
||||
0x00000084, 0x000002d1, 0x00000086, 0x00040064, 0x00000083, 0x000002d3, 0x000002d1, 0x0007005f,
|
||||
0x00000032, 0x000002d4, 0x000002d3, 0x000002c8, 0x00000002, 0x00000036, 0x00050051, 0x00000006,
|
||||
0x000002d5, 0x000002d4, 0x00000000, 0x00050085, 0x00000006, 0x000002d8, 0x000002d5, 0x00000149,
|
||||
0x0005008e, 0x00000007, 0x000002de, 0x000002d0, 0x00000027, 0x00050083, 0x00000007, 0x000002e0,
|
||||
0x000002de, 0x000001b6, 0x00050051, 0x00000006, 0x000002e2, 0x000002e0, 0x00000000, 0x00050085,
|
||||
0x00000006, 0x000002e4, 0x000002e2, 0x000002d8, 0x00050088, 0x00000006, 0x000002e7, 0x000002e4,
|
||||
0x0000022e, 0x00050051, 0x00000006, 0x000002e9, 0x000002e0, 0x00000001, 0x0004007f, 0x00000006,
|
||||
0x000002ea, 0x000002e9, 0x00050085, 0x00000006, 0x000002ec, 0x000002ea, 0x000002d8, 0x00050088,
|
||||
0x00000006, 0x000002ef, 0x000002ec, 0x00000236, 0x0004007f, 0x00000006, 0x000002f1, 0x000002d8,
|
||||
0x00060050, 0x0000000a, 0x000002f2, 0x000002e7, 0x000002ef, 0x000002f1, 0x00050080, 0x0000001a,
|
||||
0x00000258, 0x00000123, 0x0000009d, 0x0008000c, 0x0000001a, 0x000002fe, 0x00000001, 0x0000002d,
|
||||
0x00000258, 0x00000070, 0x00000253, 0x0004006f, 0x00000007, 0x00000300, 0x000002fe, 0x00050081,
|
||||
0x00000007, 0x00000302, 0x00000300, 0x000003df, 0x00050085, 0x00000007, 0x00000306, 0x00000302,
|
||||
0x00000158, 0x0004003d, 0x00000084, 0x00000307, 0x00000086, 0x00040064, 0x00000083, 0x00000309,
|
||||
0x00000307, 0x0007005f, 0x00000032, 0x0000030a, 0x00000309, 0x000002fe, 0x00000002, 0x00000036,
|
||||
0x00050051, 0x00000006, 0x0000030b, 0x0000030a, 0x00000000, 0x00050085, 0x00000006, 0x0000030e,
|
||||
0x0000030b, 0x00000149, 0x0005008e, 0x00000007, 0x00000314, 0x00000306, 0x00000027, 0x00050083,
|
||||
0x00000007, 0x00000316, 0x00000314, 0x000001b6, 0x00050051, 0x00000006, 0x00000318, 0x00000316,
|
||||
0x00000000, 0x00050085, 0x00000006, 0x0000031a, 0x00000318, 0x0000030e, 0x00050088, 0x00000006,
|
||||
0x0000031d, 0x0000031a, 0x0000022e, 0x00050051, 0x00000006, 0x0000031f, 0x00000316, 0x00000001,
|
||||
0x0004007f, 0x00000006, 0x00000320, 0x0000031f, 0x00050085, 0x00000006, 0x00000322, 0x00000320,
|
||||
0x0000030e, 0x00050088, 0x00000006, 0x00000325, 0x00000322, 0x00000236, 0x0004007f, 0x00000006,
|
||||
0x00000327, 0x0000030e, 0x00060050, 0x0000000a, 0x00000328, 0x0000031d, 0x00000325, 0x00000327,
|
||||
0x00050082, 0x0000001a, 0x0000025b, 0x00000123, 0x000000a8, 0x0008000c, 0x0000001a, 0x00000334,
|
||||
0x00000001, 0x0000002d, 0x0000025b, 0x00000070, 0x00000253, 0x0004006f, 0x00000007, 0x00000336,
|
||||
0x00000334, 0x00050081, 0x00000007, 0x00000338, 0x00000336, 0x000003df, 0x00050085, 0x00000007,
|
||||
0x0000033c, 0x00000338, 0x00000158, 0x0004003d, 0x00000084, 0x0000033d, 0x00000086, 0x00040064,
|
||||
0x00000083, 0x0000033f, 0x0000033d, 0x0007005f, 0x00000032, 0x00000340, 0x0000033f, 0x00000334,
|
||||
0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x00000341, 0x00000340, 0x00000000, 0x00050085,
|
||||
0x00000006, 0x00000344, 0x00000341, 0x00000149, 0x0005008e, 0x00000007, 0x0000034a, 0x0000033c,
|
||||
0x00000027, 0x00050083, 0x00000007, 0x0000034c, 0x0000034a, 0x000001b6, 0x00050051, 0x00000006,
|
||||
0x0000034e, 0x0000034c, 0x00000000, 0x00050085, 0x00000006, 0x00000350, 0x0000034e, 0x00000344,
|
||||
0x00050088, 0x00000006, 0x00000353, 0x00000350, 0x0000022e, 0x00050051, 0x00000006, 0x00000355,
|
||||
0x0000034c, 0x00000001, 0x0004007f, 0x00000006, 0x00000356, 0x00000355, 0x00050085, 0x00000006,
|
||||
0x00000358, 0x00000356, 0x00000344, 0x00050088, 0x00000006, 0x0000035b, 0x00000358, 0x00000236,
|
||||
0x0004007f, 0x00000006, 0x0000035d, 0x00000344, 0x00060050, 0x0000000a, 0x0000035e, 0x00000353,
|
||||
0x0000035b, 0x0000035d, 0x00050080, 0x0000001a, 0x0000025e, 0x00000123, 0x000000a8, 0x0008000c,
|
||||
0x0000001a, 0x0000036a, 0x00000001, 0x0000002d, 0x0000025e, 0x00000070, 0x00000253, 0x0004006f,
|
||||
0x00000007, 0x0000036c, 0x0000036a, 0x00050081, 0x00000007, 0x0000036e, 0x0000036c, 0x000003df,
|
||||
0x00050085, 0x00000007, 0x00000372, 0x0000036e, 0x00000158, 0x0004003d, 0x00000084, 0x00000373,
|
||||
0x00000086, 0x00040064, 0x00000083, 0x00000375, 0x00000373, 0x0007005f, 0x00000032, 0x00000376,
|
||||
0x00000375, 0x0000036a, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x00000377, 0x00000376,
|
||||
0x00000000, 0x00050085, 0x00000006, 0x0000037a, 0x00000377, 0x00000149, 0x0005008e, 0x00000007,
|
||||
0x00000380, 0x00000372, 0x00000027, 0x00050083, 0x00000007, 0x00000382, 0x00000380, 0x000001b6,
|
||||
0x00050051, 0x00000006, 0x00000384, 0x00000382, 0x00000000, 0x00050085, 0x00000006, 0x00000386,
|
||||
0x00000384, 0x0000037a, 0x00050088, 0x00000006, 0x00000389, 0x00000386, 0x0000022e, 0x00050051,
|
||||
0x00000006, 0x0000038b, 0x00000382, 0x00000001, 0x0004007f, 0x00000006, 0x0000038c, 0x0000038b,
|
||||
0x00050085, 0x00000006, 0x0000038e, 0x0000038c, 0x0000037a, 0x00050088, 0x00000006, 0x00000391,
|
||||
0x0000038e, 0x00000236, 0x0004007f, 0x00000006, 0x00000393, 0x0000037a, 0x00060050, 0x0000000a,
|
||||
0x00000394, 0x00000389, 0x00000391, 0x00000393, 0x000500aa, 0x000000b1, 0x00000262, 0x00000125,
|
||||
0x00000036, 0x000400a8, 0x000000b1, 0x00000263, 0x00000262, 0x000300f7, 0x0000027a, 0x00000000,
|
||||
0x000400fa, 0x00000263, 0x00000264, 0x0000027a, 0x000200f8, 0x00000264, 0x00050051, 0x00000019,
|
||||
0x00000268, 0x00000253, 0x00000000, 0x000500b1, 0x000000b1, 0x00000269, 0x00000125, 0x00000268,
|
||||
0x000300f7, 0x00000278, 0x00000000, 0x000400fa, 0x00000269, 0x0000026a, 0x00000278, 0x000200f8,
|
||||
0x0000026a, 0x00050083, 0x00000006, 0x0000026f, 0x0000014a, 0x0000030e, 0x0006000c, 0x00000006,
|
||||
0x00000270, 0x00000001, 0x00000004, 0x0000026f, 0x00050083, 0x00000006, 0x00000275, 0x000002d8,
|
||||
0x0000014a, 0x0006000c, 0x00000006, 0x00000276, 0x00000001, 0x00000004, 0x00000275, 0x000500b8,
|
||||
0x000000b1, 0x00000277, 0x00000270, 0x00000276, 0x000200f9, 0x00000278, 0x000200f8, 0x00000278,
|
||||
0x000700f5, 0x000000b1, 0x00000279, 0x00000269, 0x00000264, 0x00000277, 0x0000026a, 0x000200f9,
|
||||
0x0000027a, 0x000200f8, 0x0000027a, 0x000700f5, 0x000000b1, 0x0000027b, 0x00000262, 0x0000014f,
|
||||
0x00000279, 0x00000278, 0x00050051, 0x00000019, 0x0000027d, 0x00000123, 0x00000001, 0x000500aa,
|
||||
0x000000b1, 0x0000027e, 0x0000027d, 0x00000036, 0x000400a8, 0x000000b1, 0x0000027f, 0x0000027e,
|
||||
0x000300f7, 0x00000296, 0x00000000, 0x000400fa, 0x0000027f, 0x00000280, 0x00000296, 0x000200f8,
|
||||
0x00000280, 0x00050051, 0x00000019, 0x00000284, 0x00000253, 0x00000001, 0x000500b1, 0x000000b1,
|
||||
0x00000285, 0x0000027d, 0x00000284, 0x000300f7, 0x00000294, 0x00000000, 0x000400fa, 0x00000285,
|
||||
0x00000286, 0x00000294, 0x000200f8, 0x00000286, 0x00050083, 0x00000006, 0x0000028b, 0x0000014a,
|
||||
0x0000037a, 0x0006000c, 0x00000006, 0x0000028c, 0x00000001, 0x00000004, 0x0000028b, 0x00050083,
|
||||
0x00000006, 0x00000291, 0x00000344, 0x0000014a, 0x0006000c, 0x00000006, 0x00000292, 0x00000001,
|
||||
0x00000004, 0x00000291, 0x000500b8, 0x000000b1, 0x00000293, 0x0000028c, 0x00000292, 0x000200f9,
|
||||
0x00000294, 0x000200f8, 0x00000294, 0x000700f5, 0x000000b1, 0x00000295, 0x00000285, 0x00000280,
|
||||
0x00000293, 0x00000286, 0x000200f9, 0x00000296, 0x000200f8, 0x00000296, 0x000700f5, 0x000000b1,
|
||||
0x00000297, 0x0000027e, 0x0000027a, 0x00000295, 0x00000294, 0x000300f7, 0x000002a1, 0x00000000,
|
||||
0x000400fa, 0x0000027b, 0x00000299, 0x0000029d, 0x000200f8, 0x00000299, 0x00050083, 0x0000000a,
|
||||
0x0000029c, 0x00000328, 0x0000023a, 0x000200f9, 0x000002a1, 0x000200f8, 0x0000029d, 0x00050083,
|
||||
0x0000000a, 0x000002a0, 0x0000023a, 0x000002f2, 0x000200f9, 0x000002a1, 0x000200f8, 0x000002a1,
|
||||
0x000700f5, 0x0000000a, 0x000003d5, 0x0000029c, 0x00000299, 0x000002a0, 0x0000029d, 0x000300f7,
|
||||
0x000002ac, 0x00000000, 0x000400fa, 0x00000297, 0x000002a4, 0x000002a8, 0x000200f8, 0x000002a4,
|
||||
0x00050083, 0x0000000a, 0x000002a7, 0x00000394, 0x0000023a, 0x000200f9, 0x000002ac, 0x000200f8,
|
||||
0x000002a8, 0x00050083, 0x0000000a, 0x000002ab, 0x0000023a, 0x0000035e, 0x000200f9, 0x000002ac,
|
||||
0x000200f8, 0x000002ac, 0x000700f5, 0x0000000a, 0x000003d6, 0x000002a7, 0x000002a4, 0x000002ab,
|
||||
0x000002a8, 0x0007000c, 0x0000000a, 0x000002b0, 0x00000001, 0x00000044, 0x000003d5, 0x000003d6,
|
||||
0x0006000c, 0x0000000a, 0x000002b1, 0x00000001, 0x00000045, 0x000002b0, 0x00050094, 0x00000006,
|
||||
0x000002b4, 0x000002b1, 0x0000023a, 0x000500ba, 0x000000b1, 0x000002b5, 0x000002b4, 0x00000110,
|
||||
0x000300f7, 0x000002bb, 0x00000000, 0x000400fa, 0x000002b5, 0x000002b6, 0x000002b9, 0x000200f8,
|
||||
0x000002b6, 0x0004007f, 0x0000000a, 0x000002b8, 0x000002b1, 0x000200f9, 0x000002bb, 0x000200f8,
|
||||
0x000002b9, 0x000200f9, 0x000002bb, 0x000200f8, 0x000002bb, 0x000700f5, 0x0000000a, 0x000003d7,
|
||||
0x000002b8, 0x000002b6, 0x000002b1, 0x000002b9, 0x00050041, 0x00000072, 0x00000167, 0x00000035,
|
||||
0x00000077, 0x0004003d, 0x00000032, 0x00000168, 0x00000167, 0x0008004f, 0x0000000a, 0x00000169,
|
||||
0x00000168, 0x00000168, 0x00000000, 0x00000001, 0x00000002, 0x00050094, 0x00000006, 0x0000016a,
|
||||
0x000003d7, 0x00000169, 0x0008000c, 0x00000006, 0x0000016b, 0x00000001, 0x00000031, 0x00000110,
|
||||
0x00000161, 0x0000016a, 0x000500bd, 0x000000b1, 0x0000016e, 0x0000016b, 0x00000110, 0x000300f7,
|
||||
0x00000170, 0x00000000, 0x000400fa, 0x0000016e, 0x0000016f, 0x00000170, 0x000200f8, 0x0000016f,
|
||||
0x000200f9, 0x0000021d, 0x000200f8, 0x00000170, 0x00060041, 0x00000037, 0x00000174, 0x00000035,
|
||||
0x00000077, 0x00000173, 0x0004003d, 0x00000006, 0x00000175, 0x00000174, 0x00050085, 0x00000006,
|
||||
0x00000178, 0x0000014a, 0x000003e2, 0x0008000c, 0x00000006, 0x0000017b, 0x00000001, 0x0000002b,
|
||||
0x00000178, 0x00000179, 0x0000017a, 0x00050085, 0x00000006, 0x0000017c, 0x00000175, 0x0000017b,
|
||||
0x00050085, 0x00000006, 0x00000181, 0x0000014a, 0x00000180, 0x00050081, 0x00000006, 0x00000182,
|
||||
0x0000017e, 0x00000181, 0x00050085, 0x00000006, 0x00000186, 0x0000017c, 0x000003e3, 0x00050094,
|
||||
0x00000006, 0x00000398, 0x00000153, 0x00000068, 0x0006000c, 0x00000006, 0x00000399, 0x00000001,
|
||||
0x0000000a, 0x00000398, 0x00050085, 0x00000006, 0x0000039a, 0x00000064, 0x00000399, 0x0006000c,
|
||||
0x00000006, 0x0000039b, 0x00000001, 0x0000000a, 0x0000039a, 0x00050081, 0x00000006, 0x0000018e,
|
||||
0x00000189, 0x0000039b, 0x00050085, 0x00000006, 0x0000018f, 0x00000186, 0x0000018e, 0x000200f9,
|
||||
0x00000192, 0x000200f8, 0x00000192, 0x000700f5, 0x00000006, 0x000003d9, 0x0000018f, 0x00000170,
|
||||
0x000001e7, 0x00000195, 0x000700f5, 0x00000019, 0x000003d8, 0x00000036, 0x00000170, 0x000001e4,
|
||||
0x00000195, 0x000500b1, 0x000000b1, 0x00000199, 0x000003d8, 0x00000198, 0x000400f6, 0x00000194,
|
||||
0x00000195, 0x00000000, 0x000400fa, 0x00000199, 0x00000193, 0x00000194, 0x000200f8, 0x00000193,
|
||||
0x0005008e, 0x0000000a, 0x000001a0, 0x00000169, 0x000003d9, 0x00050081, 0x0000000a, 0x000001a1,
|
||||
0x0000023a, 0x000001a0, 0x00050051, 0x00000006, 0x000001a3, 0x000001a1, 0x00000002, 0x000500be,
|
||||
0x000000b1, 0x000001a5, 0x000001a3, 0x000001a4, 0x000300f7, 0x000001a7, 0x00000000, 0x000400fa,
|
||||
0x000001a5, 0x000001a6, 0x000001a7, 0x000200f8, 0x000001a6, 0x000200f9, 0x00000194, 0x000200f8,
|
||||
0x000001a7, 0x0004007f, 0x00000006, 0x000003a1, 0x000001a3, 0x00050051, 0x00000006, 0x000003a3,
|
||||
0x000001a1, 0x00000000, 0x00050085, 0x00000006, 0x000003a4, 0x0000004e, 0x000003a3, 0x00050085,
|
||||
0x00000006, 0x000003a7, 0x000003a4, 0x0000022e, 0x00050088, 0x00000006, 0x000003a9, 0x000003a7,
|
||||
0x000003a1, 0x00050081, 0x00000006, 0x000003aa, 0x0000004e, 0x000003a9, 0x00050051, 0x00000006,
|
||||
0x000003ac, 0x000001a1, 0x00000001, 0x00050085, 0x00000006, 0x000003ad, 0x0000004e, 0x000003ac,
|
||||
0x00050085, 0x00000006, 0x000003b0, 0x000003ad, 0x00000236, 0x00050088, 0x00000006, 0x000003b2,
|
||||
0x000003b0, 0x000003a1, 0x00050083, 0x00000006, 0x000003b3, 0x0000004e, 0x000003b2, 0x00050050,
|
||||
0x00000007, 0x000003b4, 0x000003aa, 0x000003b3, 0x000500b8, 0x000001af, 0x000001b0, 0x000003b4,
|
||||
0x000001ae, 0x0004009a, 0x000000b1, 0x000001b1, 0x000001b0, 0x000400a8, 0x000000b1, 0x000001b2,
|
||||
0x000001b1, 0x000300f7, 0x000001b4, 0x00000000, 0x000400fa, 0x000001b2, 0x000001b3, 0x000001b4,
|
||||
0x000200f8, 0x000001b3, 0x000500ba, 0x000001af, 0x000001b7, 0x000003b4, 0x000001b6, 0x0004009a,
|
||||
0x000000b1, 0x000001b8, 0x000001b7, 0x000200f9, 0x000001b4, 0x000200f8, 0x000001b4, 0x000700f5,
|
||||
0x000000b1, 0x000001b9, 0x000001b1, 0x000001a7, 0x000001b8, 0x000001b3, 0x000300f7, 0x000001bb,
|
||||
0x00000000, 0x000400fa, 0x000001b9, 0x000001ba, 0x000001bb, 0x000200f8, 0x000001ba, 0x000200f9,
|
||||
0x00000194, 0x000200f8, 0x000001bb, 0x0004003d, 0x00000084, 0x000001be, 0x00000086, 0x00050085,
|
||||
0x00000007, 0x000001c3, 0x000003b4, 0x00000250, 0x0004006e, 0x0000001a, 0x000001c4, 0x000001c3,
|
||||
0x00040064, 0x00000083, 0x000001c5, 0x000001be, 0x0007005f, 0x00000032, 0x000001c6, 0x000001c5,
|
||||
0x000001c4, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x000001c7, 0x000001c6, 0x00000000,
|
||||
0x00050085, 0x00000006, 0x000001ca, 0x000001c7, 0x00000149, 0x00050083, 0x00000006, 0x000001d0,
|
||||
0x000003a1, 0x000001ca, 0x00050085, 0x00000006, 0x000001d5, 0x0000014a, 0x000001d4, 0x00050081,
|
||||
0x00000006, 0x000001d6, 0x000001d2, 0x000001d5, 0x000500ba, 0x000000b1, 0x000001d7, 0x000001d0,
|
||||
0x000001d6, 0x000500b8, 0x000000b1, 0x000001da, 0x000001d0, 0x00000182, 0x000500a7, 0x000000b1,
|
||||
0x000001db, 0x000001d7, 0x000001da, 0x000300f7, 0x000001dd, 0x00000000, 0x000400fa, 0x000001db,
|
||||
0x000001dc, 0x000001dd, 0x000200f8, 0x000001dc, 0x0004006f, 0x00000006, 0x000001df, 0x000003d8,
|
||||
0x00050085, 0x00000006, 0x000001e0, 0x000001df, 0x000003e3, 0x00050083, 0x00000006, 0x000001e1,
|
||||
0x00000029, 0x000001e0, 0x000200f9, 0x00000194, 0x000200f8, 0x000001dd, 0x000200f9, 0x00000195,
|
||||
0x000200f8, 0x00000195, 0x00050080, 0x00000019, 0x000001e4, 0x000003d8, 0x00000077, 0x00050081,
|
||||
0x00000006, 0x000001e7, 0x000003d9, 0x00000186, 0x000200f9, 0x00000192, 0x000200f8, 0x00000194,
|
||||
0x000b00f5, 0x00000006, 0x000003dc, 0x00000110, 0x00000192, 0x00000110, 0x000001a6, 0x00000110,
|
||||
0x000001ba, 0x000001e1, 0x000001dc, 0x0008000c, 0x00000006, 0x000001eb, 0x00000001, 0x00000031,
|
||||
0x000001e9, 0x0000014c, 0x0000014a, 0x00050083, 0x00000006, 0x000001ec, 0x00000029, 0x000001eb,
|
||||
0x00060041, 0x00000037, 0x000001ee, 0x00000035, 0x00000036, 0x00000173, 0x0004003d, 0x00000006,
|
||||
0x000001ef, 0x000001ee, 0x00050085, 0x00000006, 0x000001f1, 0x000001ef, 0x000003dc, 0x00050085,
|
||||
0x00000006, 0x000001f3, 0x000001f1, 0x000001ec, 0x00050085, 0x00000006, 0x000001f5, 0x000001f3,
|
||||
0x0000016b, 0x00050083, 0x00000006, 0x000001f6, 0x00000029, 0x000001f5, 0x00060041, 0x00000037,
|
||||
0x000001f8, 0x00000035, 0x000001f7, 0x0000002d, 0x0004003d, 0x00000006, 0x000001f9, 0x000001f8,
|
||||
0x000500ba, 0x000000b1, 0x000001fa, 0x000001f9, 0x0000004e, 0x000300f7, 0x000001fc, 0x00000000,
|
||||
0x000400fa, 0x000001fa, 0x000001fb, 0x000001fc, 0x000200f8, 0x000001fb, 0x0004003d, 0x000001fd,
|
||||
0x00000200, 0x000001ff, 0x00070050, 0x00000032, 0x00000203, 0x000001f6, 0x000001f6, 0x000001f6,
|
||||
0x00000029, 0x00040063, 0x00000200, 0x00000123, 0x00000203, 0x000200f9, 0x0000021d, 0x000200f8,
|
||||
0x000001fc, 0x000500be, 0x000000b1, 0x00000206, 0x000001f6, 0x00000140, 0x000300f7, 0x00000208,
|
||||
0x00000000, 0x000400fa, 0x00000206, 0x00000207, 0x00000208, 0x000200f8, 0x00000207, 0x000200f9,
|
||||
0x0000021d, 0x000200f8, 0x00000208, 0x0004003d, 0x000001fd, 0x0000020c, 0x000001ff, 0x00050062,
|
||||
0x00000032, 0x0000020e, 0x0000020c, 0x00000123, 0x0004003d, 0x000001fd, 0x0000020f, 0x000001ff,
|
||||
0x0008004f, 0x0000000a, 0x00000212, 0x0000020e, 0x0000020e, 0x00000000, 0x00000001, 0x00000002,
|
||||
0x0005008e, 0x0000000a, 0x00000214, 0x00000212, 0x000001f6, 0x00050051, 0x00000006, 0x00000216,
|
||||
0x0000020e, 0x00000003, 0x00050051, 0x00000006, 0x00000217, 0x00000214, 0x00000000, 0x00050051,
|
||||
0x00000006, 0x00000218, 0x00000214, 0x00000001, 0x00050051, 0x00000006, 0x00000219, 0x00000214,
|
||||
0x00000002, 0x00070050, 0x00000032, 0x0000021a, 0x00000217, 0x00000218, 0x00000219, 0x00000216,
|
||||
0x00040063, 0x0000020f, 0x00000123, 0x0000021a, 0x000200f9, 0x0000021d, 0x000200f8, 0x0000021d,
|
||||
0x00000155, 0x00000158, 0x00060041, 0x00000037, 0x0000015c, 0x00000035, 0x0000015b, 0x0000003b,
|
||||
0x0004003d, 0x00000006, 0x0000015d, 0x0000015c, 0x000500ba, 0x000000b1, 0x0000015e, 0x0000015d,
|
||||
0x0000004e, 0x000300f7, 0x00000161, 0x00000000, 0x000400fa, 0x0000015e, 0x00000160, 0x00000168,
|
||||
0x000200f8, 0x00000160, 0x0004003d, 0x00000084, 0x00000163, 0x00000162, 0x00070058, 0x00000032,
|
||||
0x00000165, 0x00000163, 0x00000159, 0x00000002, 0x00000110, 0x00050051, 0x00000006, 0x00000167,
|
||||
0x00000165, 0x00000003, 0x000200f9, 0x00000161, 0x000200f8, 0x00000168, 0x000200f9, 0x00000161,
|
||||
0x000200f8, 0x00000161, 0x000700f5, 0x00000006, 0x000003fb, 0x00000167, 0x00000160, 0x00000029,
|
||||
0x00000168, 0x00060041, 0x00000037, 0x0000016a, 0x00000035, 0x0000015b, 0x0000002d, 0x0004003d,
|
||||
0x00000006, 0x0000016b, 0x0000016a, 0x000500ba, 0x000000b1, 0x0000016d, 0x0000016b, 0x0000016c,
|
||||
0x000300f7, 0x0000016f, 0x00000000, 0x000400fa, 0x0000016d, 0x0000016e, 0x0000016f, 0x000200f8,
|
||||
0x0000016e, 0x0004003d, 0x00000170, 0x00000173, 0x00000172, 0x00070050, 0x00000032, 0x00000176,
|
||||
0x000003fb, 0x000003fb, 0x000003fb, 0x00000029, 0x00040063, 0x00000173, 0x00000123, 0x00000176,
|
||||
0x000200f9, 0x00000243, 0x000200f8, 0x0000016f, 0x000500bc, 0x000000b1, 0x00000179, 0x000003fb,
|
||||
0x00000110, 0x000300f7, 0x0000017b, 0x00000000, 0x000400fa, 0x00000179, 0x0000017a, 0x0000017b,
|
||||
0x000200f8, 0x0000017a, 0x000500b8, 0x000000b1, 0x0000017e, 0x0000016b, 0x0000004e, 0x000200f9,
|
||||
0x0000017b, 0x000200f8, 0x0000017b, 0x000700f5, 0x000000b1, 0x0000017f, 0x00000179, 0x0000016f,
|
||||
0x0000017e, 0x0000017a, 0x000300f7, 0x00000181, 0x00000000, 0x000400fa, 0x0000017f, 0x00000180,
|
||||
0x00000181, 0x000200f8, 0x00000180, 0x000200f9, 0x00000243, 0x000200f8, 0x00000181, 0x0005008e,
|
||||
0x00000007, 0x0000024c, 0x00000159, 0x00000027, 0x00050083, 0x00000007, 0x0000024e, 0x0000024c,
|
||||
0x000001de, 0x00050051, 0x00000006, 0x00000250, 0x0000024e, 0x00000000, 0x00050085, 0x00000006,
|
||||
0x00000252, 0x00000250, 0x0000014a, 0x00060041, 0x00000037, 0x00000253, 0x00000035, 0x00000036,
|
||||
0x0000002d, 0x0004003d, 0x00000006, 0x00000254, 0x00000253, 0x00050088, 0x00000006, 0x00000255,
|
||||
0x00000252, 0x00000254, 0x00050051, 0x00000006, 0x00000257, 0x0000024e, 0x00000001, 0x0004007f,
|
||||
0x00000006, 0x00000258, 0x00000257, 0x00050085, 0x00000006, 0x0000025a, 0x00000258, 0x0000014a,
|
||||
0x00060041, 0x00000037, 0x0000025b, 0x00000035, 0x00000036, 0x0000003b, 0x0004003d, 0x00000006,
|
||||
0x0000025c, 0x0000025b, 0x00050088, 0x00000006, 0x0000025d, 0x0000025a, 0x0000025c, 0x0004007f,
|
||||
0x00000006, 0x0000025f, 0x0000014a, 0x00060050, 0x0000000a, 0x00000260, 0x00000255, 0x0000025d,
|
||||
0x0000025f, 0x0007004f, 0x00000007, 0x00000276, 0x00000157, 0x00000157, 0x00000000, 0x00000001,
|
||||
0x0004006e, 0x0000001a, 0x00000277, 0x00000276, 0x00050082, 0x0000001a, 0x00000279, 0x00000277,
|
||||
0x00000407, 0x00050082, 0x0000001a, 0x0000027b, 0x00000123, 0x0000009d, 0x0008000c, 0x0000001a,
|
||||
0x000002ee, 0x00000001, 0x0000002d, 0x0000027b, 0x00000070, 0x00000279, 0x0004006f, 0x00000007,
|
||||
0x000002f0, 0x000002ee, 0x00050081, 0x00000007, 0x000002f2, 0x000002f0, 0x00000406, 0x00050085,
|
||||
0x00000007, 0x000002f6, 0x000002f2, 0x00000158, 0x0004003d, 0x00000084, 0x000002f7, 0x00000086,
|
||||
0x00040064, 0x00000083, 0x000002f9, 0x000002f7, 0x0007005f, 0x00000032, 0x000002fa, 0x000002f9,
|
||||
0x000002ee, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x000002fb, 0x000002fa, 0x00000000,
|
||||
0x00050085, 0x00000006, 0x000002fe, 0x000002fb, 0x00000149, 0x0005008e, 0x00000007, 0x00000304,
|
||||
0x000002f6, 0x00000027, 0x00050083, 0x00000007, 0x00000306, 0x00000304, 0x000001de, 0x00050051,
|
||||
0x00000006, 0x00000308, 0x00000306, 0x00000000, 0x00050085, 0x00000006, 0x0000030a, 0x00000308,
|
||||
0x000002fe, 0x00050088, 0x00000006, 0x0000030d, 0x0000030a, 0x00000254, 0x00050051, 0x00000006,
|
||||
0x0000030f, 0x00000306, 0x00000001, 0x0004007f, 0x00000006, 0x00000310, 0x0000030f, 0x00050085,
|
||||
0x00000006, 0x00000312, 0x00000310, 0x000002fe, 0x00050088, 0x00000006, 0x00000315, 0x00000312,
|
||||
0x0000025c, 0x0004007f, 0x00000006, 0x00000317, 0x000002fe, 0x00060050, 0x0000000a, 0x00000318,
|
||||
0x0000030d, 0x00000315, 0x00000317, 0x00050080, 0x0000001a, 0x0000027e, 0x00000123, 0x0000009d,
|
||||
0x0008000c, 0x0000001a, 0x00000324, 0x00000001, 0x0000002d, 0x0000027e, 0x00000070, 0x00000279,
|
||||
0x0004006f, 0x00000007, 0x00000326, 0x00000324, 0x00050081, 0x00000007, 0x00000328, 0x00000326,
|
||||
0x00000406, 0x00050085, 0x00000007, 0x0000032c, 0x00000328, 0x00000158, 0x0004003d, 0x00000084,
|
||||
0x0000032d, 0x00000086, 0x00040064, 0x00000083, 0x0000032f, 0x0000032d, 0x0007005f, 0x00000032,
|
||||
0x00000330, 0x0000032f, 0x00000324, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x00000331,
|
||||
0x00000330, 0x00000000, 0x00050085, 0x00000006, 0x00000334, 0x00000331, 0x00000149, 0x0005008e,
|
||||
0x00000007, 0x0000033a, 0x0000032c, 0x00000027, 0x00050083, 0x00000007, 0x0000033c, 0x0000033a,
|
||||
0x000001de, 0x00050051, 0x00000006, 0x0000033e, 0x0000033c, 0x00000000, 0x00050085, 0x00000006,
|
||||
0x00000340, 0x0000033e, 0x00000334, 0x00050088, 0x00000006, 0x00000343, 0x00000340, 0x00000254,
|
||||
0x00050051, 0x00000006, 0x00000345, 0x0000033c, 0x00000001, 0x0004007f, 0x00000006, 0x00000346,
|
||||
0x00000345, 0x00050085, 0x00000006, 0x00000348, 0x00000346, 0x00000334, 0x00050088, 0x00000006,
|
||||
0x0000034b, 0x00000348, 0x0000025c, 0x0004007f, 0x00000006, 0x0000034d, 0x00000334, 0x00060050,
|
||||
0x0000000a, 0x0000034e, 0x00000343, 0x0000034b, 0x0000034d, 0x00050082, 0x0000001a, 0x00000281,
|
||||
0x00000123, 0x000000a8, 0x0008000c, 0x0000001a, 0x0000035a, 0x00000001, 0x0000002d, 0x00000281,
|
||||
0x00000070, 0x00000279, 0x0004006f, 0x00000007, 0x0000035c, 0x0000035a, 0x00050081, 0x00000007,
|
||||
0x0000035e, 0x0000035c, 0x00000406, 0x00050085, 0x00000007, 0x00000362, 0x0000035e, 0x00000158,
|
||||
0x0004003d, 0x00000084, 0x00000363, 0x00000086, 0x00040064, 0x00000083, 0x00000365, 0x00000363,
|
||||
0x0007005f, 0x00000032, 0x00000366, 0x00000365, 0x0000035a, 0x00000002, 0x00000036, 0x00050051,
|
||||
0x00000006, 0x00000367, 0x00000366, 0x00000000, 0x00050085, 0x00000006, 0x0000036a, 0x00000367,
|
||||
0x00000149, 0x0005008e, 0x00000007, 0x00000370, 0x00000362, 0x00000027, 0x00050083, 0x00000007,
|
||||
0x00000372, 0x00000370, 0x000001de, 0x00050051, 0x00000006, 0x00000374, 0x00000372, 0x00000000,
|
||||
0x00050085, 0x00000006, 0x00000376, 0x00000374, 0x0000036a, 0x00050088, 0x00000006, 0x00000379,
|
||||
0x00000376, 0x00000254, 0x00050051, 0x00000006, 0x0000037b, 0x00000372, 0x00000001, 0x0004007f,
|
||||
0x00000006, 0x0000037c, 0x0000037b, 0x00050085, 0x00000006, 0x0000037e, 0x0000037c, 0x0000036a,
|
||||
0x00050088, 0x00000006, 0x00000381, 0x0000037e, 0x0000025c, 0x0004007f, 0x00000006, 0x00000383,
|
||||
0x0000036a, 0x00060050, 0x0000000a, 0x00000384, 0x00000379, 0x00000381, 0x00000383, 0x00050080,
|
||||
0x0000001a, 0x00000284, 0x00000123, 0x000000a8, 0x0008000c, 0x0000001a, 0x00000390, 0x00000001,
|
||||
0x0000002d, 0x00000284, 0x00000070, 0x00000279, 0x0004006f, 0x00000007, 0x00000392, 0x00000390,
|
||||
0x00050081, 0x00000007, 0x00000394, 0x00000392, 0x00000406, 0x00050085, 0x00000007, 0x00000398,
|
||||
0x00000394, 0x00000158, 0x0004003d, 0x00000084, 0x00000399, 0x00000086, 0x00040064, 0x00000083,
|
||||
0x0000039b, 0x00000399, 0x0007005f, 0x00000032, 0x0000039c, 0x0000039b, 0x00000390, 0x00000002,
|
||||
0x00000036, 0x00050051, 0x00000006, 0x0000039d, 0x0000039c, 0x00000000, 0x00050085, 0x00000006,
|
||||
0x000003a0, 0x0000039d, 0x00000149, 0x0005008e, 0x00000007, 0x000003a6, 0x00000398, 0x00000027,
|
||||
0x00050083, 0x00000007, 0x000003a8, 0x000003a6, 0x000001de, 0x00050051, 0x00000006, 0x000003aa,
|
||||
0x000003a8, 0x00000000, 0x00050085, 0x00000006, 0x000003ac, 0x000003aa, 0x000003a0, 0x00050088,
|
||||
0x00000006, 0x000003af, 0x000003ac, 0x00000254, 0x00050051, 0x00000006, 0x000003b1, 0x000003a8,
|
||||
0x00000001, 0x0004007f, 0x00000006, 0x000003b2, 0x000003b1, 0x00050085, 0x00000006, 0x000003b4,
|
||||
0x000003b2, 0x000003a0, 0x00050088, 0x00000006, 0x000003b7, 0x000003b4, 0x0000025c, 0x0004007f,
|
||||
0x00000006, 0x000003b9, 0x000003a0, 0x00060050, 0x0000000a, 0x000003ba, 0x000003af, 0x000003b7,
|
||||
0x000003b9, 0x000500aa, 0x000000b1, 0x00000288, 0x00000125, 0x00000036, 0x000400a8, 0x000000b1,
|
||||
0x00000289, 0x00000288, 0x000300f7, 0x000002a0, 0x00000000, 0x000400fa, 0x00000289, 0x0000028a,
|
||||
0x000002a0, 0x000200f8, 0x0000028a, 0x00050051, 0x00000019, 0x0000028e, 0x00000279, 0x00000000,
|
||||
0x000500b1, 0x000000b1, 0x0000028f, 0x00000125, 0x0000028e, 0x000300f7, 0x0000029e, 0x00000000,
|
||||
0x000400fa, 0x0000028f, 0x00000290, 0x0000029e, 0x000200f8, 0x00000290, 0x00050083, 0x00000006,
|
||||
0x00000295, 0x0000014a, 0x00000334, 0x0006000c, 0x00000006, 0x00000296, 0x00000001, 0x00000004,
|
||||
0x00000295, 0x00050083, 0x00000006, 0x0000029b, 0x000002fe, 0x0000014a, 0x0006000c, 0x00000006,
|
||||
0x0000029c, 0x00000001, 0x00000004, 0x0000029b, 0x000500b8, 0x000000b1, 0x0000029d, 0x00000296,
|
||||
0x0000029c, 0x000200f9, 0x0000029e, 0x000200f8, 0x0000029e, 0x000700f5, 0x000000b1, 0x0000029f,
|
||||
0x0000028f, 0x0000028a, 0x0000029d, 0x00000290, 0x000200f9, 0x000002a0, 0x000200f8, 0x000002a0,
|
||||
0x000700f5, 0x000000b1, 0x000002a1, 0x00000288, 0x00000181, 0x0000029f, 0x0000029e, 0x00050051,
|
||||
0x00000019, 0x000002a3, 0x00000123, 0x00000001, 0x000500aa, 0x000000b1, 0x000002a4, 0x000002a3,
|
||||
0x00000036, 0x000400a8, 0x000000b1, 0x000002a5, 0x000002a4, 0x000300f7, 0x000002bc, 0x00000000,
|
||||
0x000400fa, 0x000002a5, 0x000002a6, 0x000002bc, 0x000200f8, 0x000002a6, 0x00050051, 0x00000019,
|
||||
0x000002aa, 0x00000279, 0x00000001, 0x000500b1, 0x000000b1, 0x000002ab, 0x000002a3, 0x000002aa,
|
||||
0x000300f7, 0x000002ba, 0x00000000, 0x000400fa, 0x000002ab, 0x000002ac, 0x000002ba, 0x000200f8,
|
||||
0x000002ac, 0x00050083, 0x00000006, 0x000002b1, 0x0000014a, 0x000003a0, 0x0006000c, 0x00000006,
|
||||
0x000002b2, 0x00000001, 0x00000004, 0x000002b1, 0x00050083, 0x00000006, 0x000002b7, 0x0000036a,
|
||||
0x0000014a, 0x0006000c, 0x00000006, 0x000002b8, 0x00000001, 0x00000004, 0x000002b7, 0x000500b8,
|
||||
0x000000b1, 0x000002b9, 0x000002b2, 0x000002b8, 0x000200f9, 0x000002ba, 0x000200f8, 0x000002ba,
|
||||
0x000700f5, 0x000000b1, 0x000002bb, 0x000002ab, 0x000002a6, 0x000002b9, 0x000002ac, 0x000200f9,
|
||||
0x000002bc, 0x000200f8, 0x000002bc, 0x000700f5, 0x000000b1, 0x000002bd, 0x000002a4, 0x000002a0,
|
||||
0x000002bb, 0x000002ba, 0x000300f7, 0x000002c7, 0x00000000, 0x000400fa, 0x000002a1, 0x000002bf,
|
||||
0x000002c3, 0x000200f8, 0x000002bf, 0x00050083, 0x0000000a, 0x000002c2, 0x0000034e, 0x00000260,
|
||||
0x000200f9, 0x000002c7, 0x000200f8, 0x000002c3, 0x00050083, 0x0000000a, 0x000002c6, 0x00000260,
|
||||
0x00000318, 0x000200f9, 0x000002c7, 0x000200f8, 0x000002c7, 0x000700f5, 0x0000000a, 0x000003fc,
|
||||
0x000002c2, 0x000002bf, 0x000002c6, 0x000002c3, 0x000300f7, 0x000002d2, 0x00000000, 0x000400fa,
|
||||
0x000002bd, 0x000002ca, 0x000002ce, 0x000200f8, 0x000002ca, 0x00050083, 0x0000000a, 0x000002cd,
|
||||
0x000003ba, 0x00000260, 0x000200f9, 0x000002d2, 0x000200f8, 0x000002ce, 0x00050083, 0x0000000a,
|
||||
0x000002d1, 0x00000260, 0x00000384, 0x000200f9, 0x000002d2, 0x000200f8, 0x000002d2, 0x000700f5,
|
||||
0x0000000a, 0x000003fd, 0x000002cd, 0x000002ca, 0x000002d1, 0x000002ce, 0x0007000c, 0x0000000a,
|
||||
0x000002d6, 0x00000001, 0x00000044, 0x000003fc, 0x000003fd, 0x0006000c, 0x0000000a, 0x000002d7,
|
||||
0x00000001, 0x00000045, 0x000002d6, 0x00050094, 0x00000006, 0x000002da, 0x000002d7, 0x00000260,
|
||||
0x000500ba, 0x000000b1, 0x000002db, 0x000002da, 0x00000110, 0x000300f7, 0x000002e1, 0x00000000,
|
||||
0x000400fa, 0x000002db, 0x000002dc, 0x000002df, 0x000200f8, 0x000002dc, 0x0004007f, 0x0000000a,
|
||||
0x000002de, 0x000002d7, 0x000200f9, 0x000002e1, 0x000200f8, 0x000002df, 0x000200f9, 0x000002e1,
|
||||
0x000200f8, 0x000002e1, 0x000700f5, 0x0000000a, 0x000003fe, 0x000002de, 0x000002dc, 0x000002d7,
|
||||
0x000002df, 0x00050041, 0x00000072, 0x00000190, 0x00000035, 0x00000077, 0x0004003d, 0x00000032,
|
||||
0x00000191, 0x00000190, 0x0008004f, 0x0000000a, 0x00000192, 0x00000191, 0x00000191, 0x00000000,
|
||||
0x00000001, 0x00000002, 0x00050094, 0x00000006, 0x00000193, 0x000003fe, 0x00000192, 0x0008000c,
|
||||
0x00000006, 0x00000194, 0x00000001, 0x00000031, 0x00000110, 0x0000018a, 0x00000193, 0x000500bd,
|
||||
0x000000b1, 0x00000197, 0x00000194, 0x00000110, 0x000300f7, 0x00000199, 0x00000000, 0x000400fa,
|
||||
0x00000197, 0x00000198, 0x00000199, 0x000200f8, 0x00000198, 0x000200f9, 0x00000243, 0x000200f8,
|
||||
0x00000199, 0x00060041, 0x00000037, 0x0000019c, 0x00000035, 0x00000077, 0x00000166, 0x0004003d,
|
||||
0x00000006, 0x0000019d, 0x0000019c, 0x00050085, 0x00000006, 0x000001a0, 0x0000014a, 0x00000409,
|
||||
0x0008000c, 0x00000006, 0x000001a3, 0x00000001, 0x0000002b, 0x000001a0, 0x000001a1, 0x000001a2,
|
||||
0x00050085, 0x00000006, 0x000001a4, 0x0000019d, 0x000001a3, 0x00050085, 0x00000006, 0x000001a9,
|
||||
0x0000014a, 0x000001a8, 0x00050081, 0x00000006, 0x000001aa, 0x000001a6, 0x000001a9, 0x00050085,
|
||||
0x00000006, 0x000001ae, 0x000001a4, 0x0000040a, 0x00050094, 0x00000006, 0x000003be, 0x00000153,
|
||||
0x00000068, 0x0006000c, 0x00000006, 0x000003bf, 0x00000001, 0x0000000a, 0x000003be, 0x00050085,
|
||||
0x00000006, 0x000003c0, 0x00000064, 0x000003bf, 0x0006000c, 0x00000006, 0x000003c1, 0x00000001,
|
||||
0x0000000a, 0x000003c0, 0x00050081, 0x00000006, 0x000001b6, 0x000001b1, 0x000003c1, 0x00050085,
|
||||
0x00000006, 0x000001b7, 0x000001ae, 0x000001b6, 0x000200f9, 0x000001ba, 0x000200f8, 0x000001ba,
|
||||
0x000700f5, 0x00000006, 0x00000400, 0x000001b7, 0x00000199, 0x0000020f, 0x000001bd, 0x000700f5,
|
||||
0x00000019, 0x000003ff, 0x00000036, 0x00000199, 0x0000020c, 0x000001bd, 0x000500b1, 0x000000b1,
|
||||
0x000001c1, 0x000003ff, 0x000001c0, 0x000400f6, 0x000001bc, 0x000001bd, 0x00000000, 0x000400fa,
|
||||
0x000001c1, 0x000001bb, 0x000001bc, 0x000200f8, 0x000001bb, 0x0005008e, 0x0000000a, 0x000001c8,
|
||||
0x00000192, 0x00000400, 0x00050081, 0x0000000a, 0x000001c9, 0x00000260, 0x000001c8, 0x00050051,
|
||||
0x00000006, 0x000001cb, 0x000001c9, 0x00000002, 0x000500be, 0x000000b1, 0x000001cd, 0x000001cb,
|
||||
0x000001cc, 0x000300f7, 0x000001cf, 0x00000000, 0x000400fa, 0x000001cd, 0x000001ce, 0x000001cf,
|
||||
0x000200f8, 0x000001ce, 0x000200f9, 0x000001bc, 0x000200f8, 0x000001cf, 0x0004007f, 0x00000006,
|
||||
0x000003c7, 0x000001cb, 0x00050051, 0x00000006, 0x000003c9, 0x000001c9, 0x00000000, 0x00050085,
|
||||
0x00000006, 0x000003ca, 0x0000004e, 0x000003c9, 0x00050085, 0x00000006, 0x000003cd, 0x000003ca,
|
||||
0x00000254, 0x00050088, 0x00000006, 0x000003cf, 0x000003cd, 0x000003c7, 0x00050081, 0x00000006,
|
||||
0x000003d0, 0x0000004e, 0x000003cf, 0x00050051, 0x00000006, 0x000003d2, 0x000001c9, 0x00000001,
|
||||
0x00050085, 0x00000006, 0x000003d3, 0x0000004e, 0x000003d2, 0x00050085, 0x00000006, 0x000003d6,
|
||||
0x000003d3, 0x0000025c, 0x00050088, 0x00000006, 0x000003d8, 0x000003d6, 0x000003c7, 0x00050083,
|
||||
0x00000006, 0x000003d9, 0x0000004e, 0x000003d8, 0x00050050, 0x00000007, 0x000003da, 0x000003d0,
|
||||
0x000003d9, 0x000500b8, 0x000001d7, 0x000001d8, 0x000003da, 0x000001d6, 0x0004009a, 0x000000b1,
|
||||
0x000001d9, 0x000001d8, 0x000400a8, 0x000000b1, 0x000001da, 0x000001d9, 0x000300f7, 0x000001dc,
|
||||
0x00000000, 0x000400fa, 0x000001da, 0x000001db, 0x000001dc, 0x000200f8, 0x000001db, 0x000500ba,
|
||||
0x000001d7, 0x000001df, 0x000003da, 0x000001de, 0x0004009a, 0x000000b1, 0x000001e0, 0x000001df,
|
||||
0x000200f9, 0x000001dc, 0x000200f8, 0x000001dc, 0x000700f5, 0x000000b1, 0x000001e1, 0x000001d9,
|
||||
0x000001cf, 0x000001e0, 0x000001db, 0x000300f7, 0x000001e3, 0x00000000, 0x000400fa, 0x000001e1,
|
||||
0x000001e2, 0x000001e3, 0x000200f8, 0x000001e2, 0x000200f9, 0x000001bc, 0x000200f8, 0x000001e3,
|
||||
0x0004003d, 0x00000084, 0x000001e6, 0x00000086, 0x00050085, 0x00000007, 0x000001eb, 0x000003da,
|
||||
0x00000276, 0x0004006e, 0x0000001a, 0x000001ec, 0x000001eb, 0x00040064, 0x00000083, 0x000001ed,
|
||||
0x000001e6, 0x0007005f, 0x00000032, 0x000001ee, 0x000001ed, 0x000001ec, 0x00000002, 0x00000036,
|
||||
0x00050051, 0x00000006, 0x000001ef, 0x000001ee, 0x00000000, 0x00050085, 0x00000006, 0x000001f2,
|
||||
0x000001ef, 0x00000149, 0x00050083, 0x00000006, 0x000001f8, 0x000003c7, 0x000001f2, 0x00050085,
|
||||
0x00000006, 0x000001fd, 0x0000014a, 0x000001fc, 0x00050081, 0x00000006, 0x000001fe, 0x000001fa,
|
||||
0x000001fd, 0x000500ba, 0x000000b1, 0x000001ff, 0x000001f8, 0x000001fe, 0x000500b8, 0x000000b1,
|
||||
0x00000202, 0x000001f8, 0x000001aa, 0x000500a7, 0x000000b1, 0x00000203, 0x000001ff, 0x00000202,
|
||||
0x000300f7, 0x00000205, 0x00000000, 0x000400fa, 0x00000203, 0x00000204, 0x00000205, 0x000200f8,
|
||||
0x00000204, 0x0004006f, 0x00000006, 0x00000207, 0x000003ff, 0x00050085, 0x00000006, 0x00000208,
|
||||
0x00000207, 0x0000040a, 0x00050083, 0x00000006, 0x00000209, 0x00000029, 0x00000208, 0x000200f9,
|
||||
0x000001bc, 0x000200f8, 0x00000205, 0x000200f9, 0x000001bd, 0x000200f8, 0x000001bd, 0x00050080,
|
||||
0x00000019, 0x0000020c, 0x000003ff, 0x00000077, 0x00050081, 0x00000006, 0x0000020f, 0x00000400,
|
||||
0x000001ae, 0x000200f9, 0x000001ba, 0x000200f8, 0x000001bc, 0x000b00f5, 0x00000006, 0x00000403,
|
||||
0x00000110, 0x000001ba, 0x00000110, 0x000001ce, 0x00000110, 0x000001e2, 0x00000209, 0x00000204,
|
||||
0x0008000c, 0x00000006, 0x00000213, 0x00000001, 0x00000031, 0x00000211, 0x0000014c, 0x0000014a,
|
||||
0x00050083, 0x00000006, 0x00000214, 0x00000029, 0x00000213, 0x00060041, 0x00000037, 0x00000216,
|
||||
0x00000035, 0x00000036, 0x00000166, 0x0004003d, 0x00000006, 0x00000217, 0x00000216, 0x00050085,
|
||||
0x00000006, 0x00000219, 0x00000217, 0x00000403, 0x00050085, 0x00000006, 0x0000021b, 0x00000219,
|
||||
0x00000214, 0x00050085, 0x00000006, 0x0000021d, 0x0000021b, 0x00000194, 0x00050085, 0x00000006,
|
||||
0x0000021f, 0x0000021d, 0x000003fb, 0x00050083, 0x00000006, 0x00000220, 0x00000029, 0x0000021f,
|
||||
0x000500ba, 0x000000b1, 0x00000223, 0x0000016b, 0x0000004e, 0x000300f7, 0x00000225, 0x00000000,
|
||||
0x000400fa, 0x00000223, 0x00000224, 0x00000225, 0x000200f8, 0x00000224, 0x0004003d, 0x00000170,
|
||||
0x00000226, 0x00000172, 0x00070050, 0x00000032, 0x00000229, 0x00000220, 0x00000220, 0x00000220,
|
||||
0x00000029, 0x00040063, 0x00000226, 0x00000123, 0x00000229, 0x000200f9, 0x00000243, 0x000200f8,
|
||||
0x00000225, 0x000500be, 0x000000b1, 0x0000022c, 0x00000220, 0x00000140, 0x000300f7, 0x0000022e,
|
||||
0x00000000, 0x000400fa, 0x0000022c, 0x0000022d, 0x0000022e, 0x000200f8, 0x0000022d, 0x000200f9,
|
||||
0x00000243, 0x000200f8, 0x0000022e, 0x0004003d, 0x00000170, 0x00000232, 0x00000172, 0x00050062,
|
||||
0x00000032, 0x00000234, 0x00000232, 0x00000123, 0x0004003d, 0x00000170, 0x00000235, 0x00000172,
|
||||
0x0008004f, 0x0000000a, 0x00000238, 0x00000234, 0x00000234, 0x00000000, 0x00000001, 0x00000002,
|
||||
0x0005008e, 0x0000000a, 0x0000023a, 0x00000238, 0x00000220, 0x00050051, 0x00000006, 0x0000023c,
|
||||
0x00000234, 0x00000003, 0x00050051, 0x00000006, 0x0000023d, 0x0000023a, 0x00000000, 0x00050051,
|
||||
0x00000006, 0x0000023e, 0x0000023a, 0x00000001, 0x00050051, 0x00000006, 0x0000023f, 0x0000023a,
|
||||
0x00000002, 0x00070050, 0x00000032, 0x00000240, 0x0000023d, 0x0000023e, 0x0000023f, 0x0000023c,
|
||||
0x00040063, 0x00000235, 0x00000123, 0x00000240, 0x000200f9, 0x00000243, 0x000200f8, 0x00000243,
|
||||
0x000100fd, 0x00010038,
|
||||
};
|
||||
@@ -214,6 +214,21 @@ void rt_dispatch(Cpu *c) {
|
||||
__attribute__((musttail)) return f(c);
|
||||
}
|
||||
|
||||
// The plugin trace (plugin_init.c, TOTK_PLUGIN_TRACE): the slot of the function start a runs fn from now on. Once per
|
||||
// traced function, before the game's code runs; the hot path stays as it is. 0 when a is no function start of the
|
||||
// table or fn lies out of the reach of a slot's 32-bit offset.
|
||||
int rt_dispatch_reroute(uint64_t a, GuestFn fn) {
|
||||
uint64_t i = (a - D.lo) >> 2;
|
||||
if (!g_ready || (a & 3) || a < D.lo || i >= D.slots || !D.slot[i]) return 0;
|
||||
uintptr_t f = (uintptr_t)fn;
|
||||
if (f <= D.anchor || f - D.anchor > UINT32_MAX) return 0;
|
||||
uint64_t page = (uint64_t)(uintptr_t)&D.slot[i] & ~0xFFFull;
|
||||
if (!plat_mem_protect(page, 0x1000, PLAT_PROT_RW)) return 0;
|
||||
((uint32_t *)D.slot)[i] = (uint32_t)(f - D.anchor); // the table is sealed read-only, unsealed above
|
||||
plat_mem_protect(page, 0x1000, PLAT_PROT_READ);
|
||||
return 1;
|
||||
}
|
||||
|
||||
RtDispatchStats rt_dispatch_stats(void) {
|
||||
return (RtDispatchStats){D.lo, D.lo + D.slots * 4, D.slots, g_table_bytes, g_functions, g_nhost};
|
||||
}
|
||||
+5
-2
@@ -19,8 +19,10 @@ typedef struct RtModule {
|
||||
} RtModule;
|
||||
|
||||
// The module glue that tools/build_game.py writes for each build (build/<version>/modules.c), from layout.json and
|
||||
// layout.h: every module of the layout, and the modules linked into this executable.
|
||||
typedef struct RtLayoutEntry { const char *name; uint64_t base, size; } RtLayoutEntry;
|
||||
// layout.h: every module of the layout, and the modules linked into this executable. A mod's code module
|
||||
// (recomp/layout.py plugin<N>, after sdk) also names its NSO file and that file's SHA-256; a game module has NULL there
|
||||
// and is read from the ExeFS directory.
|
||||
typedef struct RtLayoutEntry { const char *name; uint64_t base, size; const char *file, *sha256; } RtLayoutEntry;
|
||||
extern const RtLayoutEntry rt_layout[];
|
||||
extern const int rt_layout_count;
|
||||
int rt_linked_modules(RtModule *out, int max);
|
||||
@@ -36,6 +38,7 @@ void rt_dispatch_init(const RtModule *mods, int count);
|
||||
|
||||
// The host function for a guest address, or NULL when nothing is there. Does not run guest code.
|
||||
GuestFn rt_dispatch_lookup(uint64_t pc);
|
||||
int rt_dispatch_reroute(uint64_t a, GuestFn fn); // plugin trace only (dispatch.c); 0 when it cannot
|
||||
|
||||
// "0x7000001234 (main+0x1234)" for a guest address inside a module, else the bare address. Returns buf.
|
||||
const char *rt_guest_name(uint64_t pc, char *buf, int size);
|
||||
|
||||
+11
-4
@@ -160,6 +160,11 @@ uint64_t frame_step_cap_ns(void) {
|
||||
double hz = limit_hz ? limit_hz : gfx_window_refresh_hz();
|
||||
if (hz < LIMIT_MIN_HZ) hz = 60; // display rate unknown (no window yet)
|
||||
if (hz > LIMIT_MAX_HZ) hz = LIMIT_MAX_HZ;
|
||||
// Frame generation (vk_backend.c present_pair) shows two pictures for each frame the game draws: the limit counts
|
||||
// the pictures shown and the game draws half, 30 at least (Savage Wind's framepace_period_ns, PR #1089). Only
|
||||
// while the last frame went out with a generated picture: a menu or a fade, which has none, keeps the whole limit.
|
||||
// The real-time step follows the game's presents (frame_step_present), so it is the drawn frames' interval.
|
||||
if (gfx_frame_gen_live()) hz = hz / 2 < LIMIT_MIN_HZ ? LIMIT_MIN_HZ : hz / 2;
|
||||
return (uint64_t)(1e9 / hz + 0.5);
|
||||
}
|
||||
|
||||
@@ -185,14 +190,16 @@ static uint64_t read_ptr(uint64_t a) {
|
||||
uint64_t p = 0;
|
||||
return read_guest(a, &p, 8) ? p : 0;
|
||||
}
|
||||
// 1.2.1: [main+0x4728538] (1.1.0: [main+0x4630a68], 1.4.3: [main+0x3add238]) +0x1e8 scene, its component 13 lists the
|
||||
// 1.2.1: [main+0x4728538] (1.1.0: [[main+0x4630a68]], 1.4.3: [main+0x3add238]) +0x1e8 scene, its component 13 lists the
|
||||
// resident actors; the one named "Player" has its position at +0x2b4 (MacNativeGames world_survey.c, game_version.h
|
||||
// TOTK_GAME_V121/V143). The 1.1.0 slot was measured from its own dereference chain: 181 scene accesses in that build
|
||||
// read it, and one of them reproduces this walk (the 14-component check, component 13, the 0x70 stride and the name
|
||||
// compare) instruction for instruction.
|
||||
// compare) instruction for instruction. Its slot is a GOT entry pointing to the singleton's storage, so it needs
|
||||
// one more dereference than the direct singleton slots of 1.2.1 and 1.4.3.
|
||||
static int player_pos(float xyz[3]) {
|
||||
uint64_t module = read_ptr(MOD_MAIN_BASE + (RT_V143 ? 0x3add238 : RT_V110 ? 0x4630a68 : 0x4728538)),
|
||||
scene = module ? read_ptr(module + 0x1e8) : 0;
|
||||
uint64_t module = read_ptr(MOD_MAIN_BASE + (RT_V143 ? 0x3add238 : RT_V110 ? 0x4630a68 : 0x4728538));
|
||||
if (RT_V110) module = read_ptr(module);
|
||||
uint64_t scene = module ? read_ptr(module + 0x1e8) : 0;
|
||||
int32_t count = 0;
|
||||
if (!scene || !read_guest(scene + 0x50, &count, 4) || count < 14 || count > 256) return 0;
|
||||
uint64_t comps = read_ptr(scene + 0x58), resident = comps ? read_ptr(comps + 13 * 8) : 0;
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
// Free camera for TotK 1.4.3: the view leaves Link and flies with the gamepad while the game goes on (docs/controls.md,
|
||||
// "Free camera").
|
||||
//
|
||||
// The camera component update (main+0x628460, called with the component as x0 = x19 from main+0x627dc8, the camera
|
||||
// actor's component array +0x228, slot +0x270) copies the component's pose into its sead camera and builds the view
|
||||
// matrix from it. Component fields (doubles unless noted): eye +0xe8, target +0x110, up +0x128 (floats), then near,
|
||||
// far, vertical view angle and aspect +0x134..+0x140 (the fov and aspect sets of recomp/patches-v143.txt load the last
|
||||
// two). Two one-shot overrides come after: a non-zero eye at +0x180 or target at +0x198 replaces the pose for that
|
||||
// update and is cleared (main+0x628fdc, main+0x629004). Additive offsets follow at +0x1b0 (flag) / +0x1c0 (eye),
|
||||
// +0x1d8 / +0x1e8 (target) and +0x200 (up, three floats, applied when any is non-zero and never cleared by the game).
|
||||
//
|
||||
// The freecam set's one site (main+0x6286d4, `ldr x8, [x19, #0x18]`, the first instruction every path to the pose
|
||||
// copy runs) calls freecam_hook, which performs that load and, while the free camera is on, writes the overrides.
|
||||
// The game's own eye and target stay as they were, so the game camera takes over the update after the hook stops.
|
||||
// The up offset is the game's state: the hook keeps the component's value and puts it back when the free camera ends,
|
||||
// and makes the up vector the world's +Y meanwhile, so the horizon stays level.
|
||||
//
|
||||
// Which components: a 1.4.3 frame updates three. Two share the player camera's pose (both must move, or the scene
|
||||
// and what follows the second disagree); the third rests at the default pose, eye (0, 0, 10) towards the origin. The
|
||||
// first component seen away from that default anchors the pick, and every component whose eye is within MATCH_M of
|
||||
// the anchor is driven. When no driven component has been updated for LOST_NS (a load replaced them) the next one
|
||||
// away from the default anchors again; the free camera keeps its own position.
|
||||
//
|
||||
// Input (runtime/input.c freecam_gate): TOTK_FREECAM_PAD or TOTK_FREECAM_KEY steps it off, move, lock and off again
|
||||
// (both none by default, so the player opts in). While it moves the game gets no input; the left stick flies along the
|
||||
// view and to the side, ZR and ZL straight up and down, the right stick and the mouse turn, and each press of L or R
|
||||
// halves or doubles the speed. Keys work through their bindings: the keys' sticks, and the keys bound to ZL, ZR, L and
|
||||
// R. Every driven component steps the flight by the wall-clock time since the last step, so the speed is the same at
|
||||
// any frame rate and game speed. Locked, the view stays where the flight left it and the game gets its input back.
|
||||
// The game steers Link by the camera it draws, which takes the overrides, so Link walks where the stick points on
|
||||
// screen with the stick as it is.
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#if __has_include("patches.h")
|
||||
#include "patches.h"
|
||||
#endif
|
||||
|
||||
#define SPEED_START 8.0 // metres a second at full deflection
|
||||
#define SPEED_MIN 0.25 // 8 m/s halved five times
|
||||
#define SPEED_MAX 512.0 // 8 m/s doubled six times
|
||||
#define TURN_DEG_S 110.0 // the right stick's turn rate at full deflection
|
||||
#define PITCH_MAX_DEG 85.0 // short of straight up or down, where the view's up vector would fail
|
||||
#define TARGET_M 10.0 // the target's distance in front of the eye
|
||||
#define MATCH_M 2.0
|
||||
#define LOST_NS 500000000ull
|
||||
#define STEP_MAX_S 0.1 // a longer gap (a load, a hitch) moves the camera no further than this
|
||||
#define MAX_DRIVEN 8
|
||||
|
||||
static PlatMutex pad_lock = PLAT_MUTEX_INIT;
|
||||
static FreecamPad pad_now; // the last poll's input (input thread), under pad_lock
|
||||
static int speed_clicks; // R presses minus L presses not yet applied (input thread adds, the hook takes)
|
||||
static double mouse_deg[2]; // under pad_lock: mouse turn not yet applied, degrees (right +, down +)
|
||||
// + 1 at every switch (input thread); modulo 3 the stage (FREECAM_OFF, _MOVE, _LOCK). One value, so the hook never
|
||||
// sees a switch without the stage it switched to.
|
||||
static unsigned generation;
|
||||
|
||||
int freecam_state(void) { return __atomic_load_n(&generation, __ATOMIC_ACQUIRE) % 3; }
|
||||
|
||||
void freecam_pad(const FreecamPad *p) {
|
||||
plat_mutex_lock(&pad_lock);
|
||||
pad_now = *p;
|
||||
plat_mutex_unlock(&pad_lock);
|
||||
}
|
||||
|
||||
void freecam_mouse(double right_deg, double down_deg) {
|
||||
plat_mutex_lock(&pad_lock);
|
||||
mouse_deg[0] += right_deg;
|
||||
mouse_deg[1] += down_deg;
|
||||
plat_mutex_unlock(&pad_lock);
|
||||
}
|
||||
|
||||
void freecam_speed_click(int faster) { __atomic_add_fetch(&speed_clicks, faster ? 1 : -1, __ATOMIC_RELAXED); }
|
||||
|
||||
#ifdef RT_PATCH_PAGE
|
||||
#define HOST_FREECAM (RT_PATCH_PAGE + 0xf50)
|
||||
|
||||
enum {
|
||||
OFF_LINK = 0x18, OFF_EYE = 0xe8, OFF_TARGET = 0x110, OFF_UP = 0x128,
|
||||
OFF_EYE_OVERRIDE = 0x180, OFF_TARGET_OVERRIDE = 0x198, OFF_UP_OFFSET = 0x200,
|
||||
SPAN = OFF_UP_OFFSET + 12 - OFF_EYE, // the fields the hook reads and writes, from OFF_EYE
|
||||
};
|
||||
|
||||
int freecam_available(void) { return rt_game_version == 143 && rt_patch_enabled(rt_patch_set("freecam")); }
|
||||
|
||||
void freecam_cycle(void) {
|
||||
unsigned gen = __atomic_add_fetch(&generation, 1, __ATOMIC_ACQ_REL);
|
||||
static const char *const names[] = {"off", "move", "lock"};
|
||||
rt_log("freecam: %s", names[gen % 3]);
|
||||
}
|
||||
|
||||
// Game thread only (the camera update runs on one thread). A component stays listed from its first drive until its
|
||||
// up offset is put back (the first update after the switch goes off) or, while off, until it has gone LOST_NS
|
||||
// without an update (freed by a load).
|
||||
static struct {
|
||||
unsigned flight; // (generation + 2) / 3: the same from move through lock, new at the next move
|
||||
int started; // pos, yaw and pitch hold a pose
|
||||
double pos[3], yaw, pitch, speed; // radians; yaw 0 looks along +Z, pitch > 0 up
|
||||
uint64_t last_step, anchor_seen;
|
||||
int anchored; // anchor holds the eye of the components being driven
|
||||
double anchor[3];
|
||||
int n;
|
||||
struct { uint64_t cam, seen; float up_offset[3]; } driven[MAX_DRIVEN];
|
||||
} fc;
|
||||
|
||||
static void read3(uint64_t at, double v[3]) { memcpy(v, (const void *)(uintptr_t)at, 3 * sizeof(double)); }
|
||||
static void write3(uint64_t at, const double v[3]) { memcpy((void *)(uintptr_t)at, v, 3 * sizeof(double)); }
|
||||
|
||||
static int at_default(const double eye[3], const double target[3]) {
|
||||
return eye[0] == 0 && eye[1] == 0 && eye[2] == 10 && target[0] == 0 && target[1] == 0 && target[2] == 0;
|
||||
}
|
||||
|
||||
static void direction(double d[3]) {
|
||||
d[0] = sin(fc.yaw) * cos(fc.pitch);
|
||||
d[1] = sin(fc.pitch);
|
||||
d[2] = cos(fc.yaw) * cos(fc.pitch);
|
||||
}
|
||||
|
||||
static int driven_index(uint64_t cam) {
|
||||
for (int i = 0; i < fc.n; i++)
|
||||
if (fc.driven[i].cam == cam) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void drop(int i) { fc.driven[i] = fc.driven[--fc.n]; }
|
||||
|
||||
// The free camera starts where the game camera is: its eye, looking at its target.
|
||||
static void start(const double eye[3], const double target[3], uint64_t now) {
|
||||
double d[3] = {target[0] - eye[0], target[1] - eye[1], target[2] - eye[2]};
|
||||
double len = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
|
||||
memcpy(fc.pos, eye, sizeof fc.pos);
|
||||
fc.yaw = len > 1e-6 ? atan2(d[0], d[2]) : 0;
|
||||
fc.pitch = len > 1e-6 ? asin(fmax(-1.0, fmin(1.0, d[1] / len))) : 0;
|
||||
fc.started = 1;
|
||||
fc.last_step = now;
|
||||
rt_log("freecam: starting at (%.1f %.1f %.1f)", eye[0], eye[1], eye[2]);
|
||||
}
|
||||
|
||||
// A new component joins while it shares the anchor's eye; the first one away from the default pose sets the anchor.
|
||||
static int pick(uint64_t cam, const double eye[3], const double target[3]) {
|
||||
if (at_default(eye, target)) return -1;
|
||||
if (fc.anchored) {
|
||||
double dx = eye[0] - fc.anchor[0], dy = eye[1] - fc.anchor[1], dz = eye[2] - fc.anchor[2];
|
||||
if (dx * dx + dy * dy + dz * dz > MATCH_M * MATCH_M) return -1;
|
||||
} else {
|
||||
memcpy(fc.anchor, eye, sizeof fc.anchor);
|
||||
fc.anchored = 1;
|
||||
}
|
||||
if (fc.n == MAX_DRIVEN) { // full after several loads: the one unseen longest was freed by a load
|
||||
int oldest = 0;
|
||||
for (int k = 1; k < fc.n; k++)
|
||||
if (fc.driven[k].seen < fc.driven[oldest].seen) oldest = k;
|
||||
drop(oldest);
|
||||
}
|
||||
int i = fc.n++;
|
||||
fc.driven[i].cam = cam;
|
||||
memcpy(fc.driven[i].up_offset, (const void *)(uintptr_t)(cam + OFF_UP_OFFSET), sizeof fc.driven[i].up_offset);
|
||||
rt_log("freecam: driving camera component %#llx", (unsigned long long)cam);
|
||||
return i;
|
||||
}
|
||||
|
||||
static double axis(float v) { return v > 1 ? 1 : v < -1 ? -1 : v; }
|
||||
|
||||
// Flight since the last step: L and R presses scale the speed, the right stick turns, the left stick moves along the
|
||||
// view and to the side, the triggers along the world's up.
|
||||
// Every driven component steps; the second one of a frame comes microseconds after the first and moves that little.
|
||||
static void step(uint64_t now) {
|
||||
double dt = (now - fc.last_step) / 1e9;
|
||||
fc.last_step = now;
|
||||
if (dt <= 0) return;
|
||||
if (dt > STEP_MAX_S) dt = STEP_MAX_S;
|
||||
FreecamPad p;
|
||||
double mouse[2];
|
||||
plat_mutex_lock(&pad_lock);
|
||||
p = pad_now;
|
||||
mouse[0] = mouse_deg[0], mouse[1] = mouse_deg[1];
|
||||
mouse_deg[0] = mouse_deg[1] = 0;
|
||||
plat_mutex_unlock(&pad_lock);
|
||||
int clicks = __atomic_exchange_n(&speed_clicks, 0, __ATOMIC_RELAXED);
|
||||
if (clicks) {
|
||||
fc.speed *= exp2(clicks);
|
||||
fc.speed = fc.speed < SPEED_MIN ? SPEED_MIN : fc.speed > SPEED_MAX ? SPEED_MAX : fc.speed;
|
||||
}
|
||||
double turn = TURN_DEG_S * M_PI / 180 * dt, limit = PITCH_MAX_DEG * M_PI / 180;
|
||||
// right turns towards -yaw (see right[] below); the mouse's degrees come on top of the stick's
|
||||
fc.yaw = remainder(fc.yaw - axis(p.rx) * turn - mouse[0] * M_PI / 180, 2 * M_PI);
|
||||
fc.pitch += axis(p.ry) * turn - mouse[1] * M_PI / 180;
|
||||
fc.pitch = fc.pitch > limit ? limit : fc.pitch < -limit ? -limit : fc.pitch;
|
||||
double d[3], right[3];
|
||||
direction(d);
|
||||
// world +Y up, right-handed: right = d x Y, level
|
||||
double rl = sqrt(d[0] * d[0] + d[2] * d[2]);
|
||||
right[0] = -d[2] / rl, right[1] = 0, right[2] = d[0] / rl;
|
||||
double fwd = axis(p.ly), side = axis(p.lx), lift = axis(p.rt) - axis(p.lt), dist = fc.speed * dt;
|
||||
for (int k = 0; k < 3; k++) fc.pos[k] += (d[k] * fwd + right[k] * side) * dist;
|
||||
fc.pos[1] += lift * dist;
|
||||
}
|
||||
|
||||
static void drive(uint64_t cam) {
|
||||
double d[3], target[3];
|
||||
direction(d);
|
||||
for (int k = 0; k < 3; k++) target[k] = fc.pos[k] + d[k] * TARGET_M;
|
||||
write3(cam + OFF_EYE_OVERRIDE, fc.pos);
|
||||
write3(cam + OFF_TARGET_OVERRIDE, target);
|
||||
// up + offset = +Y: the game adds the offset to its up vector before it builds the view
|
||||
float up[3], offset[3];
|
||||
memcpy(up, (const void *)(uintptr_t)(cam + OFF_UP), sizeof up);
|
||||
offset[0] = -up[0], offset[1] = 1.0f - up[1], offset[2] = -up[2];
|
||||
if (offset[0] == 0 && offset[1] == 0 && offset[2] == 0) offset[1] = 1e-6f; // all zero would skip the offset
|
||||
memcpy((void *)(uintptr_t)(cam + OFF_UP_OFFSET), offset, sizeof offset);
|
||||
}
|
||||
|
||||
// The site's own instruction first: x8 = [x19 + 0x18]. x19 is the camera component (read only: the lifter keeps
|
||||
// X19-X29 in locals across a host call).
|
||||
static void freecam_hook(Cpu *c) {
|
||||
uint64_t cam = c->x[19];
|
||||
memcpy(&c->x[8], (const void *)(uintptr_t)(cam + OFF_LINK), sizeof c->x[8]);
|
||||
unsigned gen = __atomic_load_n(&generation, __ATOMIC_ACQUIRE);
|
||||
int state = gen % 3, active = state != FREECAM_OFF;
|
||||
if (!active && !fc.n) return; // the common case: one load, a division and two compares
|
||||
if ((gen + 2) / 3 != fc.flight) { // a new flight starts at the game camera, at the start speed
|
||||
fc.flight = (gen + 2) / 3;
|
||||
fc.started = 0, fc.anchored = 0, fc.speed = SPEED_START;
|
||||
plat_mutex_lock(&pad_lock); // mouse motion from before the switch does not turn the new flight
|
||||
mouse_deg[0] = mouse_deg[1] = 0;
|
||||
plat_mutex_unlock(&pad_lock);
|
||||
}
|
||||
uint64_t now = plat_now_ns();
|
||||
int i = driven_index(cam);
|
||||
if (!active) {
|
||||
if (i >= 0) {
|
||||
memcpy((void *)(uintptr_t)(cam + OFF_UP_OFFSET), fc.driven[i].up_offset, sizeof fc.driven[i].up_offset);
|
||||
drop(i);
|
||||
}
|
||||
for (int k = fc.n - 1; k >= 0; k--)
|
||||
if (now - fc.driven[k].seen > LOST_NS) drop(k); // freed by a load while it waited
|
||||
return;
|
||||
}
|
||||
if (!mem_guest_readable(cam + OFF_EYE, SPAN)) return;
|
||||
if (fc.anchored && now - fc.anchor_seen > LOST_NS) fc.anchored = 0; // a load replaced the components
|
||||
double eye[3], target[3];
|
||||
read3(cam + OFF_EYE, eye);
|
||||
read3(cam + OFF_TARGET, target);
|
||||
if (i < 0 && (i = pick(cam, eye, target)) < 0) return;
|
||||
if (!fc.started) start(eye, target, now);
|
||||
fc.driven[i].seen = fc.anchor_seen = now;
|
||||
if (state == FREECAM_MOVE) step(now); // locked, the view holds its pose
|
||||
drive(cam);
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void freecam_register(void) {
|
||||
if (rt_game_version == 143) rt_register_host(HOST_FREECAM, freecam_hook);
|
||||
}
|
||||
#else
|
||||
int freecam_available(void) { return 0; }
|
||||
void freecam_cycle(void) {}
|
||||
#endif
|
||||
+18
-7
@@ -47,14 +47,19 @@ enum { ROMFS_PROMPTS_OK, ROMFS_PROMPTS_MISSING, ROMFS_PROMPTS_FAILED, ROMFS_PROM
|
||||
ROMFS_PROMPTS_PATCHES };
|
||||
const char *romfs_prompts(void);
|
||||
int romfs_prompts_ready(const char *folder);
|
||||
// 1 when the game resolution w x h is of another shape whose folders are missing: the UI layout, or that of
|
||||
// prompts_folder (a prompts' folder that is there at 16:9; NULL for the game's own prompts). romfs.c shaped_name.
|
||||
int romfs_shape_missing(unsigned w, unsigned h, const char *prompts_folder);
|
||||
// The folders a start at game resolution w x h with prompts_folder (input_prompts_folder; NULL for the game's own
|
||||
// prompts) and the selected HUD width needs and that have no manifest: ROMFS_NEED_PROMPTS, prompts_folder itself (16:9);
|
||||
// at another shape (res_wants_wide_overlay) ROMFS_NEED_LAYOUT, its romfs-patches-<w>x<h>[-hud..], and
|
||||
// ROMFS_NEED_SHAPED_PROMPTS, <prompts_folder>-<w>x<h>[-hud..]. A full-layout fallback does not satisfy a requested HUD
|
||||
// cap. 0 with TOTK_ROMFS_PATCHES set.
|
||||
enum { ROMFS_NEED_LAYOUT = 1, ROMFS_NEED_PROMPTS = 2, ROMFS_NEED_SHAPED_PROMPTS = 4 };
|
||||
int romfs_folders_missing(unsigned w, unsigned h, const char *prompts_folder);
|
||||
// 1 when build-cache/rebuild.txt names the setup's Python and tools/make_romfs_patches.py and both exist, with romfs/.
|
||||
int romfs_shape_can_prepare(void);
|
||||
// Starts the generator for w x h's shape (its layout, and prompts_folder's when that is there at 16:9 and lacks it) as
|
||||
// child processes the game does not wait for; the next start loads the result. 1 when every one started.
|
||||
int romfs_shape_prepare(unsigned w, unsigned h, const char *prompts_folder);
|
||||
int romfs_folders_can_prepare(void);
|
||||
// Starts the generator for each folder romfs_folders_missing names, once per folder in this process, as child
|
||||
// processes the game does not wait for; the next start loads the result. 1 when every one runs, 0 when none was
|
||||
// missing, the tools are not there or one could not start.
|
||||
int romfs_folders_prepare(unsigned w, unsigned h, const char *prompts_folder);
|
||||
int romfs_prompts_off(const char *folder);
|
||||
const char *romfs_overlay(size_t k, const char **file, uint64_t *size, int *is_added); // RomFS path of overlay k
|
||||
void fs_trace(const char *what, const char *path); // TOTK_TRACE=fs: one line per open
|
||||
@@ -66,3 +71,9 @@ int fs_save_busy(void); // a save is being wr
|
||||
// or save data changed in the last 3 s and not committed
|
||||
void fs_save_flush(void); // wait for a save Commit still running in the background;
|
||||
// every exit path calls it before the process ends
|
||||
uint32_t fs_save_commits(char *slot, size_t cap); // commits that changed save files; slot: the save folder
|
||||
// (slot_00 ...) the last one wrote first
|
||||
int fs_save_copy_slot(const char *slot, const char *dst); // a folder of the newest save copied to dst (replaced)
|
||||
void fs_save_read_from(const char *dir); // quick load: reads of save:/slot_NN/<file> open dir/<file>
|
||||
// while dir is set; NULL ends it
|
||||
int fs_save_read_from_hits(void); // opens redirected since the last fs_save_read_from(dir)
|
||||
+73
-1
@@ -281,6 +281,18 @@ static int same_file(const char *a, const char *b) {
|
||||
return same;
|
||||
}
|
||||
|
||||
// The folder of the save (slot_00 ...) whose file the running commit wrote first, for quick save (fs_save_commits):
|
||||
// note_changed takes the first path component under new_root of each file copy_tree copies instead of linking.
|
||||
static char changed_slot[64], last_slot[64];
|
||||
static uint32_t commits; // commits that changed a file, under tx_lock
|
||||
static void note_changed(const char *dst) {
|
||||
size_t n = strlen(new_root);
|
||||
if (changed_slot[0] || !n || strncmp(dst, new_root, n) || dst[n] != '/') return;
|
||||
const char *rel = dst + n + 1, *sl = strchr(rel, '/');
|
||||
size_t len = sl ? (size_t)(sl - rel) : sizeof changed_slot;
|
||||
if (len < sizeof changed_slot) memcpy(changed_slot, rel, len), changed_slot[len] = 0;
|
||||
}
|
||||
|
||||
// Copy the tree src to dst, which must not exist; links are skipped. durable: every file is flushed, and every
|
||||
// directory as far as the file system allows. base (or NULL): the committed save; a file whose bytes equal base's file
|
||||
// at the same path becomes a hard link to it instead of a copy (*nlinked), as committed files are never written in
|
||||
@@ -300,7 +312,7 @@ static int copy_tree(const char *src, const char *dst, const char *base, int dur
|
||||
if (l.e[i].kind == PLAT_FS_DIR) bad = copy_tree(s, d, b, durable, nfiles, nlinked, bytes);
|
||||
else {
|
||||
if (b && same_file(s, b) && !plat_fs_link(b, d)) bad = 0, ++*nlinked;
|
||||
else bad = copy_file(s, d, durable, bytes);
|
||||
else bad = copy_file(s, d, durable, bytes), note_changed(d);
|
||||
*nfiles += !bad;
|
||||
if (!bad && durable && crashed()) bad = -1;
|
||||
}
|
||||
@@ -509,6 +521,7 @@ static uint32_t save_commit_locked(void) {
|
||||
int nfiles = 0, linked = 0;
|
||||
tx_step = tx_dead = 0;
|
||||
const char *base = exists(newest_save()) ? newest_save() : NULL;
|
||||
changed_slot[0] = 0;
|
||||
if (remove_tree(new_root) || copy_tree(work_root, new_root, base, 1, &nfiles, &linked, &bytes)) {
|
||||
if (tx_dead) return FS_R_INVALID_ARGUMENT;
|
||||
rt_log("fs: save commit: copying the working copy failed; the newest save is unchanged");
|
||||
@@ -535,6 +548,8 @@ static uint32_t save_commit_locked(void) {
|
||||
ready_seq++;
|
||||
if (*ready_root) remove_tree(ready_root); // superseded: the working copy it was made from held all of it
|
||||
snprintf(ready_root, sizeof ready_root, "%s", ready);
|
||||
commits++;
|
||||
memcpy(last_slot, changed_slot, sizeof last_slot);
|
||||
plat_xchg32(&save_dirty, 0);
|
||||
if (crashed()) return FS_R_INVALID_ARGUMENT;
|
||||
int waits = swap_in();
|
||||
@@ -558,6 +573,34 @@ static void save_wait_commit(void) {
|
||||
|
||||
void fs_save_flush(void) { save_wait_commit(); }
|
||||
|
||||
// ---- quick save (quicksave.c): the save folder the last commit wrote, copied out of the newest save
|
||||
uint32_t fs_save_commits(char *slot, size_t cap) {
|
||||
plat_mutex_lock(&tx_lock);
|
||||
uint32_t n = commits;
|
||||
snprintf(slot, cap, "%s", last_slot);
|
||||
plat_mutex_unlock(&tx_lock);
|
||||
return n;
|
||||
}
|
||||
|
||||
// The folder slot of the newest save to dst (replaced). 0 on success.
|
||||
static int slot_name_ok(const char *slot) {
|
||||
return slot[0] && slot[0] != '.' && !strchr(slot, '/') && !strchr(slot, '\\') && !strchr(slot, ':');
|
||||
}
|
||||
|
||||
int fs_save_copy_slot(const char *slot, const char *dst) {
|
||||
if (!*save_root || !slot_name_ok(slot)) return -1;
|
||||
save_wait_commit();
|
||||
plat_mutex_lock(&tx_lock);
|
||||
char *src = join(newest_save(), slot);
|
||||
int n = 0, linked = 0;
|
||||
uint64_t bytes = 0;
|
||||
int bad = plat_fs_kind(src) != PLAT_FS_DIR || remove_tree(dst) || copy_tree(src, dst, NULL, 1, &n, &linked, &bytes);
|
||||
plat_mutex_unlock(&tx_lock);
|
||||
free(src);
|
||||
return bad ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t commit_run(void) {
|
||||
plat_mutex_lock(&tx_lock);
|
||||
uint32_t r = save_commit_locked();
|
||||
@@ -877,6 +920,33 @@ static int64_t host_read_at(PlatFile *f, void *buf, uint32_t n, uint64_t off) {
|
||||
return got < 0 ? -1 : got;
|
||||
}
|
||||
|
||||
// Quick load (quicksave.c, fs_save_read_from): while set, a read-only open of a file of any slot folder of the save
|
||||
// mount (save:/slot_NN/<file>) opens <file> of this folder instead, so the game loads the quick save whichever slot it
|
||||
// was asked to load, and no slot of the save is written for it.
|
||||
static char read_from[PATH_CAP];
|
||||
static volatile int32_t read_from_on, read_from_hits;
|
||||
|
||||
void fs_save_read_from(const char *dir) {
|
||||
if (dir) snprintf(read_from, sizeof read_from, "%s", dir), plat_xchg32(&read_from_hits, 0);
|
||||
plat_xchg32(&read_from_on, dir != NULL);
|
||||
}
|
||||
|
||||
int fs_save_read_from_hits(void) { return plat_cas32(&read_from_hits, 0, 0); }
|
||||
|
||||
static void redirect_slot_read(const char *path, char *p, size_t cap) {
|
||||
const char *rest = strstr(path, ":/slot_");
|
||||
if (!rest) return;
|
||||
const char *d = rest + 7, *file;
|
||||
while (*d >= '0' && *d <= '9') d++;
|
||||
if (d == rest + 7 || *d != '/' || !d[1] || strchr(d + 1, '/')) return;
|
||||
file = d + 1;
|
||||
char q[PATH_CAP];
|
||||
if (snprintf(q, sizeof q, "%s/%s", read_from, file) >= (int)sizeof q || plat_fs_kind(q) != PLAT_FS_FILE) return;
|
||||
rt_log("fs: quick load: %s read from %s", path, q);
|
||||
snprintf(p, cap, "%s", q);
|
||||
plat_inc32(&read_from_hits);
|
||||
}
|
||||
|
||||
static uint32_t open_file(uint64_t *out, const char *path, int mode) {
|
||||
if (romfs_owns(path)) return romfs_open(out, path, mode);
|
||||
fs_trace(mode & FS_OPEN_WRITE ? "write" : "read", path);
|
||||
@@ -885,6 +955,8 @@ static uint32_t open_file(uint64_t *out, const char *path, int mode) {
|
||||
int kind = M_FREE;
|
||||
uint32_t r = host_path_kind(path, p, sizeof p, &kind);
|
||||
if (r) return r;
|
||||
if (kind == M_SAVE && !(mode & FS_OPEN_WRITE) && plat_cas32(&read_from_on, 0, 0))
|
||||
redirect_slot_read(path, p, sizeof p);
|
||||
if (plat_fs_kind(p) != PLAT_FS_FILE) return FS_R_PATH_NOT_FOUND;
|
||||
if (kind == M_SAVE_RO && (mode & FS_OPEN_WRITE)) return FS_R_UNSUPPORTED_OPEN;
|
||||
int save_writer = kind == M_SAVE && (mode & FS_OPEN_WRITE);
|
||||
|
||||
@@ -23,7 +23,10 @@ uint64_t gfx_vsync_ticks(void); // ticks since start
|
||||
uint64_t gfx_vsync_time_ns(uint64_t tick); // kern_now_ns() time of a tick (pacing)
|
||||
double gfx_window_refresh_hz(void); // refresh rate of the window's monitor; 0 unknown
|
||||
int gfx_window_focused(void);
|
||||
uint64_t gfx_presents_shown(void); // gfx_present.c: presents queued since the start (two a frame with frame generation)
|
||||
int gfx_frame_gen_live(void); // vk_backend.c: the last frame was shown with a generated picture before it
|
||||
int gfx_picture_rect(float out[4]); // where the last present put the picture, fractions of the swapchain (x, y, w, h); 0 before one
|
||||
void gfx_present_hold(int on); // 1: the window keeps its last picture, nothing new is presented (quick load)
|
||||
// NVIDIA Reflex (gfx_present.c, VK_NV_low_latency2): the NVN front end and the input service mark a frame's stages.
|
||||
// The markers and the sleep return at once with Reflex off or unsupported.
|
||||
void vk_reflex_marker(int marker, uint64_t present_id); // present_id: the frame's (vk_reflex_frame_begin)
|
||||
|
||||
+100
-30
@@ -22,10 +22,12 @@
|
||||
#include "fs.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_wsys.h"
|
||||
#include "host.h"
|
||||
#include "nvn_api.h"
|
||||
#include "platform/platform.h"
|
||||
#include "ui/menu.h"
|
||||
#include "vk.h"
|
||||
#include "vk_fg.h"
|
||||
|
||||
#define FRAMES 2
|
||||
#define MAX_IMAGES 16
|
||||
@@ -142,8 +144,15 @@ static VmaAllocation g_cap_alloc;
|
||||
static uint8_t *g_cap_ptr;
|
||||
static VkDeviceSize g_cap_size;
|
||||
static int g_cap_w, g_cap_h, g_cap_valid;
|
||||
static int g_flip_on; // vk_present_blit submitted the blit of swapchain image g_flip_idx; vk_present_flip presents it
|
||||
static uint32_t g_flip_idx;
|
||||
// vk_present_blit submitted the blits of swapchain images g_flip_idx[0 .. g_flip_n), oldest first; vk_present_flip
|
||||
// presents the oldest. Two only with frame generation's pair (vk_present_blit_pair): the generated picture, then the
|
||||
// game's frame.
|
||||
static int g_flip_n;
|
||||
static uint32_t g_flip_idx[2];
|
||||
static int g_flip_gen[2]; // that blit shows a generated picture: its present carries no present ID
|
||||
static volatile int64_t g_shown; // presents queued since the start (gfx_presents_shown)
|
||||
static int g_overlay_on; // the pair's generated picture laid the menu out: the game's frame draws it again
|
||||
static int g_fg_images = -1; // the swapchain was built with frame generation's extra image (build_swapchain)
|
||||
|
||||
// ---- TOTK_FLIGHT thumbnails (flight.c; g_pl): each present also blits the swapchain image down into slot frame % g_th_n
|
||||
// of a host-visible ring. A slot's tag names the frame it holds complete; recording a new frame clears the tag first,
|
||||
@@ -246,6 +255,9 @@ static void window_settings_live(void) {
|
||||
static int started;
|
||||
static char present[16]; // the TOTK_VK_PRESENT the swapchain was made with
|
||||
unsigned v = cfg_version();
|
||||
// Every present: Reflex follows the frame limit, and with fps_limit = display the window measures the monitor's
|
||||
// rate after the swapchain is made, with no settings change to announce it. Unchanged, it returns at once.
|
||||
if (started) reflex_apply_locked();
|
||||
if (started && v == seen) return;
|
||||
seen = v;
|
||||
res_fov_live();
|
||||
@@ -255,6 +267,8 @@ static void window_settings_live(void) {
|
||||
snprintf(present, sizeof present, "%s", e);
|
||||
if (started) plat_xchg32(&g_dirty, 1);
|
||||
}
|
||||
// frame_gen switched in the menu: the swapchain is built again with its image count
|
||||
if (started && g_fg_images >= 0 && (vk_fg_engine() != VK_FG_OFF) != g_fg_images) plat_xchg32(&g_dirty, 1);
|
||||
if (started) gfx_window_apply_settings();
|
||||
reflex_apply_locked();
|
||||
started = 1;
|
||||
@@ -274,7 +288,7 @@ static uint64_t g_reflex_val;
|
||||
static uint64_t g_reflex_frame_next; // the last ID handed out
|
||||
static uint64_t g_reflex_frame; // the frame the game simulates now
|
||||
static _Thread_local uint64_t t_reflex_submit; // the frame whose work this thread submits; 0: g_reflex_frame
|
||||
static uint64_t g_blit_pid, g_flip_pid; // the frame of the blit being made and of the present waiting (g_pl)
|
||||
static uint64_t g_blit_pid, g_flip_pid[2]; // the frame of the blit being made and of each present waiting (g_pl)
|
||||
static uint64_t g_last_pid; // the last present ID presented (g_pl): present IDs only go up
|
||||
static int g_reflex_mode = -1; // 0=off, 1=on, 2=boost
|
||||
static uint32_t g_reflex_min_us = 1;
|
||||
@@ -306,8 +320,11 @@ static void reflex_apply_locked(void) {
|
||||
}
|
||||
int mode = reflex_mode_from_cfg();
|
||||
uint32_t min_us = 0;
|
||||
int limit = cfg_int("TOTK_FPS_LIMIT");
|
||||
if (limit > 0) min_us = (uint32_t)(1000000 / limit);
|
||||
// The driver's sleep holds frames to the same rate as the pacer (frame_rate.c frame_step_limit_hz): the setting,
|
||||
// the monitor's rate for fps_limit = display, 60 without the real-time step. cfg_int would read "display" as the
|
||||
// setting's default, 60, and Reflex would hold a 144 Hz monitor to 60 fps.
|
||||
double hz = frame_step_limit_hz();
|
||||
if (hz > 0) min_us = (uint32_t)(1e6 / hz);
|
||||
if (mode == g_reflex_mode && min_us == g_reflex_min_us) return;
|
||||
g_reflex_mode = mode;
|
||||
g_reflex_min_us = min_us;
|
||||
@@ -461,19 +478,25 @@ static VkPresentModeKHR pick_present_mode(VkPhysicalDevice pd) {
|
||||
|
||||
const char *gfx_window_present_mode(void) { return __atomic_load_n(&g_present_got, __ATOMIC_ACQUIRE); }
|
||||
|
||||
// Queues the present of a blit vk_present_blit left waiting (g_pl held). A swapchain rebuild and the next blit flush it
|
||||
// first; the device release drops it.
|
||||
static void flip_locked(void) {
|
||||
if (!g_flip_on) return;
|
||||
g_flip_on = 0;
|
||||
// Queues the present of the oldest blit vk_present_blit left waiting (g_pl held).
|
||||
static void flip_one(void) {
|
||||
if (!g_flip_n) return;
|
||||
uint32_t idx = g_flip_idx[0];
|
||||
uint64_t frame_pid = g_flip_pid[0];
|
||||
int generated = g_flip_gen[0];
|
||||
g_flip_idx[0] = g_flip_idx[1], g_flip_pid[0] = g_flip_pid[1], g_flip_gen[0] = g_flip_gen[1];
|
||||
g_flip_n--;
|
||||
if (!g_sc) return;
|
||||
VkCtx *c = vk_ctx();
|
||||
uint64_t pid = 0;
|
||||
VkPresentIdKHR pid_info = {0};
|
||||
if (c && c->has_nv_reflex) {
|
||||
// A generated picture goes out between two frames whose IDs follow each other: no ID is left for it, and the
|
||||
// game's frame after it keeps the one its markers were set with (the rule of PR #1089)
|
||||
int with_id = c && c->has_nv_reflex && !generated;
|
||||
if (with_id) {
|
||||
// The frame's own ID; a present without one (a probe, a skipped frame's neighbour) takes the next free value,
|
||||
// as present IDs must grow on a swapchain
|
||||
pid = g_flip_pid > g_last_pid ? g_flip_pid : g_last_pid + 1;
|
||||
pid = frame_pid > g_last_pid ? frame_pid : g_last_pid + 1;
|
||||
g_last_pid = pid;
|
||||
pid_info.sType = VK_STRUCTURE_TYPE_PRESENT_ID_KHR;
|
||||
pid_info.swapchainCount = 1;
|
||||
@@ -481,17 +504,26 @@ static void flip_locked(void) {
|
||||
vk_reflex_marker(4, pid); // VK_LATENCY_MARKER_PRESENT_START_NV
|
||||
}
|
||||
VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||
.pNext = (c && c->has_nv_reflex) ? &pid_info : NULL,
|
||||
.pNext = with_id ? &pid_info : NULL,
|
||||
.waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = &g_render_done[g_flip_idx], .swapchainCount = 1, .pSwapchains = &g_sc,
|
||||
.pImageIndices = &g_flip_idx};
|
||||
.pWaitSemaphores = &g_render_done[idx], .swapchainCount = 1, .pSwapchains = &g_sc,
|
||||
.pImageIndices = &idx};
|
||||
vk_queue_lock();
|
||||
VkResult r = vkQueuePresentKHR(c->gfx_queue, &pi);
|
||||
vk_queue_unlock();
|
||||
if (c && c->has_nv_reflex) vk_reflex_marker(5, pid); // VK_LATENCY_MARKER_PRESENT_END_NV
|
||||
if (c) latency_note(c, pid ? pid : g_flip_pid);
|
||||
if (with_id) vk_reflex_marker(5, pid); // VK_LATENCY_MARKER_PRESENT_END_NV
|
||||
if (c && !generated) latency_note(c, pid ? pid : frame_pid);
|
||||
vk_device_fault_report(r);
|
||||
if (r == VK_ERROR_OUT_OF_DATE_KHR || r == VK_SUBOPTIMAL_KHR) plat_xchg32(&g_dirty, 1);
|
||||
__atomic_add_fetch(&g_shown, 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
uint64_t gfx_presents_shown(void) { return (uint64_t)__atomic_load_n(&g_shown, __ATOMIC_RELAXED); }
|
||||
|
||||
// Every blit left waiting goes out, in order (g_pl held): before a swapchain rebuild and before the next blit (but the
|
||||
// pair's second); the device release drops them.
|
||||
static void flip_locked(void) {
|
||||
while (g_flip_n) flip_one();
|
||||
}
|
||||
|
||||
static void free_capture(void) {
|
||||
@@ -526,7 +558,10 @@ static int build_swapchain(void) {
|
||||
if (fmts[i].format == VK_FORMAT_B8G8R8A8_UNORM && fmts[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) { sf = fmts[i]; found = 1; }
|
||||
for (uint32_t i = 0; i < nf && !found; i++)
|
||||
if (fmts[i].format == VK_FORMAT_R8G8B8A8_UNORM && fmts[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) { sf = fmts[i]; found = 1; }
|
||||
uint32_t count = caps.minImageCount + 1;
|
||||
// Frame generation's pair holds two images acquired at once (the generated picture's blit waits while the game's
|
||||
// frame is blitted): one image more, while frame_gen names a generator
|
||||
int fg_images = g_fg_images = vk_fg_engine() != VK_FG_OFF;
|
||||
uint32_t count = caps.minImageCount + 1 + (fg_images ? 1u : 0u);
|
||||
if (caps.maxImageCount && count > caps.maxImageCount) count = caps.maxImageCount;
|
||||
if (count > 8) count = 8;
|
||||
|
||||
@@ -577,6 +612,12 @@ static int build_swapchain(void) {
|
||||
}
|
||||
free_capture();
|
||||
vk_queue_unlock();
|
||||
if (fg_images) {
|
||||
static uint32_t said;
|
||||
if (said != g_sc_n)
|
||||
said = g_sc_n, rt_log("gfx: swapchain of %u images (minimum %u; one more for frame generation's pair)", g_sc_n,
|
||||
caps.minImageCount);
|
||||
}
|
||||
// The Reflex sleep mode belongs to the swapchain: a new one (resize, fullscreen, out of date) starts with low
|
||||
// latency off, so the mode is set on it again even though the setting did not change.
|
||||
g_reflex_mode = -1;
|
||||
@@ -788,12 +829,22 @@ void gfx_fit_rect(int cw, int ch, int dw, int dh, int out[4]) {
|
||||
out[0] = (dw - out[2]) / 2, out[1] = (dh - out[3]) / 2;
|
||||
}
|
||||
|
||||
static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int h, const int crop[4], int defer) {
|
||||
int general = layout == VK_IMAGE_LAYOUT_GENERAL;
|
||||
// Quick load (quicksave.c) holds the window on its last picture while it drives the game's load menu underneath:
|
||||
// no new frame is presented until gfx_present_hold(0), as while the window is minimized.
|
||||
static volatile int32_t g_hold;
|
||||
void gfx_present_hold(int on) { plat_xchg32(&g_hold, on != 0); }
|
||||
|
||||
// pair: 0 a present of its own; 1 frame generation's generated picture, the first of a pair; 2 the game's frame after
|
||||
// it, which leaves the first blit's present waiting in front of its own and draws the menu as that blit laid it out.
|
||||
// Returns 1 when the blit was submitted.
|
||||
static int present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int h, const int crop[4], int defer,
|
||||
int pair) {
|
||||
int general = layout == VK_IMAGE_LAYOUT_GENERAL, done = 0;
|
||||
gfx_window_start();
|
||||
VkCtx *c = vk_ctx();
|
||||
plat_rmutex_lock(&g_pl);
|
||||
flip_locked();
|
||||
if (pair != 2) flip_locked();
|
||||
if (plat_cas32(&g_hold, 0, 0)) goto out;
|
||||
if (!g_sc || plat_cas32(&g_dirty, 0, 0)) {
|
||||
if (!wsys_minimized() && !create_swapchain() && !g_sc) goto out;
|
||||
}
|
||||
@@ -833,10 +884,16 @@ static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w
|
||||
MenuTarget mt = {c->instance, c->phys, c->device, c->gfx_family, c->gfx_queue,
|
||||
g_sc_hdr ? VK_FORMAT_R8G8B8A8_UNORM : g_sc_fmt, g_sc_ext.width,
|
||||
g_sc_ext.height, cw, ch, g_scaler};
|
||||
int overlay = g_sc_view[idx] &&
|
||||
int overlay;
|
||||
if (pair == 2) {
|
||||
overlay = g_sc_view[idx] && g_overlay_on;
|
||||
} else {
|
||||
overlay = g_sc_view[idx] &&
|
||||
menu_overlay_frame(__atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED), &mt, &menu_shot);
|
||||
g_overlay_on = overlay;
|
||||
}
|
||||
int cap = (g_capture || menu_shot) && ensure_capture_buffer();
|
||||
int thumb = g_th_n && ensure_thumbs();
|
||||
int thumb = pair != 1 && g_th_n && ensure_thumbs(); // the flight recorder keeps the game's frames
|
||||
|
||||
VkCommandBuffer cb = g_cb[slot];
|
||||
vkResetCommandBuffer(cb, 0);
|
||||
@@ -949,9 +1006,11 @@ static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w
|
||||
r = vkQueueSubmit2(c->gfx_queue, 1, &si, g_fence[slot]);
|
||||
vk_queue_unlock();
|
||||
if (r == VK_SUCCESS) {
|
||||
g_flip_on = 1;
|
||||
g_flip_idx = idx;
|
||||
g_flip_pid = g_blit_pid; // the frame this blit shows (vk_reflex_present_frame)
|
||||
if (g_flip_n == 2) flip_one(); // (not reached: every blit but a pair's second flushes the waiting ones)
|
||||
g_flip_pid[g_flip_n] = g_blit_pid; // the frame this blit shows (vk_reflex_present_frame)
|
||||
g_flip_gen[g_flip_n] = pair == 1;
|
||||
g_flip_idx[g_flip_n++] = idx;
|
||||
done = 1;
|
||||
if (!defer) flip_locked();
|
||||
} else {
|
||||
vk_device_fault_report(r);
|
||||
@@ -968,19 +1027,30 @@ static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w
|
||||
}
|
||||
out:
|
||||
plat_rmutex_unlock(&g_pl);
|
||||
return done;
|
||||
}
|
||||
|
||||
void vk_present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int h, const int crop[4]) {
|
||||
present_image(src, layout, fmt, w, h, crop, 0);
|
||||
present_image(src, layout, fmt, w, h, crop, 0, 0);
|
||||
}
|
||||
|
||||
void vk_present_blit(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int h, const int crop[4]) {
|
||||
present_image(src, layout, fmt, w, h, crop, 1);
|
||||
present_image(src, layout, fmt, w, h, crop, 1, 0);
|
||||
}
|
||||
|
||||
int vk_present_blit_pair(VkImage gen, VkImage src, VkFormat fmt, int w, int h, const int crop[4]) {
|
||||
// without the first blit (no swapchain, minimised, held) the game's frame goes alone, as any present
|
||||
if (!present_image(gen, VK_IMAGE_LAYOUT_GENERAL, VK_FORMAT_R8G8B8A8_UNORM, w, h, crop, 1, 1)) {
|
||||
present_image(src, VK_IMAGE_LAYOUT_GENERAL, fmt, w, h, crop, 1, 0);
|
||||
return 0;
|
||||
}
|
||||
present_image(src, VK_IMAGE_LAYOUT_GENERAL, fmt, w, h, crop, 1, 2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void vk_present_flip(void) {
|
||||
plat_rmutex_lock(&g_pl);
|
||||
flip_locked();
|
||||
flip_one();
|
||||
plat_rmutex_unlock(&g_pl);
|
||||
}
|
||||
|
||||
@@ -1000,7 +1070,7 @@ void gfx_window_release_vk(void) {
|
||||
vk_queue_lock();
|
||||
vkDeviceWaitIdle(c->device);
|
||||
vk_queue_unlock();
|
||||
g_flip_on = 0; // its blit is done (device idle); the swapchain goes away unpresented
|
||||
g_flip_n = 0; // their blits are done (device idle); the swapchain goes away unpresented
|
||||
menu_vk_release();
|
||||
vk_fsr_release();
|
||||
vk_color_release();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Generated by tools/build_shaders.py from runtime/shaders/hdr_tonemap.frag; do not edit.
|
||||
// source sha256 2680db17a9c8cd3ad85bcbc75d67e46e84179dfbe4ac7e7904fcdc935febe4ca
|
||||
// source sha256 92e96e90540b3b7b022393843a05a1bc2addaf9f2afc535d8204faace6cebdf0
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
static const uint32_t hdr_tonemap_spv[] = {
|
||||
@@ -15,7 +15,7 @@ static const uint32_t hdr_tonemap_spv[] = {
|
||||
0x00000002, 0x00050048, 0x00000437, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x00000439,
|
||||
0x00000021, 0x00000004, 0x00040047, 0x00000439, 0x00000022, 0x00000000, 0x00040047, 0x0000043e,
|
||||
0x00000006, 0x00000010, 0x00030047, 0x0000043f, 0x00000002, 0x00050048, 0x0000043f, 0x00000000,
|
||||
0x00000023, 0x00000000, 0x00050048, 0x0000043f, 0x00000001, 0x00000023, 0x000005a0, 0x00040047,
|
||||
0x00000023, 0x00000000, 0x00050048, 0x0000043f, 0x00000001, 0x00000023, 0x000005c0, 0x00040047,
|
||||
0x00000441, 0x00000021, 0x00000000, 0x00040047, 0x00000441, 0x00000022, 0x00000000, 0x00040047,
|
||||
0x00000493, 0x0000001e, 0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002,
|
||||
0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000003, 0x00040017,
|
||||
@@ -81,7 +81,7 @@ static const uint32_t hdr_tonemap_spv[] = {
|
||||
0x0004003b, 0x00000430, 0x00000431, 0x00000002, 0x00040020, 0x00000432, 0x00000002, 0x00000073,
|
||||
0x0004001c, 0x00000436, 0x00000073, 0x0000042d, 0x0003001e, 0x00000437, 0x00000436, 0x00040020,
|
||||
0x00000438, 0x00000002, 0x00000437, 0x0004003b, 0x00000438, 0x00000439, 0x00000002, 0x0004002b,
|
||||
0x00000080, 0x0000043d, 0x0000005a, 0x0004001c, 0x0000043e, 0x00000073, 0x0000043d, 0x0004001e,
|
||||
0x00000080, 0x0000043d, 0x0000005c, 0x0004001c, 0x0000043e, 0x00000073, 0x0000043d, 0x0004001e,
|
||||
0x0000043f, 0x0000043e, 0x00000073, 0x00040020, 0x00000440, 0x00000002, 0x0000043f, 0x0004003b,
|
||||
0x00000440, 0x00000441, 0x00000002, 0x00040020, 0x00000442, 0x00000002, 0x00000006, 0x0006002c,
|
||||
0x00000007, 0x00000463, 0x00000128, 0x00000128, 0x00000128, 0x0004002b, 0x00000006, 0x0000046f,
|
||||
|
||||
+51
-2
@@ -25,7 +25,9 @@ void rt_log_raw(const char *p, size_t n);
|
||||
const char *rt_log_path(void); // the log file, NULL when this run writes none
|
||||
enum { RT_TRACE_SVC = 1, RT_TRACE_HOSTCALL = 2, RT_TRACE_IPC = 4, RT_TRACE_FS = 8, RT_TRACE_GFX = 16, RT_TRACE_PERF = 32,
|
||||
RT_TRACE_SCHED = 64, RT_TRACE_AUDIO = 128, RT_TRACE_PRESENT = 256,
|
||||
RT_TRACE_HOSTCOUNT = 512 }; // no TOTK_TRACE name of its own: hostfn_count switches it (host.h)
|
||||
RT_TRACE_HOSTCOUNT = 512, // no TOTK_TRACE name of its own: hostfn_count switches it (host.h)
|
||||
RT_TRACE_PLUGIN = 1024 }; // no name either: the plugin service run (plugin_init.c) sees every SVC through
|
||||
// rt_plugin_svc while it runs a plugin's init
|
||||
extern unsigned rt_trace; // from TOTK_TRACE=svc,host,ipc,fs,gfx,perf,sched,audio,present (or all)
|
||||
// prof_win.c: TOTK_PROFILE=<path> sampling profiler; TOTK_TRACE=perf frame timing (waits of the render thread)
|
||||
// PERF_TEX: texture uploads on the render thread (deswizzle, decode, staging), PERF_ASTC included
|
||||
@@ -150,6 +152,7 @@ uint32_t mem_set_attribute(uint64_t a, uint64_t n, uint32_t mask, uint32_t at);
|
||||
uint32_t mem_map(uint64_t dst, uint64_t src, uint64_t n); // 0x04
|
||||
uint32_t mem_unmap(uint64_t dst, uint64_t src, uint64_t n); // 0x05
|
||||
uint32_t mem_query(uint64_t a, RtMemoryInfo *out); // 0x06
|
||||
extern void (*mem_query_hook)(uint64_t a, RtMemoryInfo *r); // plugin service run only: adjusts mem_query's answer
|
||||
uint32_t mem_map_physical(uint64_t a, uint64_t n); // 0x2C
|
||||
uint32_t mem_unmap_physical(uint64_t a, uint64_t n); // 0x2D
|
||||
int mem_info(uint32_t id, uint64_t *out); // GetInfo memory ids 2-7, 12-17, 21, 22, 28; 0 if not a memory id
|
||||
@@ -199,13 +202,24 @@ int rt_oom_forced_left(int site); // forced failures st
|
||||
typedef struct {
|
||||
const char *name; uint64_t base, size, text_end, data_off; // text_end, data_off: offsets from base
|
||||
uint64_t init, init_array, init_array_size, ctor_flag; // absolute guest addresses; init_array_size in bytes
|
||||
int plugin; // a mod's code module (layout plugin<N>), not a game module
|
||||
} RtLoaded;
|
||||
void ldr_load(const char *exefs_dir); // load, relocate (overrides applied), seal; once
|
||||
extern GuestFn ldr_plugin_import; // set before ldr_load (plugin_init.c): every JUMP_SLOT
|
||||
// import of a plugin binds to this observer
|
||||
// The module tables of the runtime library: it is built once per release (tools/build_game.py --make-runtime-lib),
|
||||
// before an install's layout (recomp/layout.py) adds its mod plugins after sdk, so they do not use that MOD_COUNT.
|
||||
#define RT_MAX_MODULES 32
|
||||
int ldr_count(void);
|
||||
int ldr_plugins_gone(uint32_t *key); // layout plugins whose file is gone; mixes their paths into key
|
||||
const RtLoaded *ldr_module(int i); // order: main, subsdk0, sdk
|
||||
uint64_t ldr_symbol(const char *name); // exported definition, 0 if none
|
||||
uint64_t ldr_plt_stub(const char *module, const char *name); // PLT stub whose GOT slot holds name, 0 if none
|
||||
const char *ldr_describe(uint64_t a, char *buf, int n); // "main+0x1234 (symbol+0x10)", "host <name>", or the address
|
||||
uint64_t ldr_nso_size(const char *dir, const char *file); // image size of an ExeFS NSO (SHA-256 checked)
|
||||
void ldr_map_image(const char *dir, const char *file, uint64_t base, uint64_t *text_end, uint64_t *data_off);
|
||||
// its segments at base (reserved by the caller), not
|
||||
// linked: the plugin service run's rtld (plugin_init.c)
|
||||
uint8_t *ldr_read_verified(const char *dir, const char *file, size_t *len); // whole file, SHA-256 checked against
|
||||
// modules.c (fatal on mismatch); free() it
|
||||
|
||||
@@ -298,6 +312,7 @@ void res_heapdef_served(void); // romfs.c serves the
|
||||
void res_init(void); // after rt_patches_init: the patch page and the sets
|
||||
float res_dlss_lod_bias(void); // TOTK_DLSS upscaling: texture LOD bias (<= 0)
|
||||
int res_dlss_mode(const char *mode); // TOTK_DLSS changed while running: new scene size
|
||||
int res_dlss_dll(void); // the DLSS library is next to the executable
|
||||
void res_fn_hit(uint64_t addr, uint64_t x0); // main.c fnprof_hit: catches the renderer at start
|
||||
void res_present(Cpu *c); // nvnQueuePresentTexture: applies a pending scene size
|
||||
void res_sizes(unsigned out[2], unsigned scene[2]); // the output and scene sizes in effect (the game's own
|
||||
@@ -309,6 +324,7 @@ int romfs_shaped_ready(unsigned w, unsigned h); // romfs-patches-<w>x
|
||||
int romfs_shaped_prompts_ready(const char *folder, unsigned w, unsigned h); // the same for <folder>-<w>x<h>, a
|
||||
// prompts' folder (romfs-patches-xbox, -xbox-label, -pc)
|
||||
void res_wanted(unsigned out[2]); // the output size TOTK_OUTPUT_RES asks for
|
||||
void res_asked(unsigned out[2]); // the same before a missing shaped layout made it 16:9
|
||||
void res_fov_live(void); // TOTK_FOV to the camera (set fov); on a settings change
|
||||
void res_dynres_live(void); // TOTK_DYNAMIC_RES to the game (set fixres); on a settings change
|
||||
// ---- code patches (patches.c) and the frame step (frame_rate.c)
|
||||
@@ -320,6 +336,25 @@ void rt_patch_disable(int set); // before the guest s
|
||||
void rt_patch_switch(int set, int on); // at run time (live settings): each site takes the new code
|
||||
// the next time it runs
|
||||
void *rt_patch_page(void); // the page the patched code reads (NULL without the table)
|
||||
// Contested sites (recomp/patches.py `ordered`): a site two or more ordered sets patch runs the one that is on with the
|
||||
// lowest rank (a tie: the one later in the patch file); rt_patch_pick[] holds its place, 1 up, 0 for none.
|
||||
typedef struct {
|
||||
const char *module; // "main"
|
||||
uint32_t offset; // the site's module offset
|
||||
const int16_t *sets; // its ordered sets, in the order its C tests them
|
||||
int nsets;
|
||||
} RtPatchPick;
|
||||
void rt_patch_rank(int set, int rank); // an ordered set's rank (0 first: the Mods tab's position);
|
||||
// unranked sets come after every ranked one
|
||||
void rt_patch_picks(void); // every contested site's pick from the sets on and their
|
||||
// ranks; rt_patch_switch of an ordered set redoes its sites
|
||||
int rt_patch_pick_count(void);
|
||||
const RtPatchPick *rt_patch_pick_at(int i); // NULL out of range
|
||||
int rt_patch_pick_winner(int i); // the place in its sets of the set that runs there, -1 none
|
||||
const char *rt_patch_name(int set); // NULL out of range
|
||||
// --probe-mods: a set table of its own (names, n sets, its contested sites), every set off and unranked; names NULL
|
||||
// returns to the generated table.
|
||||
void rt_patch_probe_table(const char *const *names, int n, const RtPatchPick *picks, int npicks);
|
||||
void frame_step_init(void); // after rt_patches_init: the real-time step's first value
|
||||
int frame_step_realtime(void); // the real-time step is on: presents ignore the interval
|
||||
uint64_t frame_step_cap_ns(void); // with the real-time step: the shortest frame in ns
|
||||
@@ -339,13 +374,27 @@ int rt_knob(const char *name, const char *def);
|
||||
void frame_step_present(uint64_t display_ns, int interval); // nvnQueuePresentTexture: the frame's display time and
|
||||
// present interval (60 Hz ticks)
|
||||
// ---- boot (boot.c, main.c)
|
||||
typedef struct { const char *exefs, *romfs, *profile; int boot; double seconds; const char *shot, *gpu; } RtConfig;
|
||||
typedef struct {
|
||||
const char *exefs, *romfs, *profile;
|
||||
int boot;
|
||||
double seconds;
|
||||
const char *shot, *gpu;
|
||||
const char *plugin_init; // --plugin-init DIR: the plugin service run writes its record there (plugin_init.c)
|
||||
} RtConfig;
|
||||
// romfs: directory with romfs.bin and index.json;
|
||||
// frames: --frames N (0 = no limit); shot: --shot
|
||||
// PATH; gpu: TOTK_GPU
|
||||
const RtConfig *rt_config(void);
|
||||
void rt_boot_event(const char *what, Cpu *c, const char *detail); // checkpoint log; "nvn" ends --boot
|
||||
void rt_boot(void); // boot.c
|
||||
void rt_boot_plugin_init(void); // boot.c: --plugin-init, the plugin service run
|
||||
void plugin_init_setup(void); // plugin_init.c: before ldr_load
|
||||
void plugin_init_run(Cpu *c, const RtLoaded *sdk); // plugin_init.c: from the module-init callback; exits
|
||||
void plugins_setup(void); // plugin_init.c: rt_boot, before ldr_load; nothing
|
||||
// without a plugin in the build
|
||||
int plugins_start(Cpu *c, const RtLoaded *sdk); // plugin_init.c: from the module-init callback, before
|
||||
// the game's constructors; 1 when it ran sdk's DT_INIT
|
||||
// (a plugin's init ran after it)
|
||||
// Modes of totk.exe. main.c has run mem_init and parsed the paths; each mode calls ldr_load itself if it needs the
|
||||
// modules, registers its host functions, then seals (hostfn_seal, or implicitly at the first rt_call). Return the
|
||||
// process exit code.
|
||||
|
||||
+464
-46
@@ -4,7 +4,7 @@
|
||||
// system's back end (input_wsys.h: input_win.c with Win32, input_sdl.c with SDL), which also owns the cursor capture.
|
||||
// Keys and their map: docs/controls.md.
|
||||
// The gamepad also rumbles (input_rumble) and, when it has a gyro and an accelerometer, feeds the six-axis sensor from a
|
||||
// thread of its own (input_motion_start). Every SDL call on the gamepad is made under `lock`.
|
||||
// thread of its own (input_motion_start). Every SDL call on the gamepad is made under `lock`, except the rumble writes (rumble_main).
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@@ -37,12 +37,25 @@ int input_kbm_last(void) { return __atomic_load_n(&g_kbm_last, __ATOMIC_RELAXED)
|
||||
int input_gameplay_active(void) { return !g_menu && !g_block && ikb_foreground() && ikb_captured(); }
|
||||
static SDL_Gamepad *pad;
|
||||
static uint64_t next_scan;
|
||||
static volatile int32_t rumble_ready; // the open gamepad has rumble motors (what input_rumble returns)
|
||||
static void rumble_cancel(void);
|
||||
static int pad_rumble; // the open gamepad has rumble motors
|
||||
static volatile int32_t pad_labels[4]; // ... and the labels of its south, east, west, north buttons (PAD_LABEL_*), any thread
|
||||
static int pad_east_a; // ... and labels its east face button A (Nintendo layout under TOTK_PAD_LAYOUT=auto)
|
||||
static int pad_layout = -1; // PAD_LAYOUT_* in effect for the open gamepad, -1 to pick again; live (cfg_version)
|
||||
static unsigned pad_layout_seen;
|
||||
static volatile int32_t pad_layout_shown = -1; // pad_layout for the menu (any thread), -1 without a gamepad
|
||||
// Steam Input: a game Steam starts gets SDL_GAMECONTROLLER_IGNORE_DEVICES, the vendor/product pairs of the controllers
|
||||
// Steam reads itself, and sees Steam's virtual gamepad in their place. That pad has no motion sensors, so a Steam
|
||||
// Controller, a Steam Deck or a DualSense under Steam Input gives no gyro. steam_reveal keeps the list here and clears
|
||||
// the hint: the buttons and sticks still come from the virtual pad (scan_pads skips the listed devices, so Steam's
|
||||
// remapping holds and nothing is read twice), and only the sensors come from the real controller (motion_source).
|
||||
enum { STEAM_HIDDEN_MAX = 64 };
|
||||
static uint16_t steam_hidden[STEAM_HIDDEN_MAX][2]; // vendor, product
|
||||
static int steam_hidden_n;
|
||||
static SDL_Gamepad *motion_extra; // the hidden controller opened for its sensors only, NULL none
|
||||
static int pad_hidden; // the open gamepad is a controller Steam hid (scan_pads' fallback)
|
||||
static uint64_t next_motion_scan;
|
||||
static SDL_JoystickID sensor_pad; // the gamepad whose sensors the motion thread set up, 0 none
|
||||
static int sensor_ok; // ... and it has both sensors, enabled
|
||||
static int motion_thread; // 0 not started, 1 running, -1 off (TOTK_MOTION=0, no SDL)
|
||||
@@ -102,7 +115,10 @@ static void script_load(void) {
|
||||
ScriptEv e = {.at = (uint64_t)(at * unit + 0.5), .hold = timed ? 66667 : 4, .bit = -1, .timed = timed};
|
||||
long a, b;
|
||||
double c;
|
||||
if (!strcmp(name, "WHEEL")) {
|
||||
if (!strcmp(name, "QUICKSAVE") || !strcmp(name, "QUICKLOAD")) {
|
||||
e.stick = name[5] == 'S' ? 5 : 6, e.hold = 1; // once, as quicksave's keys
|
||||
snprintf(e.text, sizeof e.text, "%s", name);
|
||||
} else if (!strcmp(name, "WHEEL")) {
|
||||
if (sscanf(line + off, "%ld", &a) != 1) { rt_log("input: script line %d: WHEEL needs notches", ln); continue; }
|
||||
e.stick = 4, e.x = (int32_t)a, e.hold = 1; // one turn, never held
|
||||
snprintf(e.text, sizeof e.text, "WHEEL %d", e.x);
|
||||
@@ -132,6 +148,10 @@ static void script_load(void) {
|
||||
rt_log("input: script %s, %d events", path, script_n);
|
||||
}
|
||||
|
||||
// Under lock: the Switch buttons the input script pressed in the last poll, apart from the keys' and the gamepad's, so
|
||||
// a gamepad combo can count a scripted press as the gamepad's without counting the keys bound to the same buttons
|
||||
static uint64_t script_seen;
|
||||
|
||||
static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
if (!script_state) script_load();
|
||||
if (!script_n) return;
|
||||
@@ -150,7 +170,8 @@ static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
if (e->timed) rt_log("input: script frame %llu at %.1f ms: %s", (unsigned long long)fr, w / 1000.0, e->text);
|
||||
else rt_log("input: script frame %llu tick %llu: %s", (unsigned long long)fr, (unsigned long long)tick, e->text);
|
||||
}
|
||||
if (e->stick == 4) script_wheel += e->x;
|
||||
if (e->stick >= 5) quicksave_request(e->stick == 6);
|
||||
else if (e->stick == 4) script_wheel += e->x;
|
||||
else if (e->stick == 3) {
|
||||
int64_t x = (int64_t)script_mouse[0] + e->x, y = (int64_t)script_mouse[1] + e->y;
|
||||
script_mouse[0] = (int32_t)(x < INT32_MIN ? INT32_MIN : x > INT32_MAX ? INT32_MAX : x);
|
||||
@@ -252,7 +273,8 @@ static void rec_apply(uint64_t b, const int32_t sl[2], const int32_t sr[2]) {
|
||||
|
||||
void input_direct_mouse_sample(int enabled, int32_t *dx, int32_t *dy) {
|
||||
plat_mutex_lock(&lock);
|
||||
enabled = enabled && !g_block && !g_menu;
|
||||
// the moving free camera takes the mouse (freecam_gate)
|
||||
enabled = enabled && !g_block && !g_menu && freecam_state() != FREECAM_MOVE;
|
||||
*dx = script_mouse[0]; *dy = script_mouse[1];
|
||||
script_mouse[0] = script_mouse[1] = 0;
|
||||
if (!enabled) { *dx = *dy = 0; }
|
||||
@@ -347,6 +369,14 @@ static void walk_get(void) {
|
||||
static int mouse_selector;
|
||||
int input_direct_mouse_selector_active(void) { return __atomic_load_n(&mouse_selector, __ATOMIC_RELAXED) != 0; }
|
||||
|
||||
// A script's MOUSE line within the last 100 ms (under `lock`): mouse_camera then makes a stick of it
|
||||
static uint64_t script_mouse_at;
|
||||
static int input_script_mouse_recent(void) {
|
||||
uint64_t now = plat_now_ns();
|
||||
if (script_mouse[0] || script_mouse[1]) script_mouse_at = now;
|
||||
return script_mouse_at && now - script_mouse_at < 100000000ull;
|
||||
}
|
||||
|
||||
// Selector 1 is a radial wheel, 2..4 are distinct horizontal quick lists; only a wheel retains a virtual cursor.
|
||||
// Under `lock`.
|
||||
static void mouse_camera(int32_t out[2], int selector) {
|
||||
@@ -379,7 +409,10 @@ static void mouse_camera(int32_t out[2], int selector) {
|
||||
frame = ~0ull;
|
||||
return; // the camera update takes the raw counts itself, once, outside the HID stick path
|
||||
}
|
||||
if (!ikb_captured()) {
|
||||
// A script's MOUSE lines move the stick as the mouse does, captured or not (in direct mode the camera hook takes
|
||||
// them, input_direct_mouse_sample): for 100 ms after one the stick is the mouse's, as while captured
|
||||
int scripted = input_script_mouse_recent();
|
||||
if (!ikb_captured() && !scripted) {
|
||||
ikb_mouse_take(&dx, &dy);
|
||||
held[0] = held[1] = 0;
|
||||
frame = ~0ull;
|
||||
@@ -389,6 +422,9 @@ static void mouse_camera(int32_t out[2], int selector) {
|
||||
if (fr != frame) {
|
||||
double dt = age < 0.004 ? 0.004 : age > 0.1 ? 0.1 : age;
|
||||
ikb_mouse_take(&dx, &dy);
|
||||
if (!ikb_captured()) dx = dy = 0;
|
||||
dx += script_mouse[0], dy += script_mouse[1];
|
||||
script_mouse[0] = script_mouse[1] = 0;
|
||||
input_mouse_stick(dx, dy, dt, mouse_sens_get(), held);
|
||||
frame = fr;
|
||||
t0 = now;
|
||||
@@ -420,10 +456,86 @@ static void stick(SDL_GamepadAxis ax, SDL_GamepadAxis ay, float dead, int32_t ou
|
||||
input_pad_stick(SDL_GetGamepadAxis(pad, ax), -(int32_t)SDL_GetGamepadAxis(pad, ay), dead, out);
|
||||
}
|
||||
|
||||
// Open the first gamepad when none is open or the open one went away; logs once per change.
|
||||
// Before SDL_Init: keep the controllers Steam hid (steam_hidden) and let SDL open them. The list is
|
||||
// "0xVVVV/0xPPPP,..." (SDL's own format). With motion off (TOTK_MOTION=0 at start) Steam's list stays in force.
|
||||
static void steam_reveal(void) {
|
||||
const char *e = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES");
|
||||
if (!e || !*e || !cfg_bool("TOTK_MOTION")) return;
|
||||
for (const char *s = e; *s && steam_hidden_n < STEAM_HIDDEN_MAX;) {
|
||||
unsigned v, p;
|
||||
int used = 0;
|
||||
if (sscanf(s, " %x/%x%n", &v, &p, &used) == 2 && used > 0) {
|
||||
steam_hidden[steam_hidden_n][0] = (uint16_t)v;
|
||||
steam_hidden[steam_hidden_n][1] = (uint16_t)p;
|
||||
steam_hidden_n++;
|
||||
s += used;
|
||||
}
|
||||
const char *c = strchr(s, ',');
|
||||
if (!c) break;
|
||||
s = c + 1;
|
||||
}
|
||||
if (!steam_hidden_n) return;
|
||||
// The environment outranks a hint of normal priority, so this one overrides it
|
||||
SDL_SetHintWithPriority(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, "", SDL_HINT_OVERRIDE);
|
||||
rt_log("input: Steam Input hides %d controller type(s); buttons stay on Steam's virtual gamepad, motion is read "
|
||||
"from the controller itself", steam_hidden_n);
|
||||
}
|
||||
|
||||
// The ids the device itself reports. SDL_GetGamepadVendorForID and ...ProductForID give a Steam virtual pad the ids of
|
||||
// the controller behind it, which would make it look like a controller Steam hid; the GUID keeps the device's own.
|
||||
static void raw_ids(SDL_JoystickID id, uint16_t *v, uint16_t *p) {
|
||||
SDL_GetJoystickGUIDInfo(SDL_GetGamepadGUIDForID(id), v, p, NULL, NULL);
|
||||
}
|
||||
|
||||
static int steam_hidden_id(SDL_JoystickID id) {
|
||||
uint16_t v, p;
|
||||
raw_ids(id, &v, &p);
|
||||
for (int i = 0; i < steam_hidden_n; i++)
|
||||
if (steam_hidden[i][0] == v && steam_hidden[i][1] == p) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Steam's virtual gamepad: Valve's vendor id with product 0x11ff in the device's own ids (raw_ids; SDL's
|
||||
// SDL_IsJoystickSteamVirtualGamepad is not public)
|
||||
static int steam_virtual(SDL_Gamepad *g) {
|
||||
uint16_t v, p;
|
||||
raw_ids(SDL_GetGamepadID(g), &v, &p);
|
||||
return v == 0x28de && p == 0x11ff;
|
||||
}
|
||||
|
||||
static int has_motion(SDL_Gamepad *g) {
|
||||
return SDL_GamepadHasSensor(g, SDL_SENSOR_GYRO) && SDL_GamepadHasSensor(g, SDL_SENSOR_ACCEL);
|
||||
}
|
||||
|
||||
// A gamepad Steam did not hide is connected (Steam's virtual pad, or another controller).
|
||||
static int unhidden_pad_present(void) {
|
||||
int n = 0, found = 0;
|
||||
SDL_JoystickID *ids = SDL_GetGamepads(&n);
|
||||
for (int i = 0; ids && i < n && !found; i++) found = !steam_hidden_id(ids[i]);
|
||||
SDL_free(ids);
|
||||
return found;
|
||||
}
|
||||
|
||||
// Open the first gamepad when none is open or the open one went away; logs once per change. A controller Steam hid
|
||||
// (steam_hidden) is taken only when no other gamepad is there, e.g. while Steam's virtual pad is not up yet, and gives
|
||||
// way to the virtual pad once it is (pad_physical looks again every RESCAN_MS while pad_hidden): otherwise Steam's
|
||||
// remapping would be lost for the session. The hidden controller then stays open for its sensors (motion_extra), so
|
||||
// its bias and orientation go on.
|
||||
static void scan_pads(void) {
|
||||
if (pad && SDL_GamepadConnected(pad)) return;
|
||||
if (pad && SDL_GamepadConnected(pad)) {
|
||||
if (!pad_hidden || !unhidden_pad_present()) return;
|
||||
rt_log("input: Steam Input's virtual gamepad is up: buttons move to it from \"%s\"", SDL_GetGamepadName(pad));
|
||||
if (!motion_extra && has_motion(pad)) motion_extra = pad;
|
||||
else SDL_CloseGamepad(pad);
|
||||
pad = NULL;
|
||||
pad_hidden = 0;
|
||||
plat_xchg32(&rumble_ready, 0);
|
||||
rumble_cancel();
|
||||
}
|
||||
if (pad) {
|
||||
plat_xchg32(&rumble_ready, 0);
|
||||
rumble_cancel();
|
||||
SDL_CloseGamepad(pad); pad = NULL; sensor_pad = 0; sensor_ok = 0;
|
||||
// Its bias and an attempt collecting from it go with it; the next pad gets its own in pad_bias_select.
|
||||
motion_bias_reset(motion_global());
|
||||
@@ -434,10 +546,18 @@ static void scan_pads(void) {
|
||||
}
|
||||
int n = 0;
|
||||
SDL_JoystickID *ids = SDL_GetGamepads(&n);
|
||||
for (int i = 0; ids && i < n && !pad; i++) pad = SDL_OpenGamepad(ids[i]);
|
||||
for (int pass = 0; pass < 2 && !pad; pass++)
|
||||
for (int i = 0; ids && i < n && !pad; i++)
|
||||
if (steam_hidden_id(ids[i]) == pass) {
|
||||
// The controller motion_source holds for its sensors serves as the pad too: one open handle
|
||||
if (motion_extra && SDL_GetGamepadID(motion_extra) == ids[i]) { pad = motion_extra; motion_extra = NULL; }
|
||||
else pad = SDL_OpenGamepad(ids[i]);
|
||||
}
|
||||
SDL_free(ids);
|
||||
if (!pad) return;
|
||||
pad_hidden = steam_hidden_n && steam_hidden_id(SDL_GetGamepadID(pad));
|
||||
pad_rumble = SDL_GetBooleanProperty(SDL_GetGamepadProperties(pad), SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN, false);
|
||||
plat_xchg32(&rumble_ready, pad_rumble);
|
||||
pad_east_a = SDL_GetGamepadButtonLabel(pad, SDL_GAMEPAD_BUTTON_EAST) == SDL_GAMEPAD_BUTTON_LABEL_A;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
SDL_GamepadButtonLabel lb = SDL_GetGamepadButtonLabel(pad, pad_sdl[PAD_SOUTH + i]);
|
||||
@@ -453,7 +573,10 @@ static void scan_pads(void) {
|
||||
}
|
||||
pad_layout = -1;
|
||||
int motion = SDL_GamepadHasSensor(pad, SDL_SENSOR_GYRO) && SDL_GamepadHasSensor(pad, SDL_SENSOR_ACCEL);
|
||||
rt_log("input: gamepad \"%s\" (%s, %s, east button %s)", SDL_GetGamepadName(pad), pad_rumble ? "rumble" : "no rumble",
|
||||
uint16_t rv, rp;
|
||||
raw_ids(SDL_GetGamepadID(pad), &rv, &rp);
|
||||
rt_log("input: gamepad \"%s\" %04x:%04x%s (%s, %s, east button %s)", SDL_GetGamepadName(pad), rv, rp,
|
||||
steam_virtual(pad) ? " Steam Input" : "", pad_rumble ? "rumble" : "no rumble",
|
||||
motion ? "gyro and accelerometer" : "no motion sensors", pad_east_a ? "labelled A" : "not labelled A");
|
||||
}
|
||||
|
||||
@@ -496,6 +619,20 @@ static void binds_refresh(void) {
|
||||
// TOTK_TEST_PAD=<lx>,<ly>,<rx>,<ry> (test runs): an SDL virtual gamepad whose sticks rest at these raw SDL axis values
|
||||
// (-32768..32767, down is +y), attached before the first scan so it is the gamepad the game reads: drift and full
|
||||
// deflection go through the same mapping and dead zone as a real pad.
|
||||
// TOTK_TEST_PAD_RUMBLE_MS=<n>: the test gamepad has rumble and each write to it takes n ms (a slow Bluetooth HID write),
|
||||
// to show that input_rumble does not wait for it. Read with cfg_get, as TOTK_TEST_PAD is: a test variable has no row in
|
||||
// the settings table, and cfg_int stops the game on a name without one.
|
||||
static int test_pad_rumble_ms(void) {
|
||||
const char *e = cfg_get("TOTK_TEST_PAD_RUMBLE_MS");
|
||||
return e ? atoi(e) : 0;
|
||||
}
|
||||
|
||||
static bool test_pad_rumble(void *userdata, Uint16 low, Uint16 high) {
|
||||
(void)userdata; (void)low; (void)high;
|
||||
plat_wait_ns((uint64_t)test_pad_rumble_ms() * 1000000ull);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void test_pad_attach(void) {
|
||||
static SDL_Joystick *joy; // kept open: a virtual joystick's axes are set through an open handle
|
||||
const char *e = cfg_get("TOTK_TEST_PAD");
|
||||
@@ -511,6 +648,7 @@ static void test_pad_attach(void) {
|
||||
d.naxes = SDL_GAMEPAD_AXIS_COUNT;
|
||||
d.nbuttons = SDL_GAMEPAD_BUTTON_COUNT;
|
||||
d.name = "TotK test gamepad";
|
||||
if (test_pad_rumble_ms() > 0) d.Rumble = test_pad_rumble;
|
||||
SDL_JoystickID id = SDL_AttachVirtualJoystick(&d);
|
||||
joy = id ? SDL_OpenJoystick(id) : NULL;
|
||||
if (!joy) {
|
||||
@@ -528,6 +666,14 @@ static void start(void) {
|
||||
binds_refresh();
|
||||
const char *e = cfg_get("TOTK_INPUT");
|
||||
if (e && !strcmp(e, "none")) { state = -1; rt_log("input: disabled (TOTK_INPUT=none)"); return; }
|
||||
steam_reveal();
|
||||
// SDL drops gamepad button presses and stick movements (and leaves the polled state unchanged) while its own
|
||||
// window lacks keyboard focus (SDL_PrivateJoystickShouldIgnoreEvent in SDL_joystick.c; centring and releases
|
||||
// pass). That applies where the window is SDL's (Linux); the Win32 window on Windows is not an SDL window. The
|
||||
// game keeps running out of focus by default (TOTK_ASSUME_FOCUS, ov_system.c oe_set_focus), so the gamepad has to
|
||||
// keep working there. With the setting off the game's main thread waits while unfocused and reads no input, so
|
||||
// the hint can stay on for the whole run.
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
if (!SDL_Init(SDL_INIT_GAMEPAD)) { state = -1; rt_log("input: SDL gamepad init failed (%s), keyboard only", SDL_GetError()); }
|
||||
else state = 1;
|
||||
if (state == 1) test_pad_attach();
|
||||
@@ -650,7 +796,7 @@ static void wheel_route(uint64_t *bp, int32_t sl[2], int32_t sr[2]) {
|
||||
|
||||
// Under lock, state 1: the open gamepad's inputs by position (pd[PAD_*] != 0 held); 0 without a connected gamepad.
|
||||
static int pad_physical(uint8_t pd[PAD_COUNT]) {
|
||||
if ((!pad || !SDL_GamepadConnected(pad)) && plat_now_ns() / 1000000u >= next_scan) { next_scan = plat_now_ns() / 1000000u + RESCAN_MS; scan_pads(); }
|
||||
if ((!pad || !SDL_GamepadConnected(pad) || pad_hidden) && plat_now_ns() / 1000000u >= next_scan) { next_scan = plat_now_ns() / 1000000u + RESCAN_MS; scan_pads(); }
|
||||
SDL_UpdateGamepads();
|
||||
if (!pad || !SDL_GamepadConnected(pad)) return 0;
|
||||
for (int p = PAD_SOUTH; p < PAD_ZL; p++) pd[p] = SDL_GetGamepadButton(pad, pad_sdl[p]);
|
||||
@@ -662,15 +808,149 @@ static int pad_physical(uint8_t pd[PAD_COUNT]) {
|
||||
|
||||
// Under lock, state 1: the open gamepad's buttons (Switch bits after TOTK_PAD_LAYOUT and the TOTK_BIND_* lines) and
|
||||
// sticks; 0 without a connected gamepad.
|
||||
// Under lock: the last pad_read's inputs by position, [PAD_GUIDE] the Home / Guide button (no Switch button), and its
|
||||
// left and right trigger axes, 0..32767: what the gamepad combos and the free camera read
|
||||
#define PAD_GUIDE PAD_COUNT
|
||||
static uint8_t pad_seen[PAD_COUNT + 1];
|
||||
static int16_t trigger_seen[2];
|
||||
|
||||
static int pad_read(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
uint8_t pd[PAD_COUNT] = {0};
|
||||
if (!pad_physical(pd)) return 0;
|
||||
if (!pad_physical(pd)) {
|
||||
memset(pad_seen, 0, sizeof pad_seen);
|
||||
memset(trigger_seen, 0, sizeof trigger_seen);
|
||||
return 0;
|
||||
}
|
||||
memcpy(pad_seen, pd, sizeof pd);
|
||||
pad_seen[PAD_GUIDE] = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_GUIDE);
|
||||
trigger_seen[0] = SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_LEFT_TRIGGER);
|
||||
trigger_seen[1] = SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER);
|
||||
*b |= input_map_pad_buttons(pd, pad_layout_get());
|
||||
stick(SDL_GAMEPAD_AXIS_LEFTX, SDL_GAMEPAD_AXIS_LEFTY, stick_dead_get(0), sl);
|
||||
stick(SDL_GAMEPAD_AXIS_RIGHTX, SDL_GAMEPAD_AXIS_RIGHTY, stick_dead_get(1), sr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t input_pad_combo(const char *env, const char *s) {
|
||||
uint32_t mask = 0;
|
||||
char name[32];
|
||||
size_t n = 0;
|
||||
for (const char *c = s;; c++) {
|
||||
if (*c && *c != '+' && *c != ' ') {
|
||||
if (n < sizeof name - 1) name[n++] = *c;
|
||||
continue;
|
||||
}
|
||||
if (n) {
|
||||
name[n] = 0;
|
||||
int p = !strcasecmp(name, "guide") || !strcasecmp(name, "home") ? PAD_GUIDE : input_pad_id(name);
|
||||
if (p == PAD_NONE) {
|
||||
rt_log("input: %s=%s: %s is not a gamepad button (south east west north lstick rstick "
|
||||
"l r zl zr start back guide dpad_*, paddles)", env, s, name);
|
||||
return 0;
|
||||
}
|
||||
mask |= 1u << p;
|
||||
n = 0;
|
||||
}
|
||||
if (!*c) break;
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
// TOTK_FREECAM_PAD (live): the combo that switches the free camera (freecam.c), for example zl+zr+lstick (LT+RT+L3);
|
||||
// none, the default (the settings table), for no combo. Under lock.
|
||||
static uint32_t freecam_pad_mask(void) {
|
||||
static unsigned seen;
|
||||
static int read;
|
||||
static uint32_t mask;
|
||||
unsigned v = cfg_version();
|
||||
if (read && v == seen) return mask;
|
||||
read = 1, seen = v;
|
||||
const char *s = cfg_value("TOTK_FREECAM_PAD");
|
||||
mask = *s && strcasecmp(s, "none") ? input_pad_combo("TOTK_FREECAM_PAD", s) : 0;
|
||||
return mask;
|
||||
}
|
||||
|
||||
// TOTK_FREECAM_KEY (live): the key that switches the free camera; none, the default (the settings table), for no key.
|
||||
// Under lock.
|
||||
static int freecam_key(void) {
|
||||
static unsigned seen;
|
||||
static int read, key;
|
||||
unsigned v = cfg_version();
|
||||
if (read && v == seen) return key;
|
||||
read = 1, seen = v;
|
||||
const char *s = cfg_value("TOTK_FREECAM_KEY");
|
||||
key = !*s || !strcasecmp(s, "none") ? KEY_NONE : input_key_id(s);
|
||||
if (key == KEY_NONE && *s && strcasecmp(s, "none"))
|
||||
rt_log("input: TOTK_FREECAM_KEY=%s is not a key name (docs/controls.md)", s);
|
||||
return key;
|
||||
}
|
||||
|
||||
static float trigger_unit(int16_t v) { // 0..1 past a 5 % dead zone
|
||||
float t = v / 32767.0f;
|
||||
return t < 0.05f ? 0 : (t - 0.05f) / 0.95f;
|
||||
}
|
||||
|
||||
// The free camera combo, latched like Minus+Plus (input_map.c, chord): once every button of it is down (on the gamepad,
|
||||
// or pressed by an input script) the free camera steps once (off, move, lock), and the buttons stay hidden from the
|
||||
// game until all are released; the free camera key steps it on its press. While the free camera moves it gets the
|
||||
// input and the game gets nothing, so Link stands still: the sticks (the keys' sticks merged into sl and sr), the
|
||||
// trigger axes or else ZL and ZR as buttons, a press of L or R as a speed click, and the mouse's motion, which
|
||||
// input_direct_mouse_sample then keeps from the game's camera. ZL, ZR, L and R are the merged Switch buttons, so the
|
||||
// keys bound to them count. Locked, the game gets the input as it is (freecam.c: the game steers Link by the camera it
|
||||
// draws). Off for other updates and with the freecam patch set off. Under lock.
|
||||
static void freecam_gate(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
static int held, key_held, available = -1, shoulder[2];
|
||||
if (available < 0) available = freecam_available();
|
||||
uint32_t mask = available ? freecam_pad_mask() : 0, raw = 0;
|
||||
int layout = pad_layout_get();
|
||||
for (int p = PAD_SOUTH; p <= PAD_GUIDE; p++) {
|
||||
if (!(mask >> p & 1)) continue;
|
||||
// A position counts as down on the gamepad or when the input script presses the Switch buttons it stands for,
|
||||
// as a gamepad would; the keys bound to those buttons do not (the free camera key is theirs). Home has no
|
||||
// Switch button: gamepad only.
|
||||
uint8_t one[PAD_COUNT] = {0};
|
||||
if (p < PAD_COUNT) one[p] = 1;
|
||||
if (pad_seen[p] || (p < PAD_COUNT && script_seen & input_map_pad_buttons(one, layout))) raw |= 1u << p;
|
||||
}
|
||||
if (!mask) held = 0;
|
||||
else if (held) held = raw != 0;
|
||||
else if (raw == mask) {
|
||||
held = 1;
|
||||
freecam_cycle();
|
||||
}
|
||||
int key = available ? freecam_key() : KEY_NONE;
|
||||
int key_down = key != KEY_NONE && ikb_foreground() && ikb_down(key);
|
||||
if (key_down && !key_held) freecam_cycle();
|
||||
key_held = key_down;
|
||||
if (available && freecam_state() == FREECAM_MOVE) {
|
||||
float lt = trigger_unit(trigger_seen[0]), rt = trigger_unit(trigger_seen[1]);
|
||||
if (*b >> B_ZL & 1) lt = 1;
|
||||
if (*b >> B_ZR & 1) rt = 1;
|
||||
FreecamPad fp = {sl[0] / (float)STICK_MAX, sl[1] / (float)STICK_MAX, sr[0] / (float)STICK_MAX,
|
||||
sr[1] / (float)STICK_MAX, lt, rt};
|
||||
freecam_pad(&fp);
|
||||
for (int k = 0; k < 2; k++) {
|
||||
int down = (int)(*b >> (k ? B_R : B_L) & 1);
|
||||
if (down && !shoulder[k]) freecam_speed_click(k);
|
||||
shoulder[k] = down;
|
||||
}
|
||||
if (ikb_captured() && ikb_foreground() && input_cursor_allowed()) {
|
||||
int32_t x, y;
|
||||
ikb_mouse_take(&x, &y); // what the stick emulation left (none in that mode: it is in sr already)
|
||||
float deg = 0.08f * mouse_sens_get(); // the game camera's rate a count (mouse_direct.c DEG_PER_COUNT)
|
||||
if (x || y) freecam_mouse(x * deg, y * deg);
|
||||
}
|
||||
*b = 0;
|
||||
sl[0] = sl[1] = sr[0] = sr[1] = 0;
|
||||
return;
|
||||
}
|
||||
shoulder[0] = shoulder[1] = 1; // a shoulder held when the free camera starts is no click
|
||||
if (!held) return;
|
||||
uint8_t sub[PAD_COUNT] = {0};
|
||||
for (int p = PAD_SOUTH; p < PAD_COUNT; p++) sub[p] = mask >> p & 1;
|
||||
*b &= ~input_map_pad_buttons(sub, pad_layout_get());
|
||||
}
|
||||
|
||||
int input_pad_stick_percent(double pct[2]) {
|
||||
int ok = 0;
|
||||
pct[0] = pct[1] = 0;
|
||||
@@ -741,6 +1021,9 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
else if (!click_held[i]) click_held[i] = 1, click_talk[i] = menu_cursor_dialogue();
|
||||
if (click_talk[i]) down[key] = 0, b |= 1ull << click_btn[i];
|
||||
}
|
||||
// The quick save and quick load keys are quicksave's while it is on (quicksave.c): they reach no binding
|
||||
// then, and do nothing while the settings menu or a text entry is open
|
||||
if (quicksave_on()) quicksave_keys(down, !g_menu && !g_block);
|
||||
if (cap && !g_menu && !g_block) gameplay_tweaks_prepare_keys(down, b);
|
||||
else gameplay_tweaks_reset();
|
||||
b |= input_map_buttons(down);
|
||||
@@ -777,7 +1060,16 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
if (pad_used) __atomic_store_n(&g_kbm_last, 0, __ATOMIC_RELAXED);
|
||||
else if (kbm_used) __atomic_store_n(&g_kbm_last, 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
script_apply(&b, sl, sr);
|
||||
// Without the keyboard and mouse poll above (TOTK_INPUT=none in scripted runs, or the window in the background), a
|
||||
// script's MOUSE lines still move the right stick wherever the mouse would (mouse_camera)
|
||||
if (!(state > 0 && ikb_foreground()) && input_script_mouse_recent() && !input_direct_mouse_active()) {
|
||||
int32_t k[2];
|
||||
mouse_camera(k, 0);
|
||||
pick(&sr[0], &sr[1], k[0], k[1]);
|
||||
}
|
||||
script_seen = 0;
|
||||
script_apply(&script_seen, sl, sr);
|
||||
b |= script_seen;
|
||||
wheel_route(&b, sl, sr);
|
||||
gameplay_tweaks_apply(__atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED), input_gameplay_active(), &b, &sl[0], &sl[1], &sr[0], &sr[1]);
|
||||
rec_apply(b, sl, sr);
|
||||
@@ -788,6 +1080,7 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
static int overlay_held; // L3+R3 step the performance overlay (F10)
|
||||
int overlay = input_overlay_gate(&overlay_held, &b);
|
||||
sl[0] = st[0], sl[1] = st[1], sr[0] = st[2], sr[1] = st[3];
|
||||
freecam_gate(&b, sl, sr); // TOTK_FREECAM_PAD steps the free camera, which takes the pad while moving (freecam.c)
|
||||
plat_mutex_unlock(&lock);
|
||||
if (toggle) menu_toggle();
|
||||
if (overlay) menu_perf_cycle();
|
||||
@@ -852,7 +1145,10 @@ static int blocked(volatile int32_t *flag, volatile uint64_t *closed, const char
|
||||
|
||||
void input_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
poll_merged(buttons, lx, ly, rx, ry);
|
||||
if (!g_block && !g_menu) menu_cursor_poll(buttons);
|
||||
// While quick load drives the game's load menu the pointer leaves it alone and the game gets only its presses
|
||||
if (!g_block && !g_menu && !quicksave_busy()) menu_cursor_poll(buttons);
|
||||
// A quick load under way goes on while the settings menu or a text entry opens: the held picture ends with it
|
||||
if ((quicksave_busy() || (!g_block && !g_menu)) && quicksave_poll(buttons, lx, ly, rx, ry)) return;
|
||||
const int32_t axes[4] = {*lx, *ly, *rx, *ry};
|
||||
int text = blocked(&g_block, &g_block_closed, "text entry", *buttons, axes),
|
||||
menu = blocked(&g_menu, &g_menu_closed, "menu", *buttons, axes);
|
||||
@@ -930,17 +1226,83 @@ int input_rumble_triggers_enabled(void) {
|
||||
return cfg_bool("TOTK_RUMBLE_TRIGGERS");
|
||||
}
|
||||
|
||||
int input_rumble(uint16_t low, uint16_t high, uint32_t ms) {
|
||||
int ok = 0;
|
||||
static int triggers = -1;
|
||||
static unsigned seen;
|
||||
if (triggers < 0 || seen != cfg_version()) seen = cfg_version(), triggers = input_rumble_triggers_enabled();
|
||||
// The rumble worker. input_rumble only stores the newest request (rq) and wakes the worker; the worker sends it to the
|
||||
// gamepad. A Bluetooth HID write can block for tens of milliseconds, and the callers are the guest thread that runs
|
||||
// SendVibrationValue and every path that takes `lock`, so no SDL rumble call is made on them. Requests that pile up
|
||||
// while the worker is in a write are dropped except the newest (Savage Wind Recomp, commit a8ad674, does the same for
|
||||
// issue #730).
|
||||
//
|
||||
// The worker takes its own handle on the open gamepad under `lock` (SDL_OpenGamepad of an open pad's id returns the same
|
||||
// object with its reference count raised) and releases `lock` before the write, so a scan_pads close of `pad` meanwhile
|
||||
// only drops one reference and the object lives until the worker's SDL_CloseGamepad. SDL itself serialises the write
|
||||
// with its other joystick calls (SDL_RumbleJoystick runs under the joystick lock), so a poll or motion_main's
|
||||
// SDL_UpdateGamepads that lands inside a slow write still waits for it; the thread that sends rumble and the other
|
||||
// `lock` users that make no SDL gamepad call do not.
|
||||
typedef struct { uint16_t low, high; uint32_t ms; int pending; } RumbleReq;
|
||||
static PlatMutex rq_lock = PLAT_MUTEX_INIT; // guards rq, rumble_stop and rumble_thread; taken after `lock`, never before it
|
||||
static PlatCond rq_cond = PLAT_COND_INIT;
|
||||
static RumbleReq rq;
|
||||
static int rumble_stop;
|
||||
static PlatThread *rumble_thread;
|
||||
|
||||
static void rumble_write(uint16_t low, uint16_t high, uint32_t ms) {
|
||||
SDL_Gamepad *g = NULL;
|
||||
int triggers = input_rumble_triggers_enabled();
|
||||
plat_mutex_lock(&lock);
|
||||
if (state == 1 && pad && pad_rumble) {
|
||||
ok = SDL_RumbleGamepad(pad, low, high, ms);
|
||||
if (triggers) SDL_RumbleGamepadTriggers(pad, high, high, ms); // unsupported pads return false: ignored
|
||||
}
|
||||
if (state == 1 && pad && pad_rumble) g = SDL_OpenGamepad(SDL_GetGamepadID(pad));
|
||||
plat_mutex_unlock(&lock);
|
||||
if (!g) return;
|
||||
SDL_RumbleGamepad(g, low, high, ms);
|
||||
if (triggers) SDL_RumbleGamepadTriggers(g, high, high, ms); // unsupported pads return false: ignored
|
||||
SDL_CloseGamepad(g);
|
||||
}
|
||||
|
||||
static void rumble_main(void *arg) {
|
||||
(void)arg;
|
||||
plat_mutex_lock(&rq_lock);
|
||||
for (;;) {
|
||||
while (!rq.pending && !rumble_stop) plat_cond_wait(&rq_cond, &rq_lock);
|
||||
if (!rq.pending) break;
|
||||
RumbleReq r = rq;
|
||||
rq.pending = 0;
|
||||
plat_mutex_unlock(&rq_lock);
|
||||
rumble_write(r.low, r.high, r.ms);
|
||||
plat_mutex_lock(&rq_lock);
|
||||
}
|
||||
plat_mutex_unlock(&rq_lock);
|
||||
}
|
||||
|
||||
// Stops the motors and the worker at exit: a pad keeps its last request running for its duration otherwise.
|
||||
static void rumble_exit(void) {
|
||||
plat_mutex_lock(&rq_lock);
|
||||
PlatThread *t = rumble_thread;
|
||||
rq = (RumbleReq){0, 0, 0, 1};
|
||||
rumble_stop = 1;
|
||||
plat_cond_signal(&rq_cond);
|
||||
plat_mutex_unlock(&rq_lock);
|
||||
if (t) plat_thread_join_ns(t, 300000000ull); // a write stuck past this is left to the exit
|
||||
}
|
||||
|
||||
// Drops the request that has not been sent yet (the gamepad it was for went away). A request in flight holds its own
|
||||
// handle and ends by itself. Under lock.
|
||||
static void rumble_cancel(void) {
|
||||
plat_mutex_lock(&rq_lock);
|
||||
rq.pending = 0;
|
||||
plat_mutex_unlock(&rq_lock);
|
||||
}
|
||||
|
||||
int input_rumble(uint16_t low, uint16_t high, uint32_t ms) {
|
||||
int ok = __atomic_load_n(&rumble_ready, __ATOMIC_ACQUIRE);
|
||||
if (!ok) return 0;
|
||||
plat_mutex_lock(&rq_lock);
|
||||
if (!rumble_thread && !rumble_stop) {
|
||||
rumble_thread = plat_thread_new(rumble_main, NULL, "rumble");
|
||||
if (!rumble_thread) rt_fatal("input: cannot start the rumble thread");
|
||||
atexit(rumble_exit);
|
||||
}
|
||||
rq = (RumbleReq){low, high, ms, 1};
|
||||
plat_cond_signal(&rq_cond);
|
||||
plat_mutex_unlock(&rq_lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -973,17 +1335,24 @@ static void copy_name(char *dst, size_t cap, const char *src) {
|
||||
dst[n] = 0;
|
||||
}
|
||||
|
||||
// Under lock: the open gamepad's identity for the saved bias. Its name, plus a hash of SDL's serial when the pad
|
||||
// Under lock: the identity of src (motion_source) for the saved bias. Its name, plus a hash of SDL's serial when the pad
|
||||
// reports one (Switch and PlayStation pads report their Bluetooth address), so two controllers of one model keep their
|
||||
// own bias; the hash keeps the address out of totk.ini and the log, which players post with bug reports.
|
||||
static void pad_identity(char *dst, size_t cap) {
|
||||
const char *name = SDL_GetGamepadName(pad), *serial = SDL_GetGamepadSerial(pad);
|
||||
static void pad_identity(SDL_Gamepad *src, char *dst, size_t cap) {
|
||||
const char *name = SDL_GetGamepadName(src), *serial = SDL_GetGamepadSerial(src);
|
||||
char id[160];
|
||||
if (serial && *serial) {
|
||||
uint32_t h = 2166136261u; // FNV-1a
|
||||
for (const char *c = serial; *c; c++) h = (h ^ (uint8_t)*c) * 16777619u;
|
||||
snprintf(id, sizeof id, "%s #%08x", name ? name : "", h);
|
||||
} else snprintf(id, sizeof id, "%s", name ? name : "");
|
||||
// Steam's virtual pad takes the name of the controller behind it but sends Steam's corrected motion: its bias
|
||||
// is its own (pad_bias_select would otherwise load the raw controller's)
|
||||
// A controller read past Steam Input sends what Steam set it to: on the Steam Controller that is motion the
|
||||
// controller already corrected, so the bias of the same controller read with Steam closed does not apply either
|
||||
if (steam_virtual(src)) strncat(id, " (Steam Input)", sizeof id - strlen(id) - 1);
|
||||
else if (steam_hidden_n && steam_hidden_id(SDL_GetGamepadID(src)))
|
||||
strncat(id, " (under Steam)", sizeof id - strlen(id) - 1);
|
||||
copy_name(dst, cap, id);
|
||||
}
|
||||
|
||||
@@ -991,35 +1360,82 @@ static void pad_identity(char *dst, size_t cap) {
|
||||
// previous controller's bias and any attempt still collecting from it are dropped, then the bias saved in totk.ini is
|
||||
// taken when gyro_bias_pad names this controller. It is taken with gyro_calibration off too: the switch only decides
|
||||
// whether motion_feed subtracts it, so turning the switch on mid-run applies the saved bias.
|
||||
static void pad_bias_select(void) {
|
||||
static void pad_bias_select(SDL_Gamepad *src) {
|
||||
char id[128];
|
||||
pad_identity(id, sizeof id);
|
||||
pad_identity(src, id, sizeof id);
|
||||
motion_bias_reset(motion_global());
|
||||
calib_pad_name[0] = 0;
|
||||
const char *saved = cfg_get("TOTK_GYRO_BIAS_PAD");
|
||||
if (saved && !strcmp(saved, id)) {
|
||||
motion_bias_load(motion_global());
|
||||
copy_name(calib_pad_name, sizeof calib_pad_name, SDL_GetGamepadName(pad));
|
||||
copy_name(calib_pad_name, sizeof calib_pad_name, SDL_GetGamepadName(src));
|
||||
rt_log("input: gyro bias loaded from totk.ini for %s", calib_pad_name);
|
||||
}
|
||||
}
|
||||
|
||||
// Under lock: (re)enable the sensors when the open gamepad changed; 1 if it has both and they are on.
|
||||
static int sensors_ready(void) {
|
||||
SDL_JoystickID id = SDL_GetGamepadID(pad);
|
||||
// Under lock: the gamepad the sensors are read from, NULL without one. The open pad when it has a gyro and an
|
||||
// accelerometer, or when Steam hid nothing. Otherwise (Steam's virtual pad, which has neither) the first controller
|
||||
// Steam hid that has both, looked for once a RESCAN_MS; one without them is not opened again until it reconnects.
|
||||
static SDL_Gamepad *motion_source(void) {
|
||||
static SDL_JoystickID rejected[8];
|
||||
if (motion_extra && !SDL_GamepadConnected(motion_extra)) {
|
||||
rt_log("input: \"%s\" (motion only) disconnected", SDL_GetGamepadName(motion_extra));
|
||||
SDL_CloseGamepad(motion_extra);
|
||||
motion_extra = NULL;
|
||||
}
|
||||
int pad_on = pad && SDL_GamepadConnected(pad);
|
||||
// Newer Steam clients give the virtual pad motion too, but already corrected by Steam (and gated by the layout's
|
||||
// gyro settings), so the bias calibrated on the raw controller would count twice and the camera drift. Under
|
||||
// Steam Input the real controller's raw sensors come first; the virtual pad's are the fallback.
|
||||
if (pad_on && has_motion(pad) && !(steam_hidden_n && steam_virtual(pad))) {
|
||||
if (motion_extra) { SDL_CloseGamepad(motion_extra); motion_extra = NULL; }
|
||||
return pad;
|
||||
}
|
||||
if (!motion_extra && steam_hidden_n && plat_now_ns() / 1000000u >= next_motion_scan) {
|
||||
next_motion_scan = plat_now_ns() / 1000000u + RESCAN_MS;
|
||||
int n = 0;
|
||||
SDL_JoystickID *ids = SDL_GetGamepads(&n), skip = pad_on ? SDL_GetGamepadID(pad) : 0;
|
||||
for (int i = 0; ids && i < n && !motion_extra; i++) {
|
||||
int seen = 0;
|
||||
for (int r = 0; r < 8; r++) seen |= rejected[r] == ids[i];
|
||||
if (ids[i] == skip || seen || !steam_hidden_id(ids[i])) continue;
|
||||
SDL_Gamepad *g = SDL_OpenGamepad(ids[i]);
|
||||
if (g && has_motion(g)) {
|
||||
motion_extra = g;
|
||||
rt_log("input: motion from \"%s\" (%04x:%04x), the controller behind Steam Input's virtual gamepad",
|
||||
SDL_GetGamepadName(g), SDL_GetGamepadVendor(g), SDL_GetGamepadProduct(g));
|
||||
} else {
|
||||
if (g) SDL_CloseGamepad(g);
|
||||
memmove(rejected + 1, rejected, sizeof rejected - sizeof rejected[0]);
|
||||
rejected[0] = ids[i];
|
||||
}
|
||||
}
|
||||
SDL_free(ids);
|
||||
}
|
||||
return motion_extra ? motion_extra : pad_on ? pad : NULL;
|
||||
}
|
||||
|
||||
// Under lock: (re)enable the sensors when the motion source changed; 1 if it has both and they are on.
|
||||
static int sensors_ready(SDL_Gamepad *src) {
|
||||
SDL_JoystickID id = SDL_GetGamepadID(src);
|
||||
if (id == sensor_pad) return sensor_ok;
|
||||
sensor_pad = id;
|
||||
pad_bias_select();
|
||||
pad_bias_select(src);
|
||||
// Nothing drains the SDL event queue: no event per sample (the data still updates, SDL_SendJoystickSensor)
|
||||
SDL_SetEventEnabled(SDL_EVENT_GAMEPAD_SENSOR_UPDATE, false);
|
||||
sensor_ok =SDL_GamepadHasSensor(pad, SDL_SENSOR_GYRO) && SDL_GamepadHasSensor(pad, SDL_SENSOR_ACCEL) &&
|
||||
SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, true) &&
|
||||
SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_ACCEL, true);
|
||||
if (sensor_ok) rt_log("input: motion sensors on (gyro %.0f Hz, accelerometer %.0f Hz)",
|
||||
(double)SDL_GetGamepadSensorDataRate(pad, SDL_SENSOR_GYRO),
|
||||
(double)SDL_GetGamepadSensorDataRate(pad, SDL_SENSOR_ACCEL));
|
||||
sensor_ok = has_motion(src) &&
|
||||
SDL_SetGamepadSensorEnabled(src, SDL_SENSOR_GYRO, true) &&
|
||||
SDL_SetGamepadSensorEnabled(src, SDL_SENSOR_ACCEL, true);
|
||||
if (sensor_ok) {
|
||||
rt_log("input: motion sensors on (gyro %.0f Hz, accelerometer %.0f Hz)",
|
||||
(double)SDL_GetGamepadSensorDataRate(src, SDL_SENSOR_GYRO),
|
||||
(double)SDL_GetGamepadSensorDataRate(src, SDL_SENSOR_ACCEL));
|
||||
motion_restart(motion_global()); // another controller: its own orientation, from its first reading
|
||||
} else if (has_motion(src)) // after PR #1024: the SDL error, not "no sensors", when enabling them failed
|
||||
rt_log("input: \"%s\" has a gyro and an accelerometer but SDL could not turn them on (%s): the six-axis sensor "
|
||||
"reads a controller at rest", SDL_GetGamepadName(src), SDL_GetError());
|
||||
else rt_log("input: \"%s\" has no gyro and accelerometer: the six-axis sensor reads a controller at rest",
|
||||
SDL_GetGamepadName(pad));
|
||||
SDL_GetGamepadName(src));
|
||||
return sensor_ok;
|
||||
}
|
||||
|
||||
@@ -1044,10 +1460,11 @@ static void motion_main(void *arg) {
|
||||
float a[3], g[3];
|
||||
int have = 0;
|
||||
plat_mutex_lock(&lock);
|
||||
if (pad && SDL_GamepadConnected(pad)) {
|
||||
SDL_Gamepad *src = motion_source();
|
||||
if (src) {
|
||||
SDL_UpdateGamepads();
|
||||
have = sensors_ready() && SDL_GetGamepadSensorData(pad, SDL_SENSOR_ACCEL, a, 3) &&
|
||||
SDL_GetGamepadSensorData(pad, SDL_SENSOR_GYRO, g, 3);
|
||||
have = sensors_ready(src) && SDL_GetGamepadSensorData(src, SDL_SENSOR_ACCEL, a, 3) &&
|
||||
SDL_GetGamepadSensorData(src, SDL_SENSOR_GYRO, g, 3);
|
||||
}
|
||||
plat_mutex_unlock(&lock);
|
||||
if (!have || !input_motion_enabled()) continue;
|
||||
@@ -1080,18 +1497,19 @@ void input_motion_calibrate(void) {
|
||||
// The menu can run before the game starts the six-axis sensor (the title screen): the thread starts here then.
|
||||
if (input_gyro_calibration_enabled() && input_motion_enabled()) motion_thread_start();
|
||||
const char *why = NULL;
|
||||
SDL_Gamepad *src = motion_thread == 1 ? motion_source() : NULL;
|
||||
if (!input_gyro_calibration_enabled()) why = "gyro_calibration is off";
|
||||
else if (!input_motion_enabled()) why = "motion is off (TOTK_MOTION=0)";
|
||||
else if (motion_thread != 1) why = "no SDL gamepad support";
|
||||
else if (!pad || !SDL_GamepadConnected(pad)) why = "no gamepad";
|
||||
else if (!src) why = "no gamepad";
|
||||
// sensors_ready here, not at the sensor thread's next look at a new pad: that look selects the pad's bias and
|
||||
// would cancel the attempt that starts below.
|
||||
else if (!sensors_ready()) why = "the gamepad has no gyro and accelerometer";
|
||||
else if (!sensors_ready(src)) why = "the gamepad has no gyro and accelerometer";
|
||||
if (why) rt_log("input: calibrate gyro ignored: %s", why);
|
||||
else {
|
||||
char id[128];
|
||||
pad_identity(id, sizeof id);
|
||||
copy_name(calib_pad_name, sizeof calib_pad_name, SDL_GetGamepadName(pad));
|
||||
pad_identity(src, id, sizeof id);
|
||||
copy_name(calib_pad_name, sizeof calib_pad_name, SDL_GetGamepadName(src));
|
||||
motion_calibrate_start(motion_global(), id, kern_now_ns());
|
||||
rt_log("input: gyro calibration started on %s", calib_pad_name);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,27 @@ int menu_cursor_menu(void);
|
||||
int menu_cursor_strip(void);
|
||||
// The Purah Pad's camera is open: its frame and pointer without the map the Scope has. 0 with the menu cursor off.
|
||||
int menu_cursor_camera(void);
|
||||
// menu_cursor.c, the game's menus by name for quicksave.c (game thread, 1.4.3): a screen of that layout is open; the
|
||||
// screen with the focus box (its layout name) and the focused node, 0 with none; the focused screen's shown button of
|
||||
// parts layout parts with root pane root (usable_out: it can be pressed), 0 none; the load list's first entry with a
|
||||
// save; the focus to node (1 once it is there)
|
||||
int menu_ui_open(const char *layout);
|
||||
int menu_ui_focus(char *screen, size_t n, uint64_t *node);
|
||||
uint64_t menu_ui_button(const char *parts, const char *root, int *usable_out);
|
||||
uint64_t menu_ui_first_save(void);
|
||||
int menu_ui_focus_to(uint64_t node);
|
||||
// quicksave.c (TOTK_QUICKSAVE): keys: the keys held now, its two keys (TOTK_QUICKSAVE_KEY, TOTK_QUICKLOAD_KEY) start
|
||||
// it when pressed and act is set, and are cleared from down either way; request: save (0) or load (1), as the keys
|
||||
// and the script lines QUICKSAVE / QUICKLOAD do; guest: once per game pad read on the game thread, where quick save
|
||||
// calls into the game; poll: once per game pad read, 1 while quick load drives the game's load menu with its own
|
||||
// presses in place of the input; busy: quick load runs
|
||||
struct Cpu;
|
||||
int quicksave_on(void); // TOTK_QUICKSAVE is on and the game is 1.4.3
|
||||
void quicksave_keys(uint8_t *down, int act);
|
||||
void quicksave_request(int load);
|
||||
void quicksave_guest(struct Cpu *c);
|
||||
int quicksave_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
|
||||
int quicksave_busy(void);
|
||||
// The same for host UI (the text entry): never blocked. input_block(1) while a text entry is open: input_poll then
|
||||
// reports nothing; input_block(0) when it closes: nothing until all buttons and stick directions are released.
|
||||
void input_poll_ui(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
|
||||
@@ -70,9 +91,25 @@ void input_menu(int open);
|
||||
// of the combo, sticks are lx, ly, rx, ry. Returns 1 in the poll where the combo goes down (toggle the menu once).
|
||||
int input_menu_gate(int *held, int menu_open, uint64_t *buttons, int32_t sticks[4]);
|
||||
int input_overlay_gate(int *held, uint64_t *buttons); // L3+R3: 1 in the poll both go down
|
||||
// A gamepad combo setting: buttons by position joined with '+' (guide+south: Home and the bottom face button, the
|
||||
// pad: names of the bind_ lines plus guide or home). Bit p is PAD_* p, bit PAD_COUNT the Home button; 0 for an empty
|
||||
// value or one with a name that is no button, which logs a line naming env.
|
||||
uint32_t input_pad_combo(const char *env, const char *s);
|
||||
int input_pad_read(uint64_t *buttons, int32_t *lx, int32_t *ly);
|
||||
// The gamepad layout in effect (PAD_LAYOUT_*, input_map.h; TOTK_PAD_LAYOUT, live); -1 without a gamepad. Any thread.
|
||||
int input_pad_layout(void);
|
||||
|
||||
// Free camera (freecam.c). input.c steps it with TOTK_FREECAM_PAD and, while it moves, hands it the gamepad and gives
|
||||
// the game none: sticks -1..1 with up +y after the dead zone, triggers 0..1; each L or R press is one speed click.
|
||||
// Locked, the view stays and the game gets the input.
|
||||
typedef struct { float lx, ly, rx, ry, lt, rt; } FreecamPad;
|
||||
enum { FREECAM_OFF, FREECAM_MOVE, FREECAM_LOCK };
|
||||
int freecam_available(void); // game 1.4.3 with the freecam patch set on
|
||||
int freecam_state(void); // FREECAM_*
|
||||
void freecam_cycle(void); // off, move, lock, off; logs; input thread
|
||||
void freecam_pad(const FreecamPad *p);
|
||||
void freecam_speed_click(int faster); // R (1) doubles the speed, L (0) halves it
|
||||
void freecam_mouse(double right_deg, double down_deg); // a turn from the mouse, added at the next step
|
||||
// How far the open gamepad's left (pct[0]) and right (pct[1]) sticks are from the centre now, in percent of full
|
||||
// deflection, before the dead zone: the menu shows it on the dead zone rows, so a drifting stick's resting value can be
|
||||
// read off. 0 (and both 0) without a connected gamepad. Any thread.
|
||||
@@ -128,6 +165,9 @@ int input_motion_calib_state(char *pad, size_t cap);
|
||||
int input_gyro_calibration_enabled(void);
|
||||
// The fusion's own read of the same switch (motion_fusion.c); input.c reaches it for the row's state.
|
||||
int motion_calibration_enabled(void);
|
||||
// The drift tracker's switch (gyro_auto_bias, live): the drift left after calibration, learned while the controller
|
||||
// lies still, is subtracted too.
|
||||
int motion_auto_bias_enabled(void);
|
||||
// SDL sensor values (accelerometer m/s^2, gyro rad/s, SDL gamepad axes) to the Switch controller frame motion_feed
|
||||
// takes (acceleration in G as gravity reads, rotation rad/s). The mapping is documented in input_win.c.
|
||||
void input_motion_axes(const float sdl_acc[3], const float sdl_gyro[3], double acc_g[3], double gyro[3]);
|
||||
|
||||
+10
-5
@@ -66,13 +66,13 @@ const char *input_pad_name(int pad) { return pad > PAD_NONE && pad < PAD_COUNT ?
|
||||
|
||||
void input_map_reset(void) { input_map = defaults; }
|
||||
|
||||
static int key_id(const char *name) {
|
||||
int input_key_id(const char *name) {
|
||||
for (int k = KEY_A; k < KEY_COUNT; k++)
|
||||
if (key_names[k] && !strcasecmp(key_names[k], name)) return k;
|
||||
return KEY_NONE;
|
||||
}
|
||||
|
||||
static int pad_id(const char *name) {
|
||||
int input_pad_id(const char *name) {
|
||||
for (int p = PAD_SOUTH; p < PAD_COUNT; p++)
|
||||
if (!strcasecmp(pad_names[p], name)) return p;
|
||||
return PAD_NONE;
|
||||
@@ -133,12 +133,12 @@ int input_map_bind(const char *button, const char *list) {
|
||||
int ok = 0;
|
||||
if (!strncasecmp(tok, "pad:", 4) && action < B_SL_LEFT) {
|
||||
const char *name = trim(tok + 4);
|
||||
int p = pad_id(name);
|
||||
int p = input_pad_id(name);
|
||||
if (!strcasecmp(name, "default")) pad_def = ok = 1;
|
||||
else if (p && np < INPUT_PAD_BINDING_MAX) pads[np++] = (uint8_t)p, ok = 1;
|
||||
} else if (!strncasecmp(tok, "key:", 4)) {
|
||||
const char *name = trim(tok + 4);
|
||||
int k = key_id(name);
|
||||
int k = input_key_id(name);
|
||||
if (!strcasecmp(name, "default")) key_def = ok = 1;
|
||||
else if (k && nk < INPUT_BINDING_MAX) keys[nk++] = (uint8_t)k, ok = 1;
|
||||
}
|
||||
@@ -307,12 +307,17 @@ int input_pad_layout_pick(const char *setting, int east_labelled_a) {
|
||||
|
||||
int input_prompts_pick(const char *prompts, const char *pad_layout) {
|
||||
if (prompts && *prompts)
|
||||
return !strcasecmp(prompts, "xbox") ? PROMPTS_XBOX : !strcasecmp(prompts, "pc") ? PROMPTS_PC : PROMPTS_NINTENDO;
|
||||
return !strcasecmp(prompts, "xbox") ? PROMPTS_XBOX
|
||||
: !strcasecmp(prompts, "playstation") || !strcasecmp(prompts, "ps") ? PROMPTS_PLAYSTATION
|
||||
: !strcasecmp(prompts, "pc") ? PROMPTS_PC : PROMPTS_NINTENDO;
|
||||
return pad_layout && !strcasecmp(pad_layout, "xbox_prompts") ? PROMPTS_XBOX : PROMPTS_NINTENDO;
|
||||
}
|
||||
|
||||
const char *input_prompts_folder(int prompts, const char *pad_layout) {
|
||||
if (prompts == PROMPTS_PC) return "romfs-patches-pc";
|
||||
if (prompts == PROMPTS_PLAYSTATION)
|
||||
return input_pad_layout_pick(pad_layout, 0) == PAD_LAYOUT_NINTENDO ? "romfs-patches-playstation"
|
||||
: "romfs-patches-playstation-xbox";
|
||||
if (prompts != PROMPTS_XBOX) return NULL;
|
||||
// The folders are read at start, before a pad is open: auto counts as Xbox, as for a pad without Nintendo labels.
|
||||
// A Nintendo-labelled pad under auto plays by label too (its A is on the button labelled A), so it matches as well.
|
||||
|
||||
+12
-7
@@ -73,6 +73,8 @@ void input_map_reset(void);
|
||||
// stick directions the keys drive), then SHAKE. Keys: a-z 0-9 space tab lshift ... (key_names in input_map.c). Pads: south east ...
|
||||
const char *input_action_name(int action);
|
||||
const char *input_key_name(int key);
|
||||
int input_key_id(const char *name); // KEY_NONE for a name without a key
|
||||
int input_pad_id(const char *name); // PAD_NONE for a name without a gamepad button
|
||||
const char *input_pad_name(int pad);
|
||||
// Replaces every binding of the action `button` (an action name) with `list`: comma separated "pad:<name>" and
|
||||
// "key:<name>" entries, "key:default" / "pad:default" for that part's defaults, or "none" for no input. A part the list
|
||||
@@ -91,18 +93,21 @@ int input_pad_layout_pick(const char *setting, int east_labelled_a);
|
||||
|
||||
// Button prompts (TOTK_PROMPTS): the controller whose buttons the game's prompts show. Nintendo: the game's own. Xbox:
|
||||
// LB RB LT RT, Menu, View and a d-pad cross for the other buttons, and the face buttons named by the label of the
|
||||
// button the pad layout presses (runtime/romfs.c overlay_init, tools/make_romfs_patches.py --prompts). PC: the key or
|
||||
// button the pad layout presses (runtime/romfs.c overlay_init, tools/make_romfs_patches.py --prompts). PlayStation: the
|
||||
// face buttons as ○ × △ □, L1 R1 L2 R2, Options and Share, likewise on the button the pad layout presses. PC: the key or
|
||||
// mouse button the keyboard defaults press each button with, the mouse for the right stick.
|
||||
enum { PROMPTS_NINTENDO, PROMPTS_XBOX, PROMPTS_PC };
|
||||
// The prompts for a TOTK_PROMPTS value ("nintendo", "xbox" or "pc", any case). Unset or empty: Xbox while the pad
|
||||
// layout setting is "xbox_prompts", else Nintendo.
|
||||
enum { PROMPTS_NINTENDO, PROMPTS_XBOX, PROMPTS_PLAYSTATION, PROMPTS_PC };
|
||||
// The prompts for a TOTK_PROMPTS value ("nintendo", "xbox", "playstation" or "pc", any case). Unset or empty: Xbox
|
||||
// while the pad layout setting is "xbox_prompts", else Nintendo.
|
||||
int input_prompts_pick(const char *prompts, const char *pad_layout);
|
||||
// The folder next to romfs-index.bin that holds those prompts for a TOTK_PAD_LAYOUT value, NULL for the game's own. The
|
||||
// Nintendo layout plays an Xbox pad by position, so its folder names the face buttons the other way round
|
||||
// (romfs-patches-xbox: the right button does A and is labelled B); xbox and auto put every Switch button on the button
|
||||
// labelled with its letter (auto picks the layout per pad by its labels), so they share romfs-patches-xbox-label. The PC
|
||||
// prompts follow no pad: romfs-patches-pc whatever the layout (romfs.c overlay_init serves romfs-patches-pc-<w>x<h>
|
||||
// under that name at a game resolution of another shape).
|
||||
// labelled with its letter (auto picks the layout per pad by its labels), so they share romfs-patches-xbox-label. The
|
||||
// PlayStation prompts have the same two folders: romfs-patches-playstation (Nintendo layout, A on the right button is
|
||||
// circle) and romfs-patches-playstation-xbox (xbox and auto, A on the bottom button is cross). The PC prompts follow no
|
||||
// pad: romfs-patches-pc whatever the layout (romfs.c overlay_init serves romfs-patches-pc-<w>x<h> under that name at a
|
||||
// game resolution of another shape).
|
||||
const char *input_prompts_folder(int prompts, const char *pad_layout);
|
||||
// down[pad] != 0 for the gamepad inputs held. Returns the Switch button bits (0..15) the layout's pad table presses.
|
||||
uint64_t input_map_pad_buttons(const uint8_t down[PAD_COUNT], int layout);
|
||||
|
||||
@@ -38,3 +38,10 @@ extern volatile int kern_test_cv_old_order; // WaitProcessWideKeyAtomi
|
||||
// the key (MNG's pre-fix order, the negative control)
|
||||
extern void (*volatile kern_test_cv_hook)(void); // called right after the lock release, holding the kernel lock
|
||||
extern void (*volatile svc_test_exit_hook)(unsigned code); // svc 0x07 calls it instead of ExitProcess (probes)
|
||||
|
||||
// ---- mod plugin service run (plugin_init.c sets these; the game calls none of the SVCs they serve)
|
||||
extern uint64_t rt_svc_tick_offset; // added to GetSystemTick (0x1E): the service run's second run picks other ticks
|
||||
extern int (*rt_plugin_svc)(Cpu *c, uint32_t imm, uint64_t pc); // with RT_TRACE_PLUGIN: sees each SVC
|
||||
// first; 1: refused, the result is in x0 and the SVC does not run
|
||||
extern uint32_t (*rt_process_memory)(int unmap, uint64_t dst, uint32_t process, uint64_t src, uint64_t size);
|
||||
// Map/UnmapProcessMemory (0x74/0x75); NULL outside the service run: fatal
|
||||
+95
-16
@@ -47,11 +47,12 @@ typedef struct {
|
||||
uint64_t *plt_slot, *plt_stub, nplt; // PLT stubs sorted by GOT slot (ldr_plt_stub), built on first use
|
||||
// statistics
|
||||
uint64_t kinds[K_COUNT], sym_import, sym_own;
|
||||
uint32_t imports, import_to[MOD_COUNT], weak_unresolved, strong_unresolved;
|
||||
uint32_t imports, import_to[RT_MAX_MODULES], weak_unresolved, strong_unresolved;
|
||||
uint32_t init_off;
|
||||
} Mod;
|
||||
|
||||
static Mod mods[MOD_COUNT];
|
||||
static Mod mods[RT_MAX_MODULES];
|
||||
GuestFn ldr_plugin_import;
|
||||
static int nmods;
|
||||
static uint64_t identity_refs, stubs;
|
||||
static int *ovr_used, *obs_used; // per linked table entry, plus probe overrides counted separately
|
||||
@@ -74,6 +75,51 @@ static void hex32(const uint8_t d[32], char out[65]) {
|
||||
for (int i = 0; i < 32; i++) snprintf(out + 2 * i, 3, "%02x", d[i]);
|
||||
}
|
||||
|
||||
static uint8_t *read_path_verified(const char *path, const char *want, size_t *len, const char *hint) {
|
||||
uint8_t *p = read_file(path, len);
|
||||
if (!p) rt_fatal("loader: cannot read %s (%s)", path, hint);
|
||||
uint8_t d[32];
|
||||
char hex[65];
|
||||
rt_sha256(p, *len, d);
|
||||
hex32(d, hex);
|
||||
if (strcmp(hex, want)) rt_fatal("loader: %s has SHA-256 %s, expected %s", path, hex, want);
|
||||
return p;
|
||||
}
|
||||
|
||||
// Mod plugins of the layout whose file is gone (their mod was removed): a rebuild without them is due (cheats.c
|
||||
// rebuild_if_needed), keyed by their paths.
|
||||
static int plugins_gone;
|
||||
static uint32_t plugins_gone_key = 0x811C9DC5u;
|
||||
|
||||
int ldr_plugins_gone(uint32_t *key) {
|
||||
if (plugins_gone) *key = (*key ^ plugins_gone_key) * 0x01000193u;
|
||||
return plugins_gone;
|
||||
}
|
||||
|
||||
// 1 when the plugin file of lay is the one the build lifted; logged when not.
|
||||
static int plugin_file_ok(const RtLayoutEntry *lay) {
|
||||
size_t len;
|
||||
uint8_t *p = read_file(lay->file, &len);
|
||||
if (!p) {
|
||||
rt_log("loader: %s: cannot read %s; the plugin is left out", lay->name, lay->file);
|
||||
if (!plat_file_exists(lay->file)) {
|
||||
plugins_gone++;
|
||||
for (const char *c = lay->file; *c; c++) plugins_gone_key = (plugins_gone_key ^ (uint8_t)*c) * 0x01000193u;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
uint8_t d[32];
|
||||
char hex[65];
|
||||
rt_sha256(p, len, d);
|
||||
free(p);
|
||||
hex32(d, hex);
|
||||
if (strcmp(hex, lay->sha256)) {
|
||||
rt_log("loader: %s: %s changed since the build lifted it; the plugin is left out", lay->name, lay->file);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t *ldr_read_verified(const char *dir, const char *file, size_t *len) {
|
||||
const char *want = NULL;
|
||||
for (int i = 0; i < rt_exefs_sha256_count; i++)
|
||||
@@ -81,14 +127,7 @@ uint8_t *ldr_read_verified(const char *dir, const char *file, size_t *len) {
|
||||
if (!want) rt_fatal("loader: no expected SHA-256 for %s in modules.c", file);
|
||||
char path[1024];
|
||||
snprintf(path, sizeof path, "%s/%s", dir, file);
|
||||
uint8_t *p = read_file(path, len);
|
||||
if (!p) rt_fatal("loader: cannot read %s (extract the game first: tools/extract.py)", path);
|
||||
uint8_t d[32];
|
||||
char hex[65];
|
||||
rt_sha256(p, *len, d);
|
||||
hex32(d, hex);
|
||||
if (strcmp(hex, want)) rt_fatal("loader: %s has SHA-256 %s, expected %s", path, hex, want);
|
||||
return p;
|
||||
return read_path_verified(path, want, len, "extract the game first: tools/extract.py");
|
||||
}
|
||||
|
||||
// ---- NSO
|
||||
@@ -141,6 +180,32 @@ static void nso_segment(const uint8_t *raw, const Seg *s, uint8_t *dst, const ch
|
||||
}
|
||||
}
|
||||
|
||||
// The plugin service run's stand-in for rtld (plugin_init.c): an ExeFS NSO's image, read and checked like a module but
|
||||
// neither relocated, linked nor sealed. Nothing runs it; exlaunch only reads it while it walks the address space.
|
||||
uint64_t ldr_nso_size(const char *dir, const char *file) {
|
||||
size_t len;
|
||||
uint8_t *raw = ldr_read_verified(dir, file, &len);
|
||||
Seg seg[3];
|
||||
uint64_t size = nso_segments(raw, len, file, seg);
|
||||
free(raw);
|
||||
return size;
|
||||
}
|
||||
|
||||
void ldr_map_image(const char *dir, const char *file, uint64_t base, uint64_t *text_end, uint64_t *data_off) {
|
||||
size_t len;
|
||||
uint8_t *raw = ldr_read_verified(dir, file, &len);
|
||||
Seg seg[3];
|
||||
uint64_t size = nso_segments(raw, len, file, seg);
|
||||
if (!plat_mem_commit(base, size)) rt_fatal("loader: cannot commit %s at %#llx", file, (unsigned long long)base);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if ((uint64_t)seg[i].mem_off + seg[i].size > size) rt_fatal("loader: %s segment %d exceeds the image", file, i);
|
||||
nso_segment(raw, &seg[i], (uint8_t *)(uintptr_t)(base + seg[i].mem_off), file, i);
|
||||
}
|
||||
free(raw);
|
||||
*text_end = seg[0].mem_off + seg[0].size;
|
||||
*data_off = seg[2].mem_off;
|
||||
}
|
||||
|
||||
// ---- symbols
|
||||
static const char *sym_name(const Mod *m, uint32_t i) { return m->strtab + m->syms[i].name; }
|
||||
static int sym_defined(const Mod *m, uint32_t i) { return m->syms[i].shndx != 0; }
|
||||
@@ -273,9 +338,12 @@ static uint64_t decode_ctor_flag(const Mod *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A plugin (lay->file set) comes from its mod folder, checked against the hash the build took when it lifted it.
|
||||
static void load_module(Mod *m, const char *dir, const RtLayoutEntry *lay) {
|
||||
size_t len;
|
||||
uint8_t *raw = ldr_read_verified(dir, lay->name, &len);
|
||||
uint8_t *raw = lay->file ? read_path_verified(lay->file, lay->sha256, &len, "the mod's code module the build "
|
||||
"lifted; rebuild after changing mods")
|
||||
: ldr_read_verified(dir, lay->name, &len);
|
||||
Seg seg[3];
|
||||
uint64_t size = nso_segments(raw, len, lay->name, seg);
|
||||
if (size != lay->size)
|
||||
@@ -291,6 +359,7 @@ static void load_module(Mod *m, const char *dir, const RtLayoutEntry *lay) {
|
||||
}
|
||||
free(raw);
|
||||
m->pub.name = lay->name;
|
||||
m->pub.plugin = lay->file != NULL;
|
||||
m->pub.base = lay->base;
|
||||
m->pub.size = size;
|
||||
m->pub.text_end = seg[0].mem_off + seg[0].size;
|
||||
@@ -328,7 +397,11 @@ static Res resolve(Mod *m, uint32_t si, int jump) {
|
||||
uint64_t guest = sym_defined(m, si) ? m->pub.base + m->syms[si].value : find_symbol(name, NULL);
|
||||
GuestFn f;
|
||||
Res r;
|
||||
if (jump && (f = hostfn_observer(name))) {
|
||||
if (jump && m->pub.plugin && ldr_plugin_import) { // the plugin service run counts the plugin's calls by name
|
||||
uint64_t to = (f = hostfn_override(name)) ? hostfn_register(name, f) : guest;
|
||||
if (!to) to = hostfn_register(name, unresolved_stub);
|
||||
r = (Res){hostfn_register_observer(name, ldr_plugin_import, to), RES_OBSERVER};
|
||||
} else if (jump && (f = hostfn_observer(name))) {
|
||||
r = (Res){hostfn_register_observer(name, f, guest), RES_OBSERVER};
|
||||
mark_used(1, name);
|
||||
} else if ((f = hostfn_override(name))) {
|
||||
@@ -444,9 +517,15 @@ static void seal(Mod *m) {
|
||||
void ldr_load(const char *exefs_dir) {
|
||||
if (nmods) rt_fatal("ldr_load called twice");
|
||||
if (!mem_layout()->pool) rt_fatal("ldr_load before mem_init");
|
||||
if (rt_layout_count > MOD_COUNT) rt_fatal("loader: %d modules in the layout", rt_layout_count);
|
||||
for (int i = 0; i < rt_layout_count; i++) load_module(&mods[i], exefs_dir, &rt_layout[i]);
|
||||
nmods = rt_layout_count;
|
||||
if (rt_layout_count > RT_MAX_MODULES) rt_fatal("loader: %d modules in the layout", rt_layout_count);
|
||||
int n = 0;
|
||||
for (int i = 0; i < rt_layout_count; i++) {
|
||||
// A mod plugin's file that is gone or changed since the build is left out at play time: its patch set cannot
|
||||
// run (plugin_init.c plugins_start keeps it off); the plugin service run needs it and stops.
|
||||
if (rt_layout[i].file && !rt_config()->plugin_init && !plugin_file_ok(&rt_layout[i])) continue;
|
||||
load_module(&mods[n++], exefs_dir, &rt_layout[i]);
|
||||
}
|
||||
nmods = n;
|
||||
ovr_used = calloc(hostfn_table_size(0) + 1, sizeof(int));
|
||||
obs_used = calloc(hostfn_table_size(1) + 1, sizeof(int));
|
||||
for (int i = 0; i < nmods; i++) {
|
||||
@@ -557,7 +636,7 @@ uint64_t ldr_plt_stub(const char *module, const char *name) {
|
||||
typedef struct {
|
||||
const char *name;
|
||||
uint64_t kinds[K_COUNT], total, sym_import, sym_own;
|
||||
uint32_t imports, to[MOD_COUNT], weak, init_off, init_array;
|
||||
uint32_t imports, to[RT_MAX_MODULES], weak, init_off, init_array;
|
||||
} Expect;
|
||||
static const Expect expect_121[] = {
|
||||
{"main", {508816, 1415, 32, 641}, 510904, 2088, 0, 675, {0, 16, 647}, 12, 0x30, 10673},
|
||||
|
||||
+6
-1
@@ -611,7 +611,7 @@ static int usage(const char *argv0) {
|
||||
"--probe-cfg | --probe-dpi | --probe-mods | --probe-playtime | --probe-kernel | --probe-ipc | --probe-services | --probe-fs | --probe-gfx-abi | "
|
||||
"--probe-nvn | --probe-nvn-tex | --probe-window | --probe-shader | --probe-vkmem | "
|
||||
"--probe-vkexec | --probe-astc | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-discord | "
|
||||
"--prepare-shaders | --warm-shaders | --boot |--seconds S [--shot PNG]]\n", argv0);
|
||||
"--prepare-shaders | --warm-shaders | --boot | --plugin-init DIR | --seconds S [--shot PNG]]\n", argv0);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -700,6 +700,10 @@ int main(int argc, char **argv) {
|
||||
} else if (!strcmp(argv[i], "--shot")) {
|
||||
if (++i == argc) return usage(argv[0]);
|
||||
cfg.shot = argv[i];
|
||||
} else if (!mode && !strcmp(argv[i], "--plugin-init")) { // the plugin service run (plugin_init.c)
|
||||
if (++i == argc) return usage(argv[0]);
|
||||
mode = argv[i - 1];
|
||||
cfg.plugin_init = argv[i];
|
||||
} else if (!mode && !strncmp(argv[i], "--", 2)) {
|
||||
mode = argv[i];
|
||||
} else {
|
||||
@@ -744,5 +748,6 @@ int main(int argc, char **argv) {
|
||||
if (!strcmp(mode, "--prepare-shaders")) return vk_pipeline_prepare_shaders();
|
||||
if (!strcmp(mode, "--warm-shaders")) return vk_pipeline_warm_shaders();
|
||||
if (!strcmp(mode, "--boot")) { cfg.boot = 1; rt_boot(); return 0; }
|
||||
if (!strcmp(mode, "--plugin-init")) { rt_boot_plugin_init(); return 0; }
|
||||
return usage(argv[0]);
|
||||
}
|
||||
+6
-2
@@ -57,7 +57,7 @@ static uint8_t *alias_pages; // 1 per mapped 4 KiB page of the alias regi
|
||||
typedef struct { uint64_t dst, src, size; } StackMap;
|
||||
static StackMap stack_maps[MAX_STACK_MAPS];
|
||||
static unsigned nstack_maps;
|
||||
static uint8_t *module_perm[MOD_COUNT]; // per data page of each module: perm | ATTR_PERMISSION_LOCKED
|
||||
static uint8_t *module_perm[RT_MAX_MODULES]; // per data page of each module: perm | ATTR_PERMISSION_LOCKED
|
||||
|
||||
static uint64_t align_up(uint64_t v, uint64_t a) { return (v + a - 1) & ~(a - 1); }
|
||||
|
||||
@@ -530,7 +530,7 @@ uint32_t mem_unmap_physical(uint64_t a, uint64_t n) { return alias_map(1, a, n);
|
||||
// as taken (Code, RX), so the SDK never picks it.
|
||||
static void taken_gap(uint64_t a, uint64_t *base, uint64_t *size) {
|
||||
uint64_t lo = 0, hi = RT_ADDRESS_LIMIT;
|
||||
RtRange known[3 + MOD_COUNT + 2];
|
||||
RtRange known[3 + RT_MAX_MODULES + 2];
|
||||
int n = 0;
|
||||
known[n++] = (RtRange){L.aslr.base, low_size};
|
||||
known[n++] = L.alias;
|
||||
@@ -562,6 +562,9 @@ static uint64_t run_start(const uint8_t *p, uint64_t i, uint8_t v) { // first
|
||||
return i;
|
||||
}
|
||||
|
||||
// The plugin service run (plugin_init.c) shows rtld, its process-memory aliases and its free pool here.
|
||||
void (*mem_query_hook)(uint64_t a, RtMemoryInfo *r);
|
||||
|
||||
uint32_t mem_query(uint64_t a, RtMemoryInfo *out) {
|
||||
RtMemoryInfo r = {.base = a & ~(PAGE - 1), .size = PAGE};
|
||||
uint64_t low = L.aslr.base;
|
||||
@@ -632,6 +635,7 @@ uint32_t mem_query(uint64_t a, RtMemoryInfo *out) {
|
||||
r.size = hi - lo;
|
||||
}
|
||||
plat_mutex_unlock_shared(&lock);
|
||||
if (mem_query_hook) mem_query_hook(a, &r);
|
||||
if (out) *out = r;
|
||||
return R_OK;
|
||||
}
|
||||
|
||||
@@ -499,3 +499,103 @@ int menu_cursor_shortcut(void) {
|
||||
if (f.screen) layout_name(f.screen, nm, sizeof nm);
|
||||
return f.screen && (!strcmp(nm, "ShortCutMainItem_00") || !strcmp(nm, "ShortCut_00"));
|
||||
}
|
||||
|
||||
// ---- The game's menus for quicksave.c, on the game thread: the same reads and focus writes as above, by name
|
||||
static void main_range(void) {
|
||||
if (!main_lo) main_lo = MOD_MAIN_BASE, main_hi = MOD_MAIN_BASE + MAIN_SIZE;
|
||||
}
|
||||
// nn::ui2d::Pane: its name (+0xb0, 24 characters) and its children, an intrusive list whose links (+0x8 in each
|
||||
// child) start at +0x20
|
||||
enum { PANE_CHILDREN = 0x20, PANE_LINK = 0x8, PANE_NAME = 0xb0, PANE_NAME_MAX = 24 };
|
||||
static int pane_named(uint64_t pane, const char *name) {
|
||||
if (!ok_at(pane, PANE_NAME + PANE_NAME_MAX)) return 0;
|
||||
char nm[PANE_NAME_MAX + 1];
|
||||
memcpy(nm, (const void *)(uintptr_t)(pane + PANE_NAME), PANE_NAME_MAX);
|
||||
nm[PANE_NAME_MAX] = 0;
|
||||
return !strcmp(nm, name);
|
||||
}
|
||||
// The pane called name in the tree under pane, depth first, 0: none
|
||||
static uint64_t pane_find(uint64_t pane, const char *name, int depth) {
|
||||
if (pane_named(pane, name)) return pane;
|
||||
if (depth >= 6 || !ok_at(pane, PANE_NAME + PANE_NAME_MAX)) return 0;
|
||||
uint64_t head = pane + PANE_CHILDREN;
|
||||
int n = 0;
|
||||
for (uint64_t link = rd64(head); link != head && n < 64; link = rd64(link), n++) {
|
||||
if (!ok_at(link, 16)) return 0;
|
||||
uint64_t child = link - PANE_LINK;
|
||||
if (!ok_at(child, PANE_NAME + PANE_NAME_MAX) || rd64(child + PANE_PARENT) != pane) return 0;
|
||||
uint64_t hit = pane_find(child, name, depth + 1);
|
||||
if (hit) return hit;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_ui_open(const char *layout) {
|
||||
main_range();
|
||||
uint64_t sm = screen_mgr();
|
||||
if (!sm) return 0;
|
||||
int32_t n = (int32_t)rd32(sm + SM_COUNT);
|
||||
uint64_t arr = rd64(sm + SM_SCREENS);
|
||||
if (n <= 0 || n > 1024 || !ok_at(arr, 8ull * (uint64_t)n)) return 0;
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
uint64_t scr = rd64(arr + 8ull * (uint64_t)i);
|
||||
if (!game_object(scr, SCR_REQUEST + 1) || rd8(scr + SCR_STATE) != SCR_OPENED) continue;
|
||||
char nm[48];
|
||||
layout_name(scr, nm, sizeof nm);
|
||||
if (!strcmp(nm, layout)) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_ui_focus(char *screen, size_t n, uint64_t *node) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
screen[0] = 0, *node = f.node;
|
||||
if (f.screen) layout_name(f.screen, screen, n);
|
||||
return f.screen != 0;
|
||||
}
|
||||
|
||||
uint64_t menu_ui_button(const char *parts, const char *root, int *usable_out) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
if (!f.screen) return 0;
|
||||
static uint64_t node[MAX_NODES], btn[MAX_NODES];
|
||||
int n = nodes_of(f.screen, node, btn);
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint64_t pane = root_pane(btn[i]);
|
||||
char nm[48];
|
||||
layout_name(btn[i] - SCR_LAYOUT + BTN_LAYOUT, nm, sizeof nm); // the button's parts layout
|
||||
if (strcmp(nm, parts) || !pane_named(pane, root) || !pane_shown(pane)) continue;
|
||||
if (usable_out) *usable_out = usable(btn[i]);
|
||||
return node[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SystemLoadList_00 lists the saves as PaDataFileBtn_00 entries, newest first; an entry without a save fades
|
||||
// N_Disable_00 out (and is not shown when the list is shorter). The first entry that holds a save, 0 none.
|
||||
uint64_t menu_ui_first_save(void) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
if (!f.screen) return 0;
|
||||
static uint64_t node[MAX_NODES], btn[MAX_NODES];
|
||||
int n = nodes_of(f.screen, node, btn);
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint64_t pane = root_pane(btn[i]);
|
||||
char nm[48];
|
||||
layout_name(btn[i] - SCR_LAYOUT + BTN_LAYOUT, nm, sizeof nm);
|
||||
if (strcmp(nm, "PaDataFileBtn_00") || !usable(btn[i]) || !pane_shown(pane)) continue;
|
||||
uint64_t filled = pane_find(pane, "N_Disable_00", 0);
|
||||
if (filled && rd8(filled + PANE_ALPHA) >= 128) return node[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_ui_focus_to(uint64_t node) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
if (!f.screen || !node) return 0;
|
||||
if (f.node == node) return 1;
|
||||
move_focus(&f, node);
|
||||
return 0;
|
||||
}
|
||||
+359
-34
@@ -9,7 +9,14 @@
|
||||
// The order and the switches are totk.ini keys (cfg.c): TOTK_MODS_ORDER lists names top first, separated by '|' (a
|
||||
// Windows file name cannot hold '|'; a folder whose name does on Linux is listed as unusable); a folder it does not name
|
||||
// goes below the named ones, by name. TOTK_MODS_DISABLED lists the switched-off names. The menu changes the list in
|
||||
// place and writes both keys; the scan's state is kept to tell the menu a restart is due.
|
||||
// place and writes both keys; the scan's state is kept to tell the menu a restart is due. TOTK_MODS_NO_CODE lists the
|
||||
// mods used without their code part (their switch "use without its code"; TOTK_MODS_WITHOUT_CODE = 1 is that switch on
|
||||
// for every mod).
|
||||
//
|
||||
// The order decides every conflict, top mod winning: romfs.c serves the top mod's file, mods_exefs_apply stores the
|
||||
// top mod's data bytes last and ranks each mod's patch sets by its position (rt_patch_rank), so at a code site several
|
||||
// mods patch the top one's code runs (patches.c rt_patch_picks). What a mod won or lost goes into one conflict table
|
||||
// (mods_conflict), which the menu and the log read.
|
||||
//
|
||||
// ExeFS patch files: an .ips or .pchtxt file in the exefs folder or in atmosphere/exefs_patches/<name>/ is for the game
|
||||
// when its build id is main's (an IPS file's name, a pchtxt file's @nsobid line); others are another version's and
|
||||
@@ -18,6 +25,15 @@
|
||||
// rebuild at start (cheats.c), and its mod stays off until then. A file's writes into main's data (.rodata, .data,
|
||||
// .bss) are lines of build-cache/exefs.data, stored into the loaded main before the game runs (mods_exefs_data), as
|
||||
// emulators apply a patch file to the module before its dynamic linker runs.
|
||||
//
|
||||
// Code modules: an exefs/subsdk* file is a plugin that patches main from its own start-up on the Switch (exlaunch).
|
||||
// The setup builds it in (tools/exefs_plugins.py, after the design in #845 by itaskaev2) and writes its line into
|
||||
// build-cache/plugins.status (the format of exefs.status): `plugin`, its patch set mod_<hash> holds its hook sites and
|
||||
// its init runs at every start (plugin_init.c); `unsupported`, the note says why the build refused it. A plugin without
|
||||
// a line waits for the rebuild like an ExeFS patch file; one whose start differed from the build is listed in
|
||||
// build-cache/plugins.stale (mods_plugin_off) and waits for it too. A replaced exefs/main is another game code the port
|
||||
// cannot load. A code module the port cannot run (ModInfo.code names them) keeps its mod off unless it is used without
|
||||
// its code, which also leaves out the ExeFS patch files the port cannot apply.
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -36,7 +52,10 @@ static ModInfo *mods;
|
||||
static int nmods;
|
||||
static char dir[2048];
|
||||
static char start_order[MAX_MODS][256]; // names in the scan's order and their switches, for mods_changed
|
||||
static int start_enabled[MAX_MODS];
|
||||
static int start_enabled[MAX_MODS], start_no_code[MAX_MODS];
|
||||
#define MAX_CONFLICTS 1024
|
||||
static ModConflict conflicts[MAX_CONFLICTS];
|
||||
static int nconflicts;
|
||||
|
||||
// 1 when a file lies anywhere under path.
|
||||
static int has_file_cb(const char *name, int kind, uint64_t size, void *ctx);
|
||||
@@ -72,14 +91,29 @@ static int ends_with_ci(const char *s, const char *tail) {
|
||||
return n >= t && !strcasecmp(s + n - t, tail);
|
||||
}
|
||||
|
||||
// A code module of m the port cannot run, named in m->code.
|
||||
static void code_unrun(ModInfo *m, const char *name) {
|
||||
size_t k = strlen(m->code);
|
||||
snprintf(m->code + k, sizeof m->code - k, "%s%s", k ? ", " : "", name);
|
||||
}
|
||||
|
||||
static void plugin_file(ModInfo *m, const char *leaf);
|
||||
|
||||
// What the ExeFS folder holds: MOD_EXEFS for patches (.ips, .pchtxt), MOD_SUBSDK for code modules (subsdk* plugins, a
|
||||
// replaced main). main.npdm alone is the process's metadata, not code: it counts as neither.
|
||||
static int exefs_cb(const char *name, int kind, uint64_t size, void *ctx) {
|
||||
(void)size;
|
||||
int *k = ctx;
|
||||
ModInfo *m = ctx;
|
||||
if (kind != PLAT_FS_FILE) return 1;
|
||||
if (ends_with_ci(name, ".ips") || ends_with_ci(name, ".pchtxt")) *k |= MOD_EXEFS;
|
||||
else if (!strncasecmp(name, "subsdk", 6) || !strcasecmp(name, "main")) *k |= MOD_SUBSDK;
|
||||
if (ends_with_ci(name, ".ips") || ends_with_ci(name, ".pchtxt")) {
|
||||
m->kind |= MOD_EXEFS;
|
||||
} else if (!strncasecmp(name, "subsdk", 6)) {
|
||||
m->kind |= MOD_SUBSDK;
|
||||
plugin_file(m, name);
|
||||
} else if (!strcasecmp(name, "main")) {
|
||||
m->kind |= MOD_SUBSDK;
|
||||
code_unrun(m, name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -127,9 +161,13 @@ static int by_order(const void *a, const void *b) {
|
||||
static const char *problem_name(ModProblem p) {
|
||||
switch (p) {
|
||||
case MOD_EMPTY: return "empty";
|
||||
case MOD_PLUGIN: return "has a code module (subsdk or main), not supported; the whole mod stays off";
|
||||
case MOD_PLUGIN:
|
||||
return "has a code module (subsdk or main), not supported; the whole mod stays off (its switch \"use without "
|
||||
"its code\" uses the rest of it)";
|
||||
case MOD_EXEFS_LATER: return "ExeFS patches wait for a rebuild of the game code; the whole mod stays off";
|
||||
case MOD_EXEFS_UNSUPPORTED: return "an ExeFS patch file cannot be applied; the whole mod stays off";
|
||||
case MOD_EXEFS_UNSUPPORTED:
|
||||
return "an ExeFS patch file cannot be applied; the whole mod stays off (its switch \"use without its code\" "
|
||||
"uses the rest of it)";
|
||||
case MOD_EXEFS_OTHER: return "its ExeFS patches are for another game version";
|
||||
case MOD_BAD_NAME: return "its folder name holds '|', which the order list uses; rename the folder";
|
||||
default: return "ok";
|
||||
@@ -174,6 +212,7 @@ static int same_build(const char *hex, size_t n) {
|
||||
|
||||
// build-cache/<name> next to totk.exe, read once into *text; "" when there is none (mods_probe_cache sets the text).
|
||||
static char *status_text, *data_text;
|
||||
static int no_stale_file; // --probe-mods: plugins.stale stays in memory
|
||||
static const char *build_cache(const char *name, char **text) {
|
||||
if (*text) return *text;
|
||||
char path[2100];
|
||||
@@ -189,14 +228,17 @@ static const char *build_cache(const char *name, char **text) {
|
||||
return *text;
|
||||
}
|
||||
|
||||
static char *plugin_status_text, *plugin_stale_text;
|
||||
static const char *exefs_status(void) { return build_cache("exefs.status", &status_text); }
|
||||
static const char *exefs_data(void) { return build_cache("exefs.data", &data_text); }
|
||||
static const char *plugin_status(void) { return build_cache("plugins.status", &plugin_status_text); }
|
||||
static const char *plugin_stale(void) { return build_cache("plugins.stale", &plugin_stale_text); }
|
||||
|
||||
// The status line of key: its kind, built-in sets and note, NUL-terminated copies; 0 when none.
|
||||
static int status_line(const char *key, const char *content, char *kind, char *over, char *note) {
|
||||
// The line of key in a status text: its kind, built-in sets and note, NUL-terminated copies; 0 when none.
|
||||
static int status_in(const char *text, const char *key, const char *content, char *kind, char *over, char *note) {
|
||||
char want[20];
|
||||
snprintf(want, sizeof want, "%s\t%s\t", key, content);
|
||||
for (const char *line = exefs_status(); *line;) {
|
||||
for (const char *line = text; *line;) {
|
||||
const char *end = strchr(line, '\n');
|
||||
size_t len = end ? (size_t)(end - line) : strlen(line);
|
||||
if (len > 18 && !memcmp(line, want, 18)) {
|
||||
@@ -218,6 +260,69 @@ static int status_line(const char *key, const char *content, char *kind, char *o
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int status_line(const char *key, const char *content, char *kind, char *over, char *note) {
|
||||
return status_in(exefs_status(), key, content, kind, over, note);
|
||||
}
|
||||
|
||||
// The reason plugins.stale gives for key and content, or NULL.
|
||||
static const char *stale_reason(const char *key, const char *content, char *out, size_t cap) {
|
||||
char want[20];
|
||||
snprintf(want, sizeof want, "%s\t%s\t", key, content);
|
||||
for (const char *line = plugin_stale(); *line;) {
|
||||
const char *end = strchr(line, '\n');
|
||||
size_t len = end ? (size_t)(end - line) : strlen(line);
|
||||
if (len > 18 && !memcmp(line, want, 18)) {
|
||||
size_t n = len - 18;
|
||||
if (n && line[len - 1] == '\r') n--;
|
||||
snprintf(out, cap, "%.*s", (int)(n < cap ? n : cap - 1), line + 18);
|
||||
return out;
|
||||
}
|
||||
line = end ? end + 1 : line + len;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// One exefs/subsdk* file of m: a built plugin joins its patch sets, a refused one is code it cannot run, one the build
|
||||
// lacks (or whose start differed from the build) waits for the rebuild.
|
||||
static void plugin_file(ModInfo *m, const char *leaf) {
|
||||
char path[4300], rel[600];
|
||||
snprintf(path, sizeof path, "%s/%s", m->exefs, leaf);
|
||||
size_t root = strlen(dir) + 1 + strlen(m->name) + 1; // m->exefs is <dir>/<mod>/<exefs place>
|
||||
snprintf(rel, sizeof rel, "%s/%s/%s", m->name, strlen(m->exefs) > root ? m->exefs + root : "exefs", leaf);
|
||||
uint64_t n = 0;
|
||||
char *data = (char *)plat_file_read(path, &n);
|
||||
if (!data) {
|
||||
rt_log("mods: %s: cannot read %s", m->name, path);
|
||||
code_unrun(m, leaf);
|
||||
return;
|
||||
}
|
||||
char key[9], content[9], kind[16], over[256], note[256], stale[256];
|
||||
snprintf(key, sizeof key, "%08X", fnv(rel, strlen(rel)));
|
||||
snprintf(content, sizeof content, "%08X", fnv(data, (size_t)n));
|
||||
free(data);
|
||||
if (!status_in(plugin_status(), key, content, kind, over, note) || stale_reason(key, content, stale, sizeof stale)) {
|
||||
m->pending++;
|
||||
m->pending_key = (m->pending_key ^ fnv(key, 8)) * 0x01000193u;
|
||||
m->pending_key = (m->pending_key ^ fnv(content, 8)) * 0x01000193u;
|
||||
return;
|
||||
}
|
||||
if (!strcmp(kind, "plugin") && m->nsets < (int)(sizeof m->sets / sizeof *m->sets) &&
|
||||
m->nplugins < (int)(sizeof m->plugin_keys / sizeof *m->plugin_keys)) {
|
||||
uint32_t k = (uint32_t)strtoul(key, NULL, 16);
|
||||
m->sets[m->nsets++] = k;
|
||||
m->plugin_keys[m->nplugins] = k;
|
||||
m->plugin_contents[m->nplugins++] = (uint32_t)strtoul(content, NULL, 16);
|
||||
const char *hooks = strstr(note, ", ");
|
||||
m->plugin_hooks += hooks ? atoi(hooks + 2) : 0;
|
||||
size_t at = strlen(m->overrides);
|
||||
if (*over) snprintf(m->overrides + at, sizeof m->overrides - at, "%s%s", at ? "," : "", over);
|
||||
} else {
|
||||
code_unrun(m, leaf);
|
||||
if (!m->plugin_note[0]) snprintf(m->plugin_note, sizeof m->plugin_note, "%s", note);
|
||||
}
|
||||
if (!m->plugin_file[0]) snprintf(m->plugin_file, sizeof m->plugin_file, "%s", leaf);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ModInfo *m;
|
||||
const char *folder, *rel; // the folder listed and its path in the mod
|
||||
@@ -270,7 +375,8 @@ static int exefs_file_cb(const char *leaf, int kind, uint64_t size, void *ctx) {
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp(kind_s, "unsupported")) {
|
||||
if (!w->unsupported) snprintf(m->note, sizeof m->note, "%s: %s", leaf, note);
|
||||
if (!m->unsupported) snprintf(m->note, sizeof m->note, "%s: %s", leaf, note);
|
||||
m->unsupported++;
|
||||
w->unsupported = 1;
|
||||
} else if (!strcmp(kind_s, "code") && m->nsets < (int)(sizeof m->sets / sizeof *m->sets)) {
|
||||
m->sets[m->nsets++] = (uint32_t)strtoul(key, NULL, 16);
|
||||
@@ -323,6 +429,7 @@ static int scan_cb(const char *name, int kind, uint64_t size, void *ctx) {
|
||||
}
|
||||
ModInfo *m = &mods[nmods];
|
||||
memset(m, 0, sizeof *m);
|
||||
m->id = nmods;
|
||||
char path[2100];
|
||||
if (snprintf(m->name, sizeof m->name, "%s", name) >= (int)sizeof m->name ||
|
||||
snprintf(path, sizeof path, "%s/%s", dir, name) >= (int)sizeof path) {
|
||||
@@ -334,17 +441,24 @@ static int scan_cb(const char *name, int kind, uint64_t size, void *ctx) {
|
||||
find_root(path, "exefs", m->exefs, sizeof m->exefs);
|
||||
find_root(path, "cheats", m->cheats, sizeof m->cheats);
|
||||
if (m->romfs[0] && has_file(m->romfs)) m->kind |= MOD_ROMFS;
|
||||
if (m->exefs[0]) plat_fs_list(m->exefs, exefs_cb, &m->kind);
|
||||
if (m->exefs[0]) plat_fs_list(m->exefs, exefs_cb, m);
|
||||
if (m->cheats[0]) plat_fs_list(m->cheats, cheats_cb, &m->kind);
|
||||
int unsupported = exefs_check(m, path);
|
||||
// a mod whose code part the port cannot use is off as a whole: its RomFS files may expect that code
|
||||
m->problem = strchr(m->name, '|') ? MOD_BAD_NAME
|
||||
: m->kind & MOD_SUBSDK ? MOD_PLUGIN
|
||||
: unsupported ? MOD_EXEFS_UNSUPPORTED
|
||||
: m->pending ? MOD_EXEFS_LATER
|
||||
: m->nsets || m->ndata || m->kind & (MOD_ROMFS | MOD_CHEATS) ? MOD_OK
|
||||
: m->kind & MOD_EXEFS ? MOD_EXEFS_OTHER
|
||||
: MOD_EMPTY;
|
||||
// A mod whose code part the port cannot use is off as a whole: its RomFS files may expect that code. Used without
|
||||
// its code (its switch, or mods_without_code = 1 for every mod), the code modules (m->code) and the ExeFS patch
|
||||
// files the port cannot apply are left out and the rest of the mod is used, when it has a rest. Each plugin of a
|
||||
// mod is built or refused on its own (tools/exefs_plugins.py), so a built plugin is such a rest too.
|
||||
m->no_code = listed(cfg_get("TOTK_MODS_NO_CODE"), m->name);
|
||||
m->without_code = m->no_code || cfg_bool("TOTK_MODS_WITHOUT_CODE");
|
||||
int usable = m->nsets || m->ndata || m->kind & (MOD_ROMFS | MOD_CHEATS);
|
||||
int code_off = m->code[0] && (!m->without_code || !(m->kind & (MOD_ROMFS | MOD_EXEFS | MOD_CHEATS) || m->nplugins));
|
||||
m->problem = strchr(m->name, '|') ? MOD_BAD_NAME
|
||||
: code_off ? MOD_PLUGIN
|
||||
: unsupported && (!m->without_code || !usable) ? MOD_EXEFS_UNSUPPORTED
|
||||
: m->pending ? MOD_EXEFS_LATER
|
||||
: usable ? MOD_OK
|
||||
: m->kind & MOD_EXEFS ? MOD_EXEFS_OTHER
|
||||
: MOD_EMPTY;
|
||||
m->enabled = !listed(disabled, m->name);
|
||||
nmods++;
|
||||
return 1;
|
||||
@@ -407,11 +521,18 @@ void mods_scan(void) {
|
||||
for (int i = 0; i < nmods; i++) {
|
||||
snprintf(start_order[i], sizeof start_order[i], "%s", mods[i].name);
|
||||
start_enabled[i] = mods[i].enabled;
|
||||
start_no_code[i] = mods[i].no_code;
|
||||
const ModInfo *m = &mods[i];
|
||||
rt_log("mods: %s: %s,%s%s%s%s%s, %s%s%s", m->name, m->enabled ? "on" : "off", m->kind & MOD_ROMFS ? " romfs" : "",
|
||||
m->kind & MOD_EXEFS ? " exefs" : "", m->kind & MOD_SUBSDK ? " subsdk" : "",
|
||||
m->kind & MOD_CHEATS ? " cheats" : "", m->kind ? "" : " no files", problem_name(m->problem),
|
||||
m->note[0] ? ": " : "", m->note);
|
||||
if (m->code[0] && m->problem != MOD_PLUGIN)
|
||||
rt_log("mods: %s: used without its code: its code module (%s) does not load; the rest of the mod is used",
|
||||
m->name, m->code);
|
||||
if (m->unsupported && m->problem != MOD_EXEFS_UNSUPPORTED)
|
||||
rt_log("mods: %s: used without its code: %u ExeFS patch files the port cannot apply are left out (%s); the "
|
||||
"rest of the mod is used", m->name, m->unsupported, m->note);
|
||||
}
|
||||
rt_log("mods: %d folders in %s", nmods, dir);
|
||||
}
|
||||
@@ -549,38 +670,176 @@ void mods_probe_cache(const char *status, const char *data) {
|
||||
data_text = dup_text(data);
|
||||
}
|
||||
|
||||
void mods_probe_plugins(const char *status, const char *stale) {
|
||||
free(plugin_status_text);
|
||||
free(plugin_stale_text);
|
||||
plugin_status_text = dup_text(status);
|
||||
plugin_stale_text = dup_text(stale);
|
||||
no_stale_file = status != NULL;
|
||||
}
|
||||
|
||||
void mods_rescan(void) {
|
||||
free(mods);
|
||||
mods = NULL;
|
||||
nmods = 0;
|
||||
nconflicts = 0;
|
||||
scanned = 0;
|
||||
}
|
||||
|
||||
// Switches the patch set mod_<key> on; 0 when this build lacks it (logged).
|
||||
static int set_on(const ModInfo *m, uint32_t key) {
|
||||
// ---- the conflict table
|
||||
|
||||
void mods_conflict(int winner, int loser, ModPart part, uint32_t count) {
|
||||
for (int i = 0; i < nconflicts; i++) {
|
||||
ModConflict *c = &conflicts[i];
|
||||
if (c->winner == winner && c->loser == loser && c->part == part) {
|
||||
c->count += count;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (nconflicts == MAX_CONFLICTS) return; // a mod list with more pairs than that: the rest goes unshown
|
||||
conflicts[nconflicts++] = (ModConflict){winner, loser, part, count};
|
||||
}
|
||||
|
||||
int mods_conflict_count(void) { return nconflicts; }
|
||||
const ModConflict *mods_conflict_at(int i) { return i >= 0 && i < nconflicts ? &conflicts[i] : NULL; }
|
||||
|
||||
const ModInfo *mods_by_id(int id) {
|
||||
for (int i = 0; i < nmods; i++)
|
||||
if (mods[i].id == id) return &mods[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void mods_conflicts_log(ModPart part) {
|
||||
static const char *const unit[MOD_PARTS] = {"files", "bytes of main's data", "code sites"};
|
||||
for (int i = 0; i < nconflicts; i++) {
|
||||
const ModConflict *c = &conflicts[i];
|
||||
const ModInfo *w = mods_by_id(c->winner), *l = mods_by_id(c->loser);
|
||||
if (c->part != part || !w || !l) continue;
|
||||
rt_log("mods: %s: overrides %s at %u %s", w->name, l->name, c->count, unit[part]);
|
||||
rt_log("mods: %s: %u %s overridden by %s", l->name, c->count, unit[part], w->name);
|
||||
}
|
||||
}
|
||||
|
||||
// Switches the patch set mod_<key> on and gives it rank; -1 when this build lacks it (logged).
|
||||
static int set_on(const ModInfo *m, uint32_t key, int rank) {
|
||||
char name[32];
|
||||
snprintf(name, sizeof name, "mod_%08x", key);
|
||||
int set = rt_patch_set(name);
|
||||
if (set >= 0) rt_patch_switch(set, 1);
|
||||
else rt_log("mods: %s: patch set %s is not in this build", m->name, name);
|
||||
return set >= 0;
|
||||
if (set >= 0) {
|
||||
rt_patch_rank(set, rank);
|
||||
rt_patch_switch(set, 1);
|
||||
} else {
|
||||
rt_log("mods: %s: patch set %s is not in this build", m->name, name);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
// The mod in use whose ExeFS patch file has the patch set, NULL for a set of no mod.
|
||||
static const ModInfo *set_owner(int set) {
|
||||
const char *name = rt_patch_name(set);
|
||||
if (!name || strncmp(name, "mod_", 4)) return NULL;
|
||||
uint32_t key = (uint32_t)strtoul(name + 4, NULL, 16);
|
||||
for (int i = 0; i < nmods; i++)
|
||||
for (int k = 0; start_enabled[i] && mods[i].problem == MOD_OK && k < mods[i].nsets; k++)
|
||||
if (mods[i].sets[k] == key) return &mods[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// The contested code sites (patches.c): which mod's code runs at each, logged, and one site per losing mod in the
|
||||
// conflict table. Two files of one mod on one site are no conflict: the later file in the mod runs (the tie rule of
|
||||
// rt_patch_picks, as emulators apply a mod's files in name order, each over the one before).
|
||||
static void code_conflicts(void) {
|
||||
int logged = 0, contested = 0;
|
||||
for (int i = 0; i < rt_patch_pick_count(); i++) {
|
||||
const RtPatchPick *p = rt_patch_pick_at(i);
|
||||
int w = rt_patch_pick_winner(i);
|
||||
const ModInfo *wm = w >= 0 ? set_owner(p->sets[w]) : NULL;
|
||||
if (!wm) continue;
|
||||
char lost[512] = "";
|
||||
const ModInfo *seen[16];
|
||||
int nseen = 0;
|
||||
for (int j = 0; j < p->nsets; j++) {
|
||||
const ModInfo *lm = j != w && rt_patch_enabled(p->sets[j]) ? set_owner(p->sets[j]) : NULL;
|
||||
int dup = !lm || lm == wm;
|
||||
for (int k = 0; !dup && k < nseen; k++) dup = seen[k] == lm;
|
||||
if (dup) continue;
|
||||
if (nseen < 16) seen[nseen++] = lm;
|
||||
mods_conflict(wm->id, lm->id, MOD_PART_CODE, 1);
|
||||
size_t at = strlen(lost);
|
||||
snprintf(lost + at, sizeof lost - at, "%s%s", at ? ", " : "", lm->name);
|
||||
}
|
||||
if (!*lost) continue;
|
||||
contested++;
|
||||
if (logged++ < 32)
|
||||
rt_log("mods: code site %s+%#x: %s's patch runs; %s's stays off (higher in the list wins)", p->module,
|
||||
p->offset, wm->name, lost);
|
||||
}
|
||||
if (logged > 32) rt_log("mods: %d more contested code sites", logged - 32);
|
||||
if (contested) mods_conflicts_log(MOD_PART_CODE);
|
||||
}
|
||||
|
||||
// The data bytes stored at start, by mod: the overlaps are data conflicts.
|
||||
typedef struct { uint64_t addr; int n, id, pos; } DataSpan;
|
||||
static DataSpan *spans;
|
||||
static int nspans, cap_spans, span_id, span_pos;
|
||||
static int (*span_store)(uint64_t addr, const uint8_t *bytes, int n);
|
||||
|
||||
static int record_store(uint64_t addr, const uint8_t *bytes, int n) {
|
||||
if (!(span_store ? span_store : store_main)(addr, bytes, n)) return 0;
|
||||
if (nspans == cap_spans) {
|
||||
int cap = cap_spans ? 2 * cap_spans : 256;
|
||||
DataSpan *grown = realloc(spans, (size_t)cap * sizeof *spans);
|
||||
if (!grown) return 1; // stored; only its conflict goes unseen
|
||||
spans = grown, cap_spans = cap;
|
||||
}
|
||||
spans[nspans++] = (DataSpan){addr, n, span_id, span_pos};
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int by_addr(const void *a, const void *b) {
|
||||
uint64_t x = ((const DataSpan *)a)->addr, y = ((const DataSpan *)b)->addr;
|
||||
return (x > y) - (x < y);
|
||||
}
|
||||
|
||||
// Bytes two mods both wrote: the higher one's stayed (mods_exefs_apply stores bottom first).
|
||||
static void data_conflicts(void) {
|
||||
qsort(spans, (size_t)nspans, sizeof *spans, by_addr);
|
||||
int any = 0;
|
||||
for (int i = 0; i < nspans; i++) {
|
||||
uint64_t end = spans[i].addr + (uint64_t)spans[i].n;
|
||||
for (int j = i + 1; j < nspans && spans[j].addr < end; j++) {
|
||||
if (spans[j].id == spans[i].id) continue;
|
||||
uint64_t jend = spans[j].addr + (uint64_t)spans[j].n;
|
||||
uint32_t n = (uint32_t)((jend < end ? jend : end) - spans[j].addr);
|
||||
const DataSpan *hi = spans[i].pos < spans[j].pos ? &spans[i] : &spans[j];
|
||||
mods_conflict(hi->id, hi == &spans[i] ? spans[j].id : spans[i].id, MOD_PART_DATA, n);
|
||||
any = 1;
|
||||
}
|
||||
}
|
||||
free(spans);
|
||||
spans = NULL;
|
||||
nspans = cap_spans = 0;
|
||||
if (any) mods_conflicts_log(MOD_PART_DATA);
|
||||
}
|
||||
|
||||
void mods_exefs_apply(uint64_t base, uint64_t size, uint64_t code_end,
|
||||
int (*store)(uint64_t addr, const uint8_t *bytes, int n)) {
|
||||
// bottom first: the top mod's data writes land last and win, as its RomFS files do. Patch sets are only switches
|
||||
// (rt_patch_switch), so their order does not matter.
|
||||
// bottom first: the top mod's data writes land last and win, as its RomFS files do. Patch sets are switches
|
||||
// (rt_patch_switch); the mod's position ranks them, so where two mods patch one code site the higher one's runs
|
||||
// (rt_patch_picks after the loop).
|
||||
span_store = store;
|
||||
for (int i = nmods - 1; i >= 0; i--) {
|
||||
const ModInfo *m = &mods[i];
|
||||
if (!start_enabled[i] || m->problem != MOD_OK || !(m->nsets || m->ndata)) continue;
|
||||
// the data first: a mod whose data writes cannot all be stored keeps its code patches off too, as half of a
|
||||
// patch file is worse than none
|
||||
long stored = size ? mods_exefs_data(m, base, size, code_end, store) : 0;
|
||||
span_id = m->id, span_pos = i;
|
||||
long stored = size ? mods_exefs_data(m, base, size, code_end, record_store) : 0;
|
||||
if (stored < 0) {
|
||||
rt_log("mods: %s: its ExeFS patch files stay off: their data writes could not all be stored", m->name);
|
||||
continue;
|
||||
}
|
||||
for (int k = 0; k < m->nsets; k++) set_on(m, m->sets[k]);
|
||||
for (int k = 0; k < m->nsets; k++) set_on(m, m->sets[k], i);
|
||||
char over[256];
|
||||
snprintf(over, sizeof over, "%s", m->overrides);
|
||||
for (char *s = strtok(over, ","); s; s = strtok(NULL, ",")) {
|
||||
@@ -591,6 +850,57 @@ void mods_exefs_apply(uint64_t base, uint64_t size, uint64_t code_end,
|
||||
rt_log("mods: %s: %d ExeFS patch files on, %ld bytes of main's data stored", m->name, m->nsets + m->ndata,
|
||||
stored);
|
||||
}
|
||||
span_store = NULL;
|
||||
data_conflicts();
|
||||
rt_patch_picks();
|
||||
code_conflicts();
|
||||
}
|
||||
|
||||
// build-cache/plugins.stale next to totk.exe: one more line (--probe-mods keeps it in memory).
|
||||
static void stale_append(const char *line) {
|
||||
size_t had = plugin_stale_text ? strlen(plugin_stale_text) : 0, n = strlen(line);
|
||||
char *grown = realloc(plugin_stale_text, had + n + 1);
|
||||
if (grown) {
|
||||
if (!plugin_stale_text) grown[0] = 0;
|
||||
memcpy(grown + had, line, n + 1);
|
||||
plugin_stale_text = grown;
|
||||
}
|
||||
char path[2100];
|
||||
if (no_stale_file || !plat_exe_path(path, sizeof path)) return;
|
||||
char *cut = strrchr(path, '/'), *back = strrchr(path, '\\');
|
||||
if (back > cut) cut = back;
|
||||
if (!cut || snprintf(cut + 1, sizeof path - (size_t)(cut + 1 - path), "build-cache/plugins.stale") >=
|
||||
(int)(sizeof path - (size_t)(cut + 1 - path)))
|
||||
return;
|
||||
FILE *f = fopen(path, "ab");
|
||||
if (!f) {
|
||||
rt_log("mods: cannot write %s", path);
|
||||
return;
|
||||
}
|
||||
fputs(line, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void mods_plugin_off(int set, const char *why) {
|
||||
const ModInfo *owner = set_owner(set);
|
||||
rt_patch_switch(set, 0);
|
||||
if (!owner) return;
|
||||
ModInfo *m = (ModInfo *)owner;
|
||||
snprintf(m->plugin_off, sizeof m->plugin_off, "%s", why);
|
||||
const char *name = rt_patch_name(set);
|
||||
uint32_t key = name ? (uint32_t)strtoul(name + 4, NULL, 16) : 0;
|
||||
for (int k = 0; k < m->nplugins; k++) {
|
||||
if (m->plugin_keys[k] != key) continue;
|
||||
char line[400];
|
||||
snprintf(line, sizeof line, "%08X\t%08X\t%s\n", key, m->plugin_contents[k], why);
|
||||
stale_append(line);
|
||||
}
|
||||
rt_log("mods: %s: its plugin stays off this run (%s); it waits for the rebuild at the next start", m->name, why);
|
||||
int kept = 0; // the code conflicts counted anew without the set
|
||||
for (int i = 0; i < nconflicts; i++)
|
||||
if (conflicts[i].part != MOD_PART_CODE) conflicts[kept++] = conflicts[i];
|
||||
nconflicts = kept;
|
||||
code_conflicts();
|
||||
}
|
||||
|
||||
void mods_exefs_switch(void) {
|
||||
@@ -616,12 +926,13 @@ const char *mods_dir(void) { return dir; }
|
||||
int mods_count(void) { return nmods; }
|
||||
ModInfo *mods_at(int i) { return i >= 0 && i < nmods ? &mods[i] : NULL; }
|
||||
|
||||
// TOTK_MODS_ORDER as every listed name top first; TOTK_MODS_DISABLED as the switched-off names. A name holding '|'
|
||||
// would split into two; it is left out of both (its mod is unusable anyway).
|
||||
// TOTK_MODS_ORDER as every listed name top first; TOTK_MODS_DISABLED as the switched-off names; TOTK_MODS_NO_CODE as
|
||||
// the names used without their code. A name holding '|' would split into two; it is left out of all (its mod is
|
||||
// unusable anyway).
|
||||
static void write_keys(void) {
|
||||
size_t cap = (size_t)nmods * 257 + 1;
|
||||
char *order = calloc(cap, 1), *off = calloc(cap, 1);
|
||||
if (order && off) {
|
||||
char *order = calloc(cap, 1), *off = calloc(cap, 1), *no_code = calloc(cap, 1);
|
||||
if (order && off && no_code) {
|
||||
for (int i = 0; i < nmods; i++) {
|
||||
if (mods[i].problem == MOD_BAD_NAME) continue;
|
||||
if (*order) strcat(order, "|");
|
||||
@@ -630,12 +941,18 @@ static void write_keys(void) {
|
||||
if (*off) strcat(off, "|");
|
||||
strcat(off, mods[i].name);
|
||||
}
|
||||
if (mods[i].no_code) {
|
||||
if (*no_code) strcat(no_code, "|");
|
||||
strcat(no_code, mods[i].name);
|
||||
}
|
||||
}
|
||||
cfg_set("TOTK_MODS_ORDER", order);
|
||||
cfg_set("TOTK_MODS_DISABLED", off);
|
||||
cfg_set("TOTK_MODS_NO_CODE", no_code);
|
||||
}
|
||||
free(order);
|
||||
free(off);
|
||||
free(no_code);
|
||||
}
|
||||
|
||||
void mods_set_enabled(int i, int on) {
|
||||
@@ -644,6 +961,12 @@ void mods_set_enabled(int i, int on) {
|
||||
write_keys();
|
||||
}
|
||||
|
||||
void mods_set_no_code(int i, int on) {
|
||||
if (i < 0 || i >= nmods) return;
|
||||
mods[i].no_code = on != 0;
|
||||
write_keys();
|
||||
}
|
||||
|
||||
void mods_move(int i, int delta) {
|
||||
int j = i + delta;
|
||||
if (i < 0 || i >= nmods || j < 0 || j >= nmods || i == j) return;
|
||||
@@ -655,6 +978,8 @@ void mods_move(int i, int delta) {
|
||||
|
||||
int mods_changed(void) {
|
||||
for (int i = 0; i < nmods; i++)
|
||||
if (strcmp(mods[i].name, start_order[i]) || mods[i].enabled != start_enabled[i]) return 1;
|
||||
if (strcmp(mods[i].name, start_order[i]) || mods[i].enabled != start_enabled[i] ||
|
||||
mods[i].no_code != start_no_code[i])
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
+47
-8
@@ -5,7 +5,9 @@
|
||||
// switched with their mod (mods_exefs_switch), and data writes stored into main before the game runs (mods_exefs_data).
|
||||
// The list is scanned once at start (romfs.c overlay_init);
|
||||
// its order and switches live in totk.ini [mods] (TOTK_MODS_ORDER: names top first, separated by '|';
|
||||
// TOTK_MODS_DISABLED: names switched off). The top mod wins a file two mods replace.
|
||||
// TOTK_MODS_DISABLED: names switched off; TOTK_MODS_NO_CODE: names used without their code part). The top mod wins
|
||||
// whatever two mods change: a file, bytes of main's data, a code site (patches.c rt_patch_picks); the conflict table
|
||||
// (mods_conflict_at) records who won over whom, for the menu and the log.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -14,10 +16,13 @@ typedef enum {
|
||||
MOD_OK,
|
||||
MOD_EMPTY, // no RomFS file, no ExeFS patch, no cheat file
|
||||
MOD_PLUGIN, // has code modules (exefs/subsdk*, a replaced exefs/main): the port has no module loader, so the
|
||||
// whole mod stays off (its RomFS files may expect that code)
|
||||
// whole mod stays off (its RomFS files may expect that code); used without its code
|
||||
// (ModInfo.without_code) the rest of such a mod is used, without those code modules
|
||||
// (ModInfo.code names them)
|
||||
MOD_EXEFS_LATER, // has ExeFS patches for this game's main that the game was built without: the rebuild at the
|
||||
// next start builds them in; the whole mod stays off until then
|
||||
MOD_EXEFS_UNSUPPORTED, // an ExeFS patch file the port cannot apply (note says why): the whole mod stays off
|
||||
MOD_EXEFS_UNSUPPORTED, // an ExeFS patch file the port cannot apply (note says why): the whole mod stays off,
|
||||
// unless it is used without its code (ModInfo.without_code) and has a usable rest
|
||||
MOD_EXEFS_OTHER, // only ExeFS patches, all for another game version
|
||||
MOD_BAD_NAME, // its folder name holds '|', the separator of the order keys
|
||||
} ModProblem;
|
||||
@@ -27,14 +32,19 @@ typedef struct {
|
||||
char romfs[2048]; // UTF-8 path of its RomFS root; "" none
|
||||
char exefs[2048]; // UTF-8 path of its ExeFS folder; "" none
|
||||
char cheats[2048]; // UTF-8 path of its cheats folder; "" none
|
||||
int kind, enabled;
|
||||
int kind, enabled; // kind: MOD_SUBSDK for any code module
|
||||
int id; // its place in the scan: names it in the conflict table, whatever the menu moves
|
||||
int no_code; // its switch "use without its code" (TOTK_MODS_NO_CODE)
|
||||
int without_code; // the scan's: no_code or TOTK_MODS_WITHOUT_CODE (every mod); the code parts it cannot run
|
||||
// (code modules, unsupported ExeFS patch files) are left out and the rest is used
|
||||
char code[64]; // its code modules in exefs ("subsdk9", "main, subsdk9"): never loaded
|
||||
uint32_t unsupported; // its ExeFS patch files the port cannot apply (the first one's reason in note)
|
||||
ModProblem problem;
|
||||
uint32_t replaced, added, overridden; // romfs.c: files served (replacing / added), files a higher mod serves
|
||||
uint32_t other_version; // files named for another game version: RomFS *.Product.<n>.* the RomFS
|
||||
// lacks (served under their own names; another version's size table is
|
||||
// not) and ExeFS patches for another build (not used)
|
||||
char overridden_by[256]; // the first higher mod that took one of its files
|
||||
char note[256]; // MOD_EXEFS_UNSUPPORTED: why
|
||||
char note[256]; // an unsupported ExeFS patch file: which and why
|
||||
uint32_t pending, pending_key; // ExeFS patch files the build lacks; FNV-1a of their names and contents
|
||||
int nsets;
|
||||
uint32_t sets[16]; // the built patch sets mod_<hash> of its ExeFS patch files
|
||||
@@ -43,8 +53,29 @@ typedef struct {
|
||||
uint32_t data_bytes; // the bytes its usable ExeFS patch files write into main's data, as their
|
||||
// status lines count them ("data <bytes>")
|
||||
char overrides[256]; // the port's own patch sets its patches replace, comma separated
|
||||
// Its exefs/subsdk* plugins (build-cache/plugins.status, tools/exefs_plugins.py): the built ones are patch sets in
|
||||
// sets[] whose init runs at start (plugin_init.c); a refused one is a code module it cannot run (code).
|
||||
int nplugins, plugin_hooks; // built plugins and their hooks
|
||||
uint32_t plugin_keys[4], plugin_contents[4]; // their file and content hashes, for plugins.stale
|
||||
char plugin_file[64]; // the first plugin's file name
|
||||
char plugin_note[256]; // why the build refused a plugin ("" none)
|
||||
char plugin_off[256]; // why its plugin stays off this run: its start differed from the build
|
||||
} ModInfo;
|
||||
|
||||
// What two mods both change, the higher one winning: files (romfs.c), bytes of main's data and code sites
|
||||
// (mods_exefs_apply). One entry per winner, loser and part, as at start.
|
||||
typedef enum { MOD_PART_FILES, MOD_PART_DATA, MOD_PART_CODE, MOD_PARTS } ModPart;
|
||||
typedef struct {
|
||||
int winner, loser; // ModInfo.id
|
||||
ModPart part;
|
||||
uint32_t count; // files, bytes, code sites
|
||||
} ModConflict;
|
||||
void mods_conflict(int winner, int loser, ModPart part, uint32_t count); // adds count to the pair's entry
|
||||
int mods_conflict_count(void);
|
||||
const ModConflict *mods_conflict_at(int i);
|
||||
void mods_conflicts_log(ModPart part); // one line each way per entry of that part
|
||||
const ModInfo *mods_by_id(int id);
|
||||
|
||||
void mods_scan(void); // once; later calls return at once
|
||||
// Every switched-on mod folder's RomFS root, without the rest of the scan (no ExeFS checks, no order): for mem_init,
|
||||
// which runs before the paths mods_scan needs are set (resolution.c mod_tex_heap_kib). cb gets the name and root.
|
||||
@@ -55,10 +86,12 @@ ModInfo *mods_at(int i); // 0 = top of the order; NULL out of range
|
||||
// Menu edits (present path). They change the list mods_at shows and write TOTK_MODS_ORDER / TOTK_MODS_DISABLED with
|
||||
// cfg_set; romfs.c used the start state, so they apply at the next start.
|
||||
void mods_set_enabled(int i, int on);
|
||||
void mods_set_no_code(int i, int on); // "use without its code" (TOTK_MODS_NO_CODE)
|
||||
void mods_move(int i, int delta); // -1 up, +1 down; nothing at the ends
|
||||
int mods_changed(void); // 1 when the order or a switch differs from the start
|
||||
// After ldr_load and rt_patches_init, before any game code: the patch sets of the enabled mods' ExeFS patches on, the
|
||||
// port's own sets they replace off, and their data writes stored into main (mods_exefs_data).
|
||||
// After ldr_load and rt_patches_init, before any game code: the patch sets of the enabled mods' ExeFS patches on and
|
||||
// ranked by the order (rt_patch_rank: the top mod's code runs where several patch one site), the port's own sets they
|
||||
// replace off, and their data writes stored into main (mods_exefs_data); the data and code conflicts recorded.
|
||||
void mods_exefs_switch(void);
|
||||
// What mods_exefs_switch does with main's image at base (size bytes, code below code_end; size 0: no data stored), for
|
||||
// every enabled mod from the bottom one up, so that the top mod's data writes win where two mods write the same bytes.
|
||||
@@ -79,5 +112,11 @@ void mods_rescan(void);
|
||||
// The ExeFS patch files of the enabled mods that the build lacks, their FNV-1a mixed into *key (cheats.c starts the
|
||||
// rebuild for them).
|
||||
int mods_exefs_pending(uint32_t *key);
|
||||
// From plugin_init.c plugins_start: the plugin patch set `set` stays off this run (why), its mod's row says so,
|
||||
// build-cache/plugins.stale marks its file for the rebuild at the next start, and the code conflicts are counted anew.
|
||||
void mods_plugin_off(int set, const char *why);
|
||||
// --probe-mods: the texts of build-cache/plugins.status and plugins.stale instead of the files; the stale lines
|
||||
// mods_plugin_off adds stay in memory.
|
||||
void mods_probe_plugins(const char *status, const char *stale);
|
||||
// The hex of the game main's build id (64 digits), "" when exefs/main cannot be read.
|
||||
const char *mods_main_build_id(void);
|
||||
@@ -121,11 +121,262 @@ static void probe_data(const char *root) {
|
||||
mods_exefs_apply(base, sizeof img, 8, store_buffer);
|
||||
CHECK(img[0x28] == 0xAA, "two mods write the same byte: the top mod's byte stays");
|
||||
CHECK(!memcmp(img + 0x10, "ABC", 3) && !img[0x30], "the other mods' data as each one stores it alone");
|
||||
const ModInfo *xm = by_name("X"), *ym = by_name("Y");
|
||||
CHECK(mods_conflict_count() == 1 && xm && ym && mods_conflict_at(0)->winner == ym->id &&
|
||||
mods_conflict_at(0)->loser == xm->id && mods_conflict_at(0)->part == MOD_PART_DATA &&
|
||||
mods_conflict_at(0)->count == 1,
|
||||
"the conflict table: Y overrides X at one byte of data");
|
||||
}
|
||||
mods_probe_cache(NULL, NULL);
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
// "mod_<key>": the name tools/exefs_patches.py gives the patch set of the file at rel (mod folder name / path in it).
|
||||
static void set_name(char *out, size_t cap, const char *rel) { snprintf(out, cap, "mod_%08x", fnv(rel, strlen(rel))); }
|
||||
|
||||
// Code sites several mods patch (patches.c rt_patch_picks): a set table of the probe's own, with the sets of the ExeFS
|
||||
// patch files of A (one file), B (two files) and C (one, switched off) and three contested sites:
|
||||
// 0: A and B's first file the higher mod's set runs; a conflict of B over A or A over B
|
||||
// 1: B's two files the later file in the mod runs; no conflict
|
||||
// 2: C and A C is off, so A's runs; no conflict
|
||||
static void probe_code(const char *root) {
|
||||
remove_tree(root);
|
||||
plat_file_mkdir_p(root);
|
||||
const char *bid = *mods_main_build_id() ? mods_main_build_id() : "0";
|
||||
char a[160], b1[160], b2[160], c[160];
|
||||
snprintf(a, sizeof a, "A/exefs/%s.ips", bid);
|
||||
snprintf(b1, sizeof b1, "B/atmosphere/exefs_patches/one/%s.ips", bid);
|
||||
snprintf(b2, sizeof b2, "B/atmosphere/exefs_patches/two/%s.ips", bid);
|
||||
snprintf(c, sizeof c, "C/exefs/%s.ips", bid);
|
||||
const char *files[] = {a, b1, b2, c};
|
||||
static char names[5][16];
|
||||
static const char *const table[] = {"fps60", names[1], names[2], names[3], names[4]};
|
||||
char status[512] = "";
|
||||
for (int i = 0; i < 4; i++) {
|
||||
put(root, files[i]);
|
||||
set_name(names[i + 1], sizeof names[i + 1], files[i]);
|
||||
size_t at = strlen(status);
|
||||
snprintf(status + at, sizeof status - at, "%08X\t%08X\tcode\t-\t\n", fnv(files[i], strlen(files[i])),
|
||||
fnv("probe", 5));
|
||||
}
|
||||
static const int16_t s0[] = {1, 2}, s1[] = {2, 3}, s2[] = {4, 1};
|
||||
static const RtPatchPick picks[] = {{"main", 0x100, s0, 2}, {"main", 0x200, s1, 2}, {"main", 0x300, s2, 2}};
|
||||
mods_probe_cache(status, "");
|
||||
cfg_set("TOTK_MODS_DIR", root);
|
||||
cfg_set("TOTK_MODS_DISABLED", "C");
|
||||
for (int round = 0; round < 2; round++) {
|
||||
cfg_set("TOTK_MODS_ORDER", round ? "A|B" : "B|A");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
rt_patch_probe_table(table, 5, picks, 3);
|
||||
mods_exefs_apply(0, 0, 0, NULL);
|
||||
const ModInfo *am = by_name("A"), *bm = by_name("B");
|
||||
CHECK(am && bm && am->nsets == 1 && bm->nsets == 2 && am->problem == MOD_OK, "code scan: A one set, B two");
|
||||
if (!am || !bm) break;
|
||||
const ModInfo *hi = round ? am : bm, *lo = round ? bm : am;
|
||||
CHECK(rt_patch_pick_winner(0) == (round ? 0 : 1), round ? "A above B: A's code runs at their site"
|
||||
: "B above A: B's code runs at their site");
|
||||
CHECK(rt_patch_pick_winner(1) == 1, "two files of one mod on a site: the later file's code runs");
|
||||
CHECK(rt_patch_pick_winner(2) == 1 && !rt_patch_enabled(4), "a switched-off mod's set stays off");
|
||||
CHECK(mods_conflict_count() == 1 && mods_conflict_at(0)->winner == hi->id &&
|
||||
mods_conflict_at(0)->loser == lo->id && mods_conflict_at(0)->part == MOD_PART_CODE &&
|
||||
mods_conflict_at(0)->count == 1,
|
||||
"the conflict table: the higher mod overrides the lower one at one code site, and only there");
|
||||
// the winner switched off at run time: the site takes the other mod's set
|
||||
rt_patch_switch(round ? 1 : 2, 0);
|
||||
CHECK(rt_patch_pick_winner(0) == (round ? 1 : 0), "a contested site follows a switch of its winner");
|
||||
}
|
||||
// the table itself: one entry per pair and part, counts adding up
|
||||
mods_conflict(7, 8, MOD_PART_FILES, 2);
|
||||
mods_conflict(7, 8, MOD_PART_FILES, 3);
|
||||
const ModConflict *last = mods_conflict_at(mods_conflict_count() - 1);
|
||||
CHECK(last && last->winner == 7 && last->count == 5, "mods_conflict adds to the pair's entry");
|
||||
rt_patch_probe_table(NULL, 0, NULL, 0);
|
||||
cfg_set("TOTK_MODS_DISABLED", "");
|
||||
mods_probe_cache(NULL, NULL);
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
// build-cache/plugins.status lines (tools/exefs_plugins.py) that refuse the probe's subsdk9 files of E and H: they stay
|
||||
// code the port cannot run.
|
||||
static const char *refused_plugins(void) {
|
||||
static char text[256];
|
||||
snprintf(text, sizeof text, "%08X\t%08X\tunsupported\t-\tthe init called svc 0x40\n"
|
||||
"%08X\t%08X\tunsupported\t-\tthe init called svc 0x40\n", fnv("E/exefs/subsdk9", 15), fnv("probe", 5),
|
||||
fnv("H/exefs/subsdk9", 15), fnv("probe", 5));
|
||||
return text;
|
||||
}
|
||||
|
||||
// Mod plugins (build-cache/plugins.status, plugins.stale; mods.c plugin_file, mods_plugin_off) in a folder of their own:
|
||||
// P RomFS + a built plugin (7 hooks) its set on, ranked by the order; a contested site with Q's patch file
|
||||
// Q an ExeFS patch file on P's site
|
||||
// R a plugin the build has no line for waits for the rebuild
|
||||
// S RomFS + a refused plugin off, the reason kept; used without its code, the rest runs
|
||||
// T a built plugin + a refused one each judged alone: off for the refused one, its reason kept; used
|
||||
// without its code, the built one's set runs
|
||||
// Then P's start differs from the build (mods_plugin_off): its set goes off, Q's code runs at the site, the conflict
|
||||
// goes, a stale line marks P's file, and the next scan has P wait for the rebuild.
|
||||
static void probe_plugins(const char *root) {
|
||||
remove_tree(root);
|
||||
plat_file_mkdir_p(root);
|
||||
const char *bid = *mods_main_build_id() ? mods_main_build_id() : "0";
|
||||
char q[160];
|
||||
snprintf(q, sizeof q, "Q/exefs/%s.ips", bid);
|
||||
static const char *const files[] = {"P/romfs/p.bin", "P/exefs/subsdk9", "R/exefs/subsdk9", "S/romfs/s.bin",
|
||||
"S/exefs/subsdk9", "T/exefs/subsdk8", "T/exefs/subsdk9"};
|
||||
for (size_t i = 0; i < sizeof files / sizeof *files; i++) put(root, files[i]);
|
||||
put(root, q);
|
||||
static char names[4][16];
|
||||
static const char *const table[] = {"fps60", names[1], names[2], names[3]};
|
||||
set_name(names[1], sizeof names[1], "P/exefs/subsdk9");
|
||||
set_name(names[2], sizeof names[2], q);
|
||||
set_name(names[3], sizeof names[3], "T/exefs/subsdk9");
|
||||
char status[256], plugins[512];
|
||||
snprintf(status, sizeof status, "%08X\t%08X\tcode\t-\t\n", fnv(q, strlen(q)), fnv("probe", 5));
|
||||
snprintf(plugins, sizeof plugins, "%08X\t%08X\tplugin\tfps60\tplugin0, 7 hooks\n"
|
||||
"%08X\t%08X\tunsupported\t-\tthe code its hooks reach has svc 0x40\n"
|
||||
"%08X\t%08X\tplugin\t-\tplugin1, 2 hooks\n"
|
||||
"%08X\t%08X\tunsupported\t-\tthe run was refused: svc 0x1 at plugin2+0x50a0\n", fnv("P/exefs/subsdk9", 15),
|
||||
fnv("probe", 5), fnv("S/exefs/subsdk9", 15), fnv("probe", 5), fnv("T/exefs/subsdk9", 15), fnv("probe", 5),
|
||||
fnv("T/exefs/subsdk8", 15), fnv("probe", 5));
|
||||
static const int16_t s0[] = {1, 2};
|
||||
static const RtPatchPick picks[] = {{"main", 0x100, s0, 2}};
|
||||
mods_probe_cache(status, "");
|
||||
mods_probe_plugins(plugins, "");
|
||||
cfg_set("TOTK_MODS_DIR", root);
|
||||
cfg_set("TOTK_MODS_DISABLED", "");
|
||||
cfg_set("TOTK_MODS_NO_CODE", "");
|
||||
for (int round = 0; round < 2; round++) {
|
||||
cfg_set("TOTK_MODS_ORDER", round ? "Q|P" : "P|Q");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
rt_patch_probe_table(table, 4, picks, 1);
|
||||
rt_patch_switch(0, 1);
|
||||
mods_exefs_apply(0, 0, 0, NULL);
|
||||
const ModInfo *pm = by_name("P"), *qm = by_name("Q"), *rm = by_name("R"), *sm = by_name("S"),
|
||||
*tm = by_name("T");
|
||||
CHECK(pm && qm && rm && sm && tm, "plugin scan: five mods");
|
||||
if (!pm || !qm || !rm || !sm || !tm) break;
|
||||
CHECK(pm->problem == MOD_OK && pm->nsets == 1 && pm->nplugins == 1 && pm->plugin_hooks == 7 && !pm->code[0] &&
|
||||
EQ(pm->overrides, "fps60"), "a built plugin: its set, its hooks, the built-in set it replaces");
|
||||
CHECK(rt_patch_enabled(1) && !rt_patch_enabled(0), "the plugin's set on, the built-in set it replaces off");
|
||||
CHECK(rt_patch_pick_winner(0) == (round ? 1 : 0), round ? "Q above P: Q's patch runs at their site"
|
||||
: "P above Q: P's plugin hook runs at their site");
|
||||
CHECK(mods_conflict_count() == 1 && mods_conflict_at(0)->part == MOD_PART_CODE &&
|
||||
mods_conflict_at(0)->winner == (round ? qm : pm)->id,
|
||||
"the conflict table: a plugin site against a patch file goes by the order");
|
||||
CHECK(rm->problem == MOD_EXEFS_LATER && rm->pending == 1, "a plugin the build lacks waits for the rebuild");
|
||||
CHECK(sm->problem == MOD_PLUGIN && EQ(sm->code, "subsdk9") && strstr(sm->plugin_note, "svc 0x40"),
|
||||
"a refused plugin keeps its mod off and says why");
|
||||
CHECK(tm->problem == MOD_PLUGIN && tm->nplugins == 1 && tm->plugin_hooks == 2 && EQ(tm->code, "subsdk8") &&
|
||||
strstr(tm->plugin_note, "svc 0x1") && !rt_patch_enabled(3),
|
||||
"a built plugin beside a refused one: the mod off, the refused one's reason on its row");
|
||||
}
|
||||
// P above Q, then P's start differs from the build
|
||||
cfg_set("TOTK_MODS_ORDER", "P|Q");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
rt_patch_probe_table(table, 4, picks, 1);
|
||||
mods_exefs_apply(0, 0, 0, NULL);
|
||||
mods_plugin_off(1, "probe: 1 of the words the build recorded were not written");
|
||||
const ModInfo *pm = by_name("P");
|
||||
CHECK(!rt_patch_enabled(1) && rt_patch_pick_winner(0) == 1, "a plugin off at start: the other mod's patch runs");
|
||||
CHECK(pm && strstr(pm->plugin_off, "were not written"), "its row says why");
|
||||
CHECK(mods_conflict_count() == 0, "its conflict goes with it");
|
||||
cfg_set("TOTK_MODS_NO_CODE", "S|T");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
rt_patch_probe_table(table, 4, picks, 1);
|
||||
mods_exefs_apply(0, 0, 0, NULL);
|
||||
pm = by_name("P");
|
||||
const ModInfo *sm = by_name("S"), *tm = by_name("T");
|
||||
CHECK(pm && pm->problem == MOD_EXEFS_LATER && pm->pending == 1, "the next start: its file waits for the rebuild");
|
||||
CHECK(sm && sm->problem == MOD_OK && sm->plugin_note[0], "a refused plugin used without its code: the rest runs");
|
||||
CHECK(tm && tm->problem == MOD_OK && tm->plugin_note[0] && rt_patch_enabled(3),
|
||||
"a built plugin beside a refused one, used without its code: the built one's set runs");
|
||||
rt_patch_probe_table(NULL, 0, NULL, 0);
|
||||
cfg_set("TOTK_MODS_NO_CODE", "");
|
||||
cfg_set("TOTK_MODS_ORDER", "");
|
||||
mods_probe_cache(NULL, NULL);
|
||||
mods_probe_plugins(refused_plugins(), "");
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
// Mods with code the port cannot run (a code module, an ExeFS patch file it cannot apply): used without that code
|
||||
// by their own switch (mods_no_code) or by mods_without_code for every mod.
|
||||
static void probe_without_code(const char *root) {
|
||||
remove_tree(root);
|
||||
plat_file_mkdir_p(root);
|
||||
const char *bid = *mods_main_build_id() ? mods_main_build_id() : "0";
|
||||
char u[160], v[160];
|
||||
snprintf(u, sizeof u, "U/exefs/%s.ips", bid); // with RomFS files: the rest is usable
|
||||
snprintf(v, sizeof v, "V/exefs/%s.ips", bid); // nothing else
|
||||
static const char *const files[] = {"E/exefs/subsdk9", "H/romfs/h.bin", "H/exefs/subsdk9", "I/romfs/i.bin",
|
||||
"I/exefs/main", "U/romfs/u.bin"};
|
||||
for (size_t i = 0; i < sizeof files / sizeof *files; i++) put(root, files[i]);
|
||||
put(root, u);
|
||||
put(root, v);
|
||||
char status[256];
|
||||
snprintf(status, sizeof status, "%08X\t%08X\tunsupported\t-\tit writes outside main\n"
|
||||
"%08X\t%08X\tunsupported\t-\tit writes outside main\n", fnv(u, strlen(u)), fnv("probe", 5),
|
||||
fnv(v, strlen(v)), fnv("probe", 5));
|
||||
mods_probe_cache(status, "");
|
||||
cfg_set("TOTK_MODS_NO_CODE", "H|U|V");
|
||||
cfg_set("TOTK_MODS_DIR", root);
|
||||
cfg_set("TOTK_MODS_ORDER", "");
|
||||
cfg_set("TOTK_MODS_DISABLED", "");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
{
|
||||
ModInfo *h = by_name("H"), *im = by_name("I"), *um = by_name("U"), *vm = by_name("V");
|
||||
CHECK(h && im && um && vm, "per-mod scan: four mods");
|
||||
if (h && im && um && vm) {
|
||||
CHECK(h->problem == MOD_OK && h->no_code && EQ(h->code, "subsdk9"),
|
||||
"its own switch: RomFS + subsdk9 is used without the code module");
|
||||
CHECK(im->problem == MOD_PLUGIN && !im->no_code, "a mod without the switch stays off");
|
||||
CHECK(um->problem == MOD_OK && um->unsupported == 1 && um->note[0],
|
||||
"its own switch: RomFS + an unsupported patch file is used without that file");
|
||||
CHECK(vm->problem == MOD_EXEFS_UNSUPPORTED, "an unsupported patch file and nothing else stays off");
|
||||
int ii = 0;
|
||||
while (mods_at(ii) != im) ii++;
|
||||
mods_set_no_code(ii, 1);
|
||||
CHECK(EQ(cfg_get("TOTK_MODS_NO_CODE"), "H|I|U|V") && mods_changed(), "the switch writes mods_no_code");
|
||||
}
|
||||
}
|
||||
cfg_set("TOTK_MODS_NO_CODE", "");
|
||||
cfg_set("TOTK_MODS_WITHOUT_CODE", "0");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
CHECK(by_name("U") && by_name("U")->problem == MOD_EXEFS_UNSUPPORTED, "without the switch an unsupported file "
|
||||
"keeps the whole mod off");
|
||||
remove_tree(root);
|
||||
plat_file_mkdir_p(root);
|
||||
for (size_t i = 0; i < 5; i++) put(root, files[i]);
|
||||
mods_probe_cache("", "");
|
||||
cfg_set("TOTK_MODS_DIR", root);
|
||||
cfg_set("TOTK_MODS_ORDER", "");
|
||||
cfg_set("TOTK_MODS_DISABLED", "");
|
||||
cfg_set("TOTK_MODS_WITHOUT_CODE", "1");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
ModInfo *e = by_name("E"), *h = by_name("H"), *im = by_name("I");
|
||||
CHECK(e && h && im, "without-code scan: three mods");
|
||||
if (e && h && im) {
|
||||
CHECK(e->problem == MOD_PLUGIN, "mods_without_code: a mod with only a code module stays off");
|
||||
CHECK(h->problem == MOD_OK && EQ(h->code, "subsdk9"), "mods_without_code: RomFS + subsdk9 is used without it");
|
||||
CHECK(im->problem == MOD_OK && EQ(im->code, "main"), "mods_without_code: RomFS + replaced main is used");
|
||||
}
|
||||
cfg_set("TOTK_MODS_WITHOUT_CODE", "0");
|
||||
mods_rescan();
|
||||
mods_scan();
|
||||
h = by_name("H");
|
||||
CHECK(h && h->problem == MOD_PLUGIN && !h->without_code, "without mods_without_code a mod with a code module stays "
|
||||
"off");
|
||||
cfg_set("TOTK_MODS_WITHOUT_CODE", "");
|
||||
mods_probe_cache(NULL, NULL);
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
// s ends in tail, either path separator matching either.
|
||||
static int ends_with(const char *s, const char *tail) {
|
||||
size_t n = strlen(s), t = strlen(tail);
|
||||
@@ -146,6 +397,7 @@ int probe_mods(void) {
|
||||
if (back > cut) cut = back;
|
||||
if (!cut) return 1;
|
||||
strcpy(cut + 1, "mods-probe");
|
||||
mods_probe_plugins(refused_plugins(), ""); // not the build's own plugins.status
|
||||
remove_tree(root);
|
||||
plat_file_mkdir_p(root);
|
||||
static const char *const files[] = {
|
||||
@@ -214,6 +466,10 @@ int probe_mods(void) {
|
||||
CHECK(mods_changed(), "changes seen");
|
||||
}
|
||||
probe_data(root);
|
||||
probe_without_code(root);
|
||||
probe_code(root);
|
||||
probe_plugins(root);
|
||||
mods_probe_plugins(NULL, NULL);
|
||||
printf("mods: %s\n", fails ? "FAIL" : "ok");
|
||||
int table = restbl_probe();
|
||||
return fails || table ? 1 : 0;
|
||||
|
||||
+148
-15
@@ -6,12 +6,17 @@
|
||||
// reports it: acceleration in G, angular velocity in revolutions per second, angle = the integrated revolutions per
|
||||
// axis, direction = the controller's three axes in a reference frame whose z is up. The orientation is integrated from
|
||||
// the gyro and, while the controller is not being accelerated (|a| within 15 % of 1 G), pulled toward the measured
|
||||
// gravity (Mahony, gain 0.5/s: about 2 s), as the Switch's sensor fusion does; yaw has no reference and drifts with the
|
||||
// gyro's bias, so a bias measured with the controller at rest (the Calibrate gyro row, motion_calibrate_start) is
|
||||
// subtracted from every sample while gyro_calibration is on. The newest MOTION_RING samples are kept; reads are newest
|
||||
// first. A restart (StartSixAxisSensor) drops the samples before it: reads return nothing until the next sample, which
|
||||
// starts a fresh frame and angle; sampling numbers go on. The feeding thread writes, guest threads read, both under the
|
||||
// instance's SRW lock.
|
||||
// gravity (Mahony, gain 0.5/s: about 2 s), as the Switch's sensor fusion does; held still (|a| within 5 % of 1 G,
|
||||
// turning slower than STILL_RATE) the pull is STILL_GAIN, so a down the gyro got wrong while the controller moved is
|
||||
// right again before the next aim. The game splits the aim into pitch and yaw by the reported down: a wrong one turns a
|
||||
// tilt up or down into a turn to the side as well. Yaw has no reference and drifts with the gyro's bias, so a bias
|
||||
// measured with the controller at rest (the Calibrate gyro row, motion_calibrate_start) is subtracted from every sample
|
||||
// while gyro_calibration is on, and the drift left after it is learned while the controller lies still and subtracted
|
||||
// too while gyro_auto_bias is on (drift_track). The newest MOTION_RING samples are kept; reads are newest first. A
|
||||
// restart (StartSixAxisSensor) drops the samples before it: reads return nothing until the first sample with a reading
|
||||
// (|a| over 0.5 G: a sensor just switched on reads zero until its first report), which starts a fresh frame, levelled
|
||||
// by that reading, and a fresh angle; sampling numbers go on. The feeding thread writes, guest threads read, both under
|
||||
// the instance's SRW lock.
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -31,6 +36,29 @@ enum { MOTION_RING = 64, CALIB_SETTLE = 125, CALIB_SAMPLES = 250 };
|
||||
// near 0.01-0.02 rad/s. A jolt that stays under the limit moves the mean by at most the limit times the square root of
|
||||
// the share of the second it lasts.
|
||||
#define CALIB_MAX_SPREAD 0.04
|
||||
#define STILL_GAIN 4.0 // 1/s: a wrong down is 2 % of itself after a second held still
|
||||
#define STILL_RATE 0.5 // rad/s, about 30 deg/s: a slow aim still counts as held still
|
||||
// The drift tracker (drift_track), after PR #380's estimator: a window of REST_WIN samples (256 ms) is still when every
|
||||
// axis of the gyro stays within REST_GYRO_PTP peak to peak and of the acceleration within REST_ACC_PTP, |a| is within
|
||||
// REST_GRAVITY of 1 G, and the window's mean rate is within DRIFT_FIRST_MAX (before the estimate settled) or
|
||||
// DRIFT_TRACK_MAX (after) of the estimate in use. A Pro Controller on a table reads 0.004-0.006 rad/s of noise and
|
||||
// passes; held in a hand, even steadily, it reads 0.013-0.025 rad/s and mostly does not, so the tracker learns from a
|
||||
// controller put down rather than from an aim held still. After REST_HOLD_S still the estimate moves toward the
|
||||
// window's mean with a time constant of DRIFT_TAU_FIRST until it has settled, then DRIFT_TAU: a bias changes only
|
||||
// slowly as the controller warms up, and a hand that slips past the gate shifts it little. No dead zone: a slow aim
|
||||
// keeps every bit of its rate.
|
||||
enum { REST_WIN = 64 };
|
||||
#define REST_GYRO_PTP 0.04 // rad/s, per axis over the window
|
||||
#define REST_ACC_PTP 0.03 // G, per axis over the window
|
||||
#define REST_GRAVITY 0.25 // G: controllers' accelerometers read 1 G only roughly
|
||||
#define REST_HOLD_S 0.5
|
||||
#define DRIFT_FIRST_MAX 0.1 // rad/s, 5.7 deg/s; a larger factory bias (one Pro: 0.14 on z) needs the calibration
|
||||
#define DRIFT_TRACK_MAX 0.05 // rad/s
|
||||
#define DRIFT_TAU_FIRST 0.25 // s
|
||||
#define DRIFT_TAU 30.0 // s
|
||||
#define DRIFT_SETTLE_S 1.5 // learning this long with the estimate within DRIFT_SETTLED of the window: settled
|
||||
#define DRIFT_SETTLED 0.01 // rad/s
|
||||
#define DRIFT_LIMIT 0.3 // rad/s per axis
|
||||
|
||||
struct MotionFusion {
|
||||
PlatMutex lock;
|
||||
@@ -49,6 +77,16 @@ struct MotionFusion {
|
||||
char calib_pad[128]; // the controller the attempt measures (input.c pad_identity), written with the bias
|
||||
int calib_result; // MOTION_CALIB_NONE, _DONE, _FAILED or _MOVED: the outcome the row shows between attempts
|
||||
int persist; // the gamepad's instance: a finished calibration is written to totk.ini
|
||||
// The drift tracker: the estimate (rad/s, on top of gyro_bias when gyro_calibration is on), whether it settled,
|
||||
// and the rest window it is learned from. The estimate belongs to the controller and to the bias it was learned
|
||||
// against: kept through restarts, cleared with a new controller, a new calibration or a change of
|
||||
// gyro_calibration (drift_clear).
|
||||
double drift[3];
|
||||
int drift_settled;
|
||||
int drift_base; // gyro_calibration the estimate was learned with, -1 none
|
||||
double rest_s, learn_s;
|
||||
double win_g[REST_WIN][3], win_a[REST_WIN][3];
|
||||
int win_n, win_i;
|
||||
};
|
||||
|
||||
MotionFusion *motion_new(void) {
|
||||
@@ -56,6 +94,7 @@ MotionFusion *motion_new(void) {
|
||||
if (!m) rt_fatal("motion: out of memory");
|
||||
plat_mutex_init(&m->lock);
|
||||
m->restart = 1;
|
||||
m->drift_base = -1;
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -89,11 +128,11 @@ static void orthonormalize(double R[3][3]) {
|
||||
for (int j = 0; j < 3; j++) R[0][j] /= n;
|
||||
cross3(R[2], R[0], R[1]);
|
||||
}
|
||||
// A fresh orientation: z up against the measured gravity, x as close to the controller's x as that allows.
|
||||
// A fresh orientation: z up against the measured gravity (|acc| over 0.5 G), x as close to the controller's x as that
|
||||
// allows.
|
||||
static void align_to(double R[3][3], const double acc[3]) {
|
||||
double n = norm3(acc), up[3] = {0, 0, 1}, x[3] = {1, 0, 0};
|
||||
if (n > 0.5)
|
||||
for (int j = 0; j < 3; j++) up[j] = -acc[j] / n;
|
||||
double n = norm3(acc), up[3], x[3] = {1, 0, 0};
|
||||
for (int j = 0; j < 3; j++) up[j] = -acc[j] / n;
|
||||
if (fabs(up[0]) > 0.9) { x[0] = 0; x[1] = 1; }
|
||||
memcpy(R[2], up, sizeof up);
|
||||
memcpy(R[0], x, sizeof x);
|
||||
@@ -103,7 +142,7 @@ static void align_to(double R[3][3], const double acc[3]) {
|
||||
static void integrate(double R[3][3], const double gyro[3], const double acc[3], double dt) {
|
||||
double w[3] = {gyro[0], gyro[1], gyro[2]}, n = norm3(acc);
|
||||
if (fabs(n - 1) < 0.15) { // not being accelerated: turn the estimated down toward the measured one
|
||||
const double kp = 0.5;
|
||||
double kp = fabs(n - 1) < 0.05 && norm3(gyro) < STILL_RATE ? STILL_GAIN : 0.5;
|
||||
double measured[3] = {acc[0] / n, acc[1] / n, acc[2] / n}, estimated[3] = {-R[2][0], -R[2][1], -R[2][2]}, e[3];
|
||||
cross3(measured, estimated, e);
|
||||
for (int j = 0; j < 3; j++) w[j] += kp * e[j];
|
||||
@@ -128,6 +167,80 @@ static void integrate(double R[3][3], const double gyro[3], const double acc[3],
|
||||
orthonormalize(R);
|
||||
}
|
||||
|
||||
// The tracker's own switch (gyro_auto_bias, live, default 0: subtracting a learned bias made aiming feel worse in
|
||||
// play, cause unknown). Off, nothing is learned or subtracted.
|
||||
int motion_auto_bias_enabled(void) {
|
||||
static int on = -1;
|
||||
static unsigned seen;
|
||||
unsigned v = cfg_version();
|
||||
if (on < 0 || v != seen) {
|
||||
seen = v;
|
||||
on = cfg_bool("TOTK_GYRO_AUTO_BIAS");
|
||||
}
|
||||
return on;
|
||||
}
|
||||
|
||||
// m->lock held: forget the estimate and the rest window.
|
||||
static void drift_clear(MotionFusion *m) {
|
||||
memset(m->drift, 0, sizeof m->drift);
|
||||
m->drift_settled = 0;
|
||||
m->drift_base = -1;
|
||||
m->rest_s = m->learn_s = 0;
|
||||
m->win_n = m->win_i = 0;
|
||||
}
|
||||
|
||||
// Largest per-axis peak-to-peak of a full window.
|
||||
static double win_ptp(const double w[REST_WIN][3]) {
|
||||
double worst = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
double lo = w[0][i], hi = w[0][i];
|
||||
for (int j = 1; j < REST_WIN; j++) {
|
||||
if (w[j][i] < lo) lo = w[j][i];
|
||||
if (w[j][i] > hi) hi = w[j][i];
|
||||
}
|
||||
if (hi - lo > worst) worst = hi - lo;
|
||||
}
|
||||
return worst;
|
||||
}
|
||||
|
||||
// m->lock held, one sample with a reading: gyro is the rate with the calibrated bias taken off when base is 1. Moves
|
||||
// m->drift toward the rate of a controller lying still. Returns 1 when the estimate settled with this sample.
|
||||
static int drift_track(MotionFusion *m, const double acc[3], const double gyro[3], int base, double dt) {
|
||||
if (m->drift_base != base) { // nothing learned yet, or learned against the other baseline: start over
|
||||
drift_clear(m);
|
||||
m->drift_base = base;
|
||||
}
|
||||
memcpy(m->win_g[m->win_i], gyro, sizeof m->win_g[0]);
|
||||
memcpy(m->win_a[m->win_i], acc, sizeof m->win_a[0]);
|
||||
m->win_i = (m->win_i + 1) % REST_WIN;
|
||||
if (m->win_n < REST_WIN) m->win_n++;
|
||||
if (m->win_n < REST_WIN) return 0;
|
||||
double mean[3] = {0, 0, 0}, a[3] = {0, 0, 0}, dev = 0;
|
||||
for (int j = 0; j < REST_WIN; j++)
|
||||
for (int i = 0; i < 3; i++) mean[i] += m->win_g[j][i] / REST_WIN, a[i] += m->win_a[j][i] / REST_WIN;
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (fabs(mean[i] - m->drift[i]) > dev) dev = fabs(mean[i] - m->drift[i]);
|
||||
int still = fabs(norm3(a) - 1) < REST_GRAVITY && win_ptp(m->win_g) < REST_GYRO_PTP &&
|
||||
win_ptp(m->win_a) < REST_ACC_PTP && dev < (m->drift_settled ? DRIFT_TRACK_MAX : DRIFT_FIRST_MAX);
|
||||
if (!still) {
|
||||
m->rest_s = 0;
|
||||
if (!m->drift_settled) m->learn_s = 0;
|
||||
return 0;
|
||||
}
|
||||
m->rest_s += dt;
|
||||
if (m->rest_s < REST_HOLD_S) return 0;
|
||||
double k = dt / (m->drift_settled ? DRIFT_TAU : DRIFT_TAU_FIRST);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
m->drift[i] += k * (mean[i] - m->drift[i]);
|
||||
if (m->drift[i] > DRIFT_LIMIT) m->drift[i] = DRIFT_LIMIT;
|
||||
if (m->drift[i] < -DRIFT_LIMIT) m->drift[i] = -DRIFT_LIMIT;
|
||||
}
|
||||
m->learn_s += dt;
|
||||
if (m->drift_settled || m->learn_s < DRIFT_SETTLE_S || dev >= DRIFT_SETTLED) return 0;
|
||||
m->drift_settled = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Write the calibrated bias to totk.ini. Called with m->lock released: cfg_set takes cfg.c's own lock and cfg_save
|
||||
// rewrites the file, and neither belongs inside the sensor thread's critical section.
|
||||
static void save_bias(const double bias[3], const char *pad, double spread) {
|
||||
@@ -203,18 +316,24 @@ static int calib_sample(MotionFusion *m, const double g[3], double *spread) {
|
||||
m->bias_valid = 1;
|
||||
m->calib_result = MOTION_CALIB_DONE;
|
||||
m->restart = 1; // the angle and direction start over from the new bias
|
||||
drift_clear(m); // what it learned was the old bias's remainder
|
||||
return 1;
|
||||
}
|
||||
|
||||
void motion_feed(MotionFusion *m, const double acc[3], const double gyro_raw[3], uint64_t now) {
|
||||
const int calib_on = motion_calibration_enabled(); // read before the lock: a settings change takes cfg.c's lock
|
||||
double saved[3] = {0, 0, 0}, spread = 0;
|
||||
// Read before the lock: a settings change takes cfg.c's lock.
|
||||
const int calib_on = motion_calibration_enabled(), auto_on = motion_auto_bias_enabled();
|
||||
double saved[3] = {0, 0, 0}, spread = 0, drift[3] = {0, 0, 0};
|
||||
char saved_pad[sizeof m->calib_pad] = "";
|
||||
int ended = 0, timed_out = 0, samples = 0;
|
||||
int ended = 0, timed_out = 0, samples = 0, settled = 0;
|
||||
uint64_t started = 0;
|
||||
plat_mutex_lock(&m->lock);
|
||||
double dt = m->last_ns && now > m->last_ns ? (double)(now - m->last_ns) / 1e9 : 0.004;
|
||||
if (dt > 0.05) dt = 0.004; // a gap (no controller, sensors were off): no integration across it
|
||||
if (dt > 0.05) { // a gap (no controller, sensors were off): no integration and no rest across it
|
||||
dt = 0.004;
|
||||
m->rest_s = 0;
|
||||
m->win_n = m->win_i = 0;
|
||||
}
|
||||
// Calibration: the player holds the controller still, so the raw gyro reads the bias. With the switch off an
|
||||
// attempt in progress is dropped.
|
||||
if (m->calibrating && !calib_on) {
|
||||
@@ -237,6 +356,14 @@ void motion_feed(MotionFusion *m, const double acc[3], const double gyro_raw[3],
|
||||
// The bias applies only while the switch is on; with no bias measured it is zero and the gyro passes unchanged.
|
||||
double gyro[3];
|
||||
for (int i = 0; i < 3; i++) gyro[i] = gyro_raw[i] - (calib_on ? m->gyro_bias[i] : 0);
|
||||
// A sample without a reading (a sensor just switched on reads zero) neither starts a frame nor counts as rest.
|
||||
const int reading = norm3(acc) >= 0.5;
|
||||
if (!auto_on) {
|
||||
if (m->drift_base >= 0) drift_clear(m);
|
||||
} else if (reading && (settled = drift_track(m, acc, gyro, calib_on, dt)))
|
||||
memcpy(drift, m->drift, sizeof drift);
|
||||
for (int i = 0; i < 3; i++) gyro[i] -= m->drift[i]; // zero while the switch is off
|
||||
if (m->restart && !reading) goto unlock; // no state yet; the logs below still run
|
||||
if (m->restart) {
|
||||
align_to(m->R, acc);
|
||||
memset(m->angle, 0, sizeof m->angle);
|
||||
@@ -253,9 +380,13 @@ void motion_feed(MotionFusion *m, const double acc[3], const double gyro_raw[3],
|
||||
for (int j = 0; j < 3; j++) s->dir[i * 3 + j] = (float)m->R[j][i]; // direction i = controller axis i in the reference frame
|
||||
}
|
||||
m->produced++;
|
||||
unlock:
|
||||
// The logs run with the lock released: the log back end can be slow, and the menu thread holds this lock in
|
||||
// motion_calib_poll.
|
||||
plat_mutex_unlock(&m->lock);
|
||||
if (settled)
|
||||
rt_log("motion: gyro drift at rest learned: %.5f %.5f %.5f rad/s, taken off %s", drift[0], drift[1], drift[2],
|
||||
calib_on ? "on top of the calibrated bias" : "the raw gyro");
|
||||
if (timed_out)
|
||||
rt_log("motion: gyro calibration timed out after %.1f s (%d samples): sensor data not arriving",
|
||||
(now - started) / 1e9, samples);
|
||||
@@ -322,6 +453,7 @@ void motion_bias_load(MotionFusion *m) {
|
||||
memcpy(m->gyro_bias, bias, sizeof bias);
|
||||
m->bias_valid = 1;
|
||||
m->calib_result = MOTION_CALIB_DONE;
|
||||
drift_clear(m);
|
||||
plat_mutex_unlock(&m->lock);
|
||||
}
|
||||
|
||||
@@ -335,6 +467,7 @@ void motion_bias_reset(MotionFusion *m) {
|
||||
m->calib_pad[0] = 0;
|
||||
m->calib_result = MOTION_CALIB_NONE;
|
||||
m->bias_valid = 0;
|
||||
drift_clear(m); // the drift belonged to that controller too
|
||||
plat_mutex_unlock(&m->lock);
|
||||
}
|
||||
|
||||
|
||||
+32
-2
@@ -7,6 +7,7 @@
|
||||
// raw-count angular deltas at its spherical-angle output instead. The aiming, scope, ability, horse and Purah Pad
|
||||
// cameras do the same at the angle each integrates from (camera_load). Ultrahand has a separate post-curve hook.
|
||||
// The other camera modes still take the mouse as stick, linear on both axes (mouse_stick_add).
|
||||
// A camera that runs none of these hooks gets the mouse as the right stick instead, through input.c (camera_unhooked).
|
||||
// The ordinary stick's result stays, so a controller still uses the game's own response.
|
||||
//
|
||||
// This is deliberately not a render-camera override: the game remains responsible for aiming, camera collision,
|
||||
@@ -64,10 +65,20 @@ static int hand_active(uint64_t now) {
|
||||
return last && now - last < 150000000ull;
|
||||
}
|
||||
|
||||
// Cameras no direct hook reaches. The hooks below (the free orbit's orbit_begin, every camera_load site, Ultrahand's
|
||||
// hand_input) mark each camera step they run in (step_hooked). A camera that runs none of them, such as Autobuild's
|
||||
// placement camera on games 1.4.3 and 1.2.1, reads its turn from input the hooks never see. After UNHOOKED_STEPS such
|
||||
// steps in a row the mouse leaves the direct path and acts as the right stick (input.c mouse_camera), as with
|
||||
// mouse_mode = stick, until a step runs a hook again.
|
||||
#define UNHOOKED_STEPS 2
|
||||
static volatile int32_t step_hooked, unhooked_steps;
|
||||
static void step_mark_hooked(void) { __atomic_store_n(&step_hooked, 1, __ATOMIC_RELAXED); }
|
||||
static int camera_unhooked(void) { return __atomic_load_n(&unhooked_steps, __ATOMIC_RELAXED) >= UNHOOKED_STEPS; }
|
||||
|
||||
int input_direct_mouse_active(void) {
|
||||
uint64_t last = __atomic_load_n(&last_update, __ATOMIC_ACQUIRE);
|
||||
return direct_mode() && (__atomic_load_n(&accepts_mouse, __ATOMIC_RELAXED) || hand_active(plat_now_ns())) && last &&
|
||||
plat_now_ns() - last < 150000000ull;
|
||||
plat_now_ns() - last < 150000000ull && !camera_unhooked();
|
||||
}
|
||||
|
||||
int input_direct_mouse_enabled(void) { return direct_mode(); }
|
||||
@@ -373,7 +384,19 @@ static void camera_input(Cpu *c) {
|
||||
memcpy(&next.pad[1], &c->v[10], sizeof(float));
|
||||
if (flags & 2) next.pad[0] = -next.pad[0];
|
||||
if (flags & 4) next.pad[1] = -next.pad[1];
|
||||
if (direct_mode()) {
|
||||
// The step before this one ran no direct hook: count it (camera_unhooked)
|
||||
int hooked = __atomic_exchange_n(&step_hooked, 0, __ATOMIC_RELAXED);
|
||||
int unhooked = hooked ? 0 : __atomic_load_n(&unhooked_steps, __ATOMIC_RELAXED) + (camera_unhooked() ? 0 : 1);
|
||||
if (direct_mode() && (unhooked >= UNHOOKED_STEPS) != camera_unhooked()) {
|
||||
static int lines;
|
||||
if (lines < 6) {
|
||||
lines++;
|
||||
rt_log(unhooked >= UNHOOKED_STEPS ? "mouse: the camera runs no direct hook; the mouse acts as the right stick"
|
||||
: "mouse: the camera runs a direct hook again; the mouse turns it directly");
|
||||
}
|
||||
}
|
||||
__atomic_store_n(&unhooked_steps, unhooked, __ATOMIC_RELAXED);
|
||||
if (direct_mode() && !camera_unhooked()) {
|
||||
int32_t dx, dy;
|
||||
input_direct_mouse_sample(!input_direct_mouse_selector_active() && (accept || hand_active(plat_now_ns())), &dx, &dy);
|
||||
float sensitivity = (float)cfg_double("TOTK_MOUSE_SENS");
|
||||
@@ -432,6 +455,10 @@ static void camera_input(Cpu *c) {
|
||||
rt_log("mouse: direct camera input after the stick dead zone, clamp and exponent");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Off the direct path (another mouse_mode, or a camera without a direct hook) no step follows a shake: a side
|
||||
// left set would hold input.c's right stick at full tilt
|
||||
__atomic_store_n(&shake_side, 0, __ATOMIC_RELAXED);
|
||||
}
|
||||
plat_mutex_lock(&sample_lock);
|
||||
MouseSample last = sample;
|
||||
@@ -463,6 +490,7 @@ static void orbit_begin(Cpu *c) {
|
||||
__atomic_store_n(&cam_kind_at, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
orbit.object = 0;
|
||||
uint64_t object = c->x[0];
|
||||
step_mark_hooked();
|
||||
if (direct_mode()) {
|
||||
MouseSample m = sample_read();
|
||||
uint64_t input = guest_pointer(object + 0x20);
|
||||
@@ -587,6 +615,7 @@ static void orbit_angles(Cpu *c) {
|
||||
static void hand_input(Cpu *c) {
|
||||
const MouseLayout *ml = mouse_layout();
|
||||
__atomic_store_n(&hand_update, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
step_mark_hooked();
|
||||
static _Thread_local uint64_t object, generation;
|
||||
if (direct_mode()) {
|
||||
MouseSample m = sample_read();
|
||||
@@ -1039,6 +1068,7 @@ static void camera_load(Cpu *c) {
|
||||
rt_log("mouse: load hook called from main+%#llx, no such site", (unsigned long long)offset);
|
||||
abort();
|
||||
}
|
||||
step_mark_hooked();
|
||||
int mapped = INPUT_CAM_UNCLASSIFIED;
|
||||
switch (s->mode) {
|
||||
case MODE_AIM:
|
||||
|
||||
@@ -49,8 +49,13 @@ uint64_t nvn_new_serial(void); // next tex_t / prog_
|
||||
// that assumption too early.
|
||||
void nvn_sync_ahead_present(void);
|
||||
uint64_t nvn_sync_ahead_guard(void);
|
||||
int nvn_sync_ahead_on(void); // 1 when the frame-ahead wait is in effect: TOTK_SYNC_AHEAD=1 and a wait site known for this version
|
||||
int vk_mem_shadow_on(void); // vk_memory.c: 1 with shadow storage on (valid once the Vulkan back end is up)
|
||||
int vk_mem_mirror_on(void); // vk_memory.c: 1 when pools used as buffers get VRAM mirrors (memory = mirror or auto on a discrete GPU)
|
||||
void vk_mem_shadow_fence(void); // vk_memory.c: returns once every shadow sync that read the old guard is done
|
||||
// vk_memory.c: the game is about to read [addr, addr+size) of pool storage; waits for a GPU write into it that the game
|
||||
// was told is done, unless the range still holds the result of the write before
|
||||
void vk_mem_shadow_read(uint64_t addr, uint64_t size);
|
||||
void gfx_replay_wait_value(uint64_t v); // vk_backend.c: the replay thread submitted value v
|
||||
uint64_t nvn_fence_last(void); // fence value of the newest submit (0 before the first)
|
||||
int nvn_depth_minus_w(void); // 1 after DeviceSetDepthMode(NEAR_IS_MINUS_W), else 0
|
||||
|
||||
+30
-10
@@ -30,6 +30,7 @@
|
||||
#define MIN_COMMAND_SIZE 512 // NVN_DEVICE_INFO_COMMAND_BUFFER_MIN_COMMAND_SIZE (nvn_api_core.c devinfo)
|
||||
#define MIN_CONTROL_SIZE 256 // NVN_DEVICE_INFO_COMMAND_BUFFER_MIN_CONTROL_SIZE
|
||||
#define CTL_PER_RECORDING 64 // control memory one recording is reported to use
|
||||
#define CTL_PER_CALL 24 // control memory one called handle is reported to use (CallCommands)
|
||||
#define COPY_PAGE_SHIFT 16 // recording copy index granularity (release_copies)
|
||||
|
||||
static cmd_t *cmd_of(const Cpu *c) { return arg_p(c, 0); }
|
||||
@@ -412,8 +413,9 @@ void nvn_pins_stats(uint64_t *live, uint64_t *freed) {
|
||||
// copies per page), and the recording threads waited on it.
|
||||
// deferred: 0 unknown, 1 none, 2 some; pins: texture pins its ops name, counted in their refs; pin_v: those pins, in
|
||||
// record order, or NULL (then pin_refs walks the records); cap: bytes of the block from the large-block cache
|
||||
// (copy_block), 0 for a plain heap block
|
||||
typedef struct { uint64_t magic, bytes, made_at, used_at, deferred, pins, cap; const tex_t **pin_v; } copy_prefix;
|
||||
// (copy_block), 0 for a plain heap block; hw: the recording's command memory as the real driver counts it (set at
|
||||
// EndRecording), what CopyCommands of it adds to nvnCommandBufferGetCommandMemoryUsed (inline_recording)
|
||||
typedef struct { uint64_t magic, bytes, made_at, used_at, deferred, pins, cap, hw; const tex_t **pin_v; } copy_prefix;
|
||||
_Static_assert(sizeof(copy_prefix) % 8 == 0, "records stay 8-byte aligned");
|
||||
typedef struct { uintptr_t lo, hi; uint8_t *copy; } cmd_copy;
|
||||
typedef struct { cmd_copy *v; uint32_t n, cap; } copy_bucket;
|
||||
@@ -573,11 +575,12 @@ uint64_t nvn_handle_bytes(uint64_t handle) {
|
||||
}
|
||||
|
||||
// Marks a live copy used by submission now; its size from OP_BEGIN to OP_END inclusive.
|
||||
static uint64_t copy_touch(uint64_t handle, uint64_t now, const char *what) {
|
||||
static uint64_t copy_touch(uint64_t handle, uint64_t now, const char *what, uint64_t *hw) {
|
||||
plat_mutex_lock_shared(©_lock);
|
||||
copy_prefix *pf = copy_find(handle);
|
||||
uint64_t bytes = 0;
|
||||
if (pf) __atomic_store_n(&pf->used_at, now, __ATOMIC_RELAXED), bytes = pf->bytes;
|
||||
if (hw) *hw = pf ? pf->hw : 0;
|
||||
plat_mutex_unlock_shared(©_lock);
|
||||
if (!pf) rt_fatal("nvn: %s: command handle %#llx is not a live recording (released or never recorded)", what,
|
||||
(unsigned long long)handle);
|
||||
@@ -731,6 +734,9 @@ NVN_API(nvnCommandBufferAddCommandMemory) {
|
||||
const pool_t *p = arg_p(c, 1);
|
||||
o->cmd_base = (uintptr_t)(p ? p->mem : NULL) + (uintptr_t)arg_x(c, 2);
|
||||
o->game_size = arg_x(c, 3);
|
||||
// Memory added while recording (the out-of-memory callback): hw_start moves with hw_used, so hw_used - hw_start
|
||||
// stays the whole recording's size at EndRecording (unsigned wrap-around cancels out).
|
||||
if (o->recording) o->hw_start -= o->hw_used;
|
||||
o->cmd_used = 0;
|
||||
o->hw_used = 0;
|
||||
}
|
||||
@@ -781,6 +787,7 @@ NVN_API(nvnCommandBufferEndRecording) {
|
||||
uintptr_t lo = (uintptr_t)o->ctl + (o->ctl_used < o->ctl_size ? o->ctl_used : 0);
|
||||
uintptr_t hi = o->ctl ? lo + 1 : 0;
|
||||
o->ctl_used += CTL_PER_RECORDING;
|
||||
((copy_prefix *)copy - 1)->hw = o->hw_used - o->hw_start; // BEGIN and END excluded; what a copy of it adds
|
||||
copy_add(lo, hi, copy);
|
||||
ret_x(c, (uintptr_t)copy);
|
||||
}
|
||||
@@ -789,32 +796,45 @@ NVN_API(nvnCommandBufferIsRecording) { ret_x(c, cmd_of(c)->recording != 0); }
|
||||
|
||||
// The called recording is copied into the caller at the call position: the game recycles command memory in small steps,
|
||||
// so a handle may be gone by the time the caller is submitted. Deferred binds stay deferred. A copy is OP_BEGIN, its
|
||||
// records and OP_END (flatten_recording checked them), so the records go over as one block; usage grows by the same
|
||||
// records and OP_END (flatten_recording checked them), so the records go over as one block; cmd_used grows by the same
|
||||
// bytes as record by record.
|
||||
static void inline_recording(cmd_t *o, uint64_t handle, const char *what) {
|
||||
// nvnCommandBufferGetCommandMemoryUsed grows as on the real driver: a call by nothing (the driver puts a call in
|
||||
// control memory, nvnCommandBufferCallCommands) and a copy by the copied recording's hardware size (copy_prefix.hw), not by our record bytes. The
|
||||
// game measures small command sets it records and sizes renderer memory pools from them: MacNativeGames commit 6909dbb7
|
||||
// measured one recording with two uniform buffer binds and one CallCommands at 40 bytes on the original driver
|
||||
// (Ryujinx, 1.0.0) and 88 in their port, whose larger sizes doubled a renderer's pool and ran its private heap dry
|
||||
// (NULL write crash near Zora's Domain). 1.4.3 calls in recordings it queries every frame (copies were not seen).
|
||||
static void inline_recording(cmd_t *o, uint64_t handle, int call) {
|
||||
const char *what = call ? "CallCommands" : "CopyCommands";
|
||||
if (!handle) rt_fatal("nvn: %s with a null handle", what);
|
||||
uint64_t bytes = copy_touch(handle, __atomic_load_n(&nsubmits, __ATOMIC_RELAXED), what);
|
||||
uint64_t hw = 0;
|
||||
uint64_t bytes = copy_touch(handle, __atomic_load_n(&nsubmits, __ATOMIC_RELAXED), what, &hw);
|
||||
if (bytes <= 16) return;
|
||||
size_t body = (size_t)bytes - 16;
|
||||
cmd_reserve(o, body);
|
||||
memcpy(o->cur, (const uint8_t *)(uintptr_t)handle + 8, body);
|
||||
o->cur += body;
|
||||
o->cmd_used += body;
|
||||
o->hw_used += body;
|
||||
if (!call) o->hw_used += hw;
|
||||
o->last_rec = 0;
|
||||
}
|
||||
// void nvnCommandBuffer{Call,Copy}Commands(NVNcommandBuffer *cmd, int n, const NVNcommandHandle *handles)
|
||||
// A call takes control memory instead: the game's inline copy of the driver's call (1.4.3 main+0x2d33a4, in the
|
||||
// function that measures a renderer's command set) writes one 24-byte control entry per segment of the called handle,
|
||||
// after an 8-byte block header. The game reads a buffer whose command and control usage are both 0 as empty
|
||||
// (main+0x83f8c clears bit 0 of its flags), so a buffer that only called recordings must show control usage.
|
||||
NVN_API(nvnCommandBufferCallCommands) {
|
||||
cmd_t *o = cmd_of(c);
|
||||
int n = (int)arg_x(c, 1);
|
||||
const uint64_t *h = arg_p(c, 2);
|
||||
for (int i = 0; i < n; i++) inline_recording(o, h[i], "CallCommands");
|
||||
for (int i = 0; i < n; i++) inline_recording(o, h[i], 1);
|
||||
if (n > 0) o->ctl_used += CTL_PER_CALL * (size_t)n;
|
||||
}
|
||||
NVN_API(nvnCommandBufferCopyCommands) {
|
||||
cmd_t *o = cmd_of(c);
|
||||
int n = (int)arg_x(c, 1);
|
||||
const uint64_t *h = arg_p(c, 2);
|
||||
for (int i = 0; i < n; i++) inline_recording(o, h[i], "CopyCommands");
|
||||
for (int i = 0; i < n; i++) inline_recording(o, h[i], 0);
|
||||
}
|
||||
|
||||
// ---------- CommandBuffer: commands with CPU-visible results (performed by the back end in GPU order)
|
||||
@@ -1285,7 +1305,7 @@ static int resolve_deferred(const uint8_t *p, int depth) { // returns the numb
|
||||
|
||||
void nvn_submit_prepare(const uint64_t *handles, int n) {
|
||||
uint64_t now = __atomic_add_fetch(&nsubmits, 1, __ATOMIC_RELAXED);
|
||||
for (int i = 0; i < n; i++) copy_touch(handles[i], now, "QueueSubmitCommands");
|
||||
for (int i = 0; i < n; i++) copy_touch(handles[i], now, "QueueSubmitCommands", NULL);
|
||||
for (int i = 0; i < n; i++) resolve_deferred((const uint8_t *)(uintptr_t)handles[i], 0);
|
||||
}
|
||||
|
||||
|
||||
+69
-26
@@ -15,6 +15,7 @@
|
||||
#include "host.h"
|
||||
#include "nvn_api.h"
|
||||
#include "nvn_pool_index.h"
|
||||
#include "vk_ahead.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define DEV_MAGIC MAGIC('D', 'E', 'V', 0)
|
||||
@@ -53,13 +54,19 @@ void nvn_guest_written(uint64_t addr, uint64_t size) {
|
||||
if (size) gfx_backend()->guest_written(addr, size);
|
||||
}
|
||||
|
||||
// The camera jitter of 1.4.3 (vk_dlaa.c); a weak default like the hooks below.
|
||||
void vk_dlaa_camera_copied(uint64_t lr, uint64_t dst, uint64_t off);
|
||||
__attribute__((weak)) void vk_dlaa_camera_copied(uint64_t lr, uint64_t dst, uint64_t off) { (void)lr, (void)dst, (void)off; }
|
||||
|
||||
// memcpy of pool storage the GPU rendered into must copy what the GPU wrote: TotK moves its generated grass maps
|
||||
// between pools with memcpy. Copies below 1 KiB skip the check; the copy itself is memmove, as overlapping
|
||||
// arguments are undefined for memcpy anyway.
|
||||
// arguments are undefined for memcpy anyway. TotK 1.4.3 copies its camera matrices with 64-byte memcpys
|
||||
// (f_70000e31d4); x8 holds the member's offset in the block there (vk_dlaa.c vk_dlaa_camera_copied).
|
||||
static void ov_memcpy(Cpu *c) {
|
||||
uint64_t dst = arg_x(c, 0), src = arg_x(c, 1), n = arg_x(c, 2);
|
||||
if (n >= 1024) gfx_backend()->guest_read(src, n);
|
||||
memmove((void *)(uintptr_t)dst, (const void *)(uintptr_t)src, n);
|
||||
if (n == 64) vk_dlaa_camera_copied(c->x[30], dst, c->x[8]);
|
||||
ret_x(c, dst);
|
||||
}
|
||||
HOST_OVERRIDE("memcpy", ov_memcpy);
|
||||
@@ -475,44 +482,66 @@ NVN_API(nvnQueueFenceSync) {
|
||||
// the frame it presented last; on the Switch that work is long done by then, here it is still in the replay and on the
|
||||
// GPU (about 11 ms from the submit), and the wait sets the frame time. With the switch on, that wait, and only that
|
||||
// one, waits for the frame before it instead. What the game reads back of GPU results after the wait can then be a
|
||||
// frame old. The game's CPU writes to memory the GPU still reads reach the GPU only through shadow copies, which are
|
||||
// queued for the GPU or wait (nvn_sync_ahead_guard). The wait still lasts until the replay thread submitted the asked
|
||||
// value, so no copy of that value itself picks up those writes. pa_fence: the newest fence at the latest present and
|
||||
// the one before, present thread only for writes. pa_guard: the newest value the game was told is done early.
|
||||
// frame old; a buffer that holds no older result is waited for when the game invalidates it (vk_memory.c
|
||||
// vk_mem_shadow_read). The wait still lasts until the replay thread submitted the asked value, so every copy the
|
||||
// replay makes of the game's memory at record time (uniform snapshots, CPU texture uploads, the staged mirror syncs)
|
||||
// holds the asked frame's bytes before the game writes the next. Two forms, by shadow storage:
|
||||
// - shadow on: the game's CPU writes to memory the GPU still reads reach the GPU only through shadow copies, which are
|
||||
// queued for the GPU or wait (nvn_sync_ahead_guard).
|
||||
// - shadow off (in place, Savage Wind's form): the GPU reads the game's own memory; the back end's guards (vk_ahead.c
|
||||
// vk_ahead_init) keep its GPU-timeline reads off memory the game writes after the wait, and a value whose result the
|
||||
// game reads at once (vk_ahead_oneshot: a one-off small target, a samples-passed report with
|
||||
// TOTK_SYNC_AHEAD_QUERIES) is waited for, only up to that value.
|
||||
// pa_fence: the newest fence at the latest present and the one before, present thread only for writes. pa_guard: the
|
||||
// newest value the game was told is done early.
|
||||
static uint64_t pa_fence[2], pa_guard;
|
||||
// The return address of that wait. 1.2.1: 0x7000b23dfc. 1.4.3: 0x70002db99c, the second of the two nvnSyncWait calls
|
||||
// in f_70002db8ac; like on 1.2.1 its sync comes from a two-entry ring indexed per frame, and the first call waits on
|
||||
// one object's sync behind a mode check. 0: no site known, the switch stays off.
|
||||
// The return address of that wait. 1.1.0: 0x7000b39aa4, 1.2.1: 0x7000b23dfc, 1.4.3: 0x70002db99c. The second
|
||||
// nvnSyncWait in 1.1.0 f_7000b39a00 and 1.4.3 f_70002db8ac uses the per-frame sync, like on 1.2.1; the first
|
||||
// call waits on one object's sync behind a mode check. 0: no site known, the switch stays off.
|
||||
static uint64_t frame_wait_lr(void) {
|
||||
if (rt_game_version == 110) return 0x7000b39aa4ull;
|
||||
return rt_game_version == 121 ? 0x7000b23dfcull : rt_game_version == 143 ? 0x70002db99cull : 0;
|
||||
}
|
||||
static int sync_ahead(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) {
|
||||
on = cfg_bool("TOTK_SYNC_AHEAD");
|
||||
// Without shadow storage the GPU reads the game's own memory, which the game writes ahead: nothing guards
|
||||
// that. The Vulkan back end sets the mode while it starts, before the game's first present or wait; the null
|
||||
// back end never does.
|
||||
if (on && !vk_mem_shadow_on()) {
|
||||
rt_log("nvn: TOTK_SYNC_AHEAD needs shadow storage (shadow = 1 in totk.ini or TOTK_SHADOW=1 on native Windows); "
|
||||
"the game waits for the GPU as before");
|
||||
// TOTK_SYNC_AHEAD=check (vk_ahead.c): the wait stays exact; the presents and the wait note what the one-frame-late
|
||||
// wait would have waited for, and the back end counts what that would have raced. sync_mode: 0 off, 1 on, 2 check.
|
||||
static int sync_mode(void) {
|
||||
static int mode = -1;
|
||||
if (mode < 0) {
|
||||
const char *v = cfg_value("TOTK_SYNC_AHEAD");
|
||||
int on = strcmp(v, "0") != 0 && strcmp(v, "check") != 0, check = !strcmp(v, "check");
|
||||
// In place (no shadow storage) the guards cover the VRAM mirrors' copies; with memory = import the GPU reads
|
||||
// vertex, index and storage data straight from the game's memory, and a check run (TOTK_MEMORY=import,
|
||||
// islands) saw the game rewrite ~10 KiB of them a frame after the wait, particles mostly.
|
||||
if (on && !vk_mem_shadow_on() && !vk_mem_mirror_on()) {
|
||||
rt_log("nvn: TOTK_SYNC_AHEAD needs shadow storage or the VRAM mirrors (memory = import reads the game's "
|
||||
"vertex and storage data in place); the game waits for the GPU as before");
|
||||
on = 0;
|
||||
}
|
||||
if (on && !frame_wait_lr()) {
|
||||
if ((on || check) && !frame_wait_lr()) {
|
||||
rt_log("nvn: TOTK_SYNC_AHEAD: no frame wait site is known for this game version; the game waits for the "
|
||||
"GPU as before");
|
||||
on = 0;
|
||||
on = check = 0;
|
||||
}
|
||||
if (on) rt_log("nvn: TOTK_SYNC_AHEAD: a wait for the frame presented last waits for the frame before it");
|
||||
// The depth query patch (set qstamp, patches-v143.txt) is switched by TOTK_SYNC_AHEAD too: a refused switch
|
||||
// leaves the game's own frame number check, as with the switch off.
|
||||
if (!on) rt_patch_switch(rt_patch_set("qstamp"), 0);
|
||||
// The Vulkan back end decides the mode while it starts (vk_memory.c mirror_mode), after it knows whether shadow
|
||||
// storage is on, before the game's first present or wait.
|
||||
if (on)
|
||||
rt_log("nvn: TOTK_SYNC_AHEAD: a wait for the frame presented last waits for the frame before it (%s)",
|
||||
vk_mem_shadow_on() ? "shadow storage" : "in place, with the back end's guards");
|
||||
mode = on ? 1 : check ? 2 : 0;
|
||||
}
|
||||
return on;
|
||||
return mode;
|
||||
}
|
||||
static int sync_ahead(void) { return sync_mode() == 1; }
|
||||
void nvn_sync_ahead_present(void) {
|
||||
if (!sync_ahead()) return;
|
||||
if (!sync_mode()) return;
|
||||
__atomic_store_n(&pa_fence[1], __atomic_load_n(&pa_fence[0], __ATOMIC_RELAXED), __ATOMIC_RELEASE);
|
||||
__atomic_store_n(&pa_fence[0], nvn_fence_last(), __ATOMIC_RELEASE);
|
||||
}
|
||||
uint64_t nvn_sync_ahead_guard(void) { return __atomic_load_n(&pa_guard, __ATOMIC_ACQUIRE); }
|
||||
int nvn_sync_ahead_on(void) { return sync_ahead(); }
|
||||
|
||||
// NVNsyncWaitResult nvnSyncWait(const NVNsync *s, uint64_t timeout_ns): a sync never fenced reports a timeout at once;
|
||||
// a fenced one is released only after the back end completed that fence value
|
||||
@@ -521,12 +550,22 @@ NVN_API(nvnSyncWait) {
|
||||
uint64_t timeout = arg_x(c, 1);
|
||||
if (!s->fenced) { ret_x(c, NVN_SYNC_WAIT_RESULT_TIMEOUT_EXPIRED); return; }
|
||||
const GfxBackend *b = gfx_backend();
|
||||
uint64_t want = s->fence;
|
||||
uint64_t want = s->fence, lag = s->fence;
|
||||
// Only the game's per-frame wait lags, and not a poll (timeout 0).
|
||||
if (timeout && c->x[30] == frame_wait_lr() && sync_ahead() && b->fence_done() < want) {
|
||||
int mode = timeout && c->x[30] == frame_wait_lr() ? sync_mode() : 0, behind = b->fence_done() < want;
|
||||
// The detector (vk_ahead.c): check mode, or the switch on with TOTK_SYNC_AHEAD_CHECK=1.
|
||||
int det = mode && vk_ahead_on;
|
||||
if (det) vk_ahead_frame_entry();
|
||||
// check: every frame as if the GPU were behind (the question is what the game writes, not this machine's timing)
|
||||
if (mode == 2 || (mode && behind)) {
|
||||
uint64_t p0 = __atomic_load_n(&pa_fence[0], __ATOMIC_ACQUIRE);
|
||||
uint64_t p1 = __atomic_load_n(&pa_fence[1], __ATOMIC_ACQUIRE);
|
||||
if (want <= p0 && want > p1) want = p1;
|
||||
if (want <= p0 && want > p1) lag = p1;
|
||||
if (mode == 1 && lag < want) { // a value in (lag, want] whose result the game reads at once: up to it
|
||||
uint64_t o = vk_ahead_oneshot(lag, want);
|
||||
if (o > lag) lag = o;
|
||||
}
|
||||
if (mode == 1) want = lag;
|
||||
}
|
||||
if (want != s->fence) { // the replay of the asked value is done first: the guard then covers every copy of it
|
||||
{
|
||||
@@ -539,7 +578,9 @@ NVN_API(nvnSyncWait) {
|
||||
vk_mem_shadow_fence(); // a shadow sync that read the old guard finishes before the game writes again
|
||||
}
|
||||
if (b->fence_done() >= want) {
|
||||
if (det) vk_ahead_frame_lag(s->fence, lag, behind);
|
||||
b->cpu_synced(want == s->fence ? s->fence : b->fence_done());
|
||||
if (det) vk_ahead_frame_done(1);
|
||||
ret_x(c, NVN_SYNC_WAIT_RESULT_ALREADY_SIGNALED);
|
||||
return;
|
||||
}
|
||||
@@ -548,7 +589,9 @@ NVN_API(nvnSyncWait) {
|
||||
NVN_BLOCKING();
|
||||
ok = b->fence_wait(want, timeout);
|
||||
}
|
||||
if (det) vk_ahead_frame_lag(s->fence, lag, behind);
|
||||
if (ok) b->cpu_synced(want == s->fence ? s->fence : b->fence_done());
|
||||
if (det) vk_ahead_frame_done(ok);
|
||||
ret_x(c, ok ? NVN_SYNC_WAIT_RESULT_CONDITION_SATISFIED : NVN_SYNC_WAIT_RESULT_TIMEOUT_EXPIRED);
|
||||
}
|
||||
// void nvnEventBuilderSetDefaults(NVNeventBuilder *b)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
void nvn_pool_invalidate(const pool_t *p, uint64_t off, uint64_t size) {
|
||||
if (!p->mem || nvn_gpu_only((uintptr_t)p->mem) || off >= p->size || !size) return;
|
||||
if (size > p->size - off) size = p->size - off;
|
||||
vk_mem_shadow_read((uintptr_t)p->mem + off, size);
|
||||
gfx_backend()->guest_read((uintptr_t)p->mem + off, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -770,6 +770,16 @@ static void probe_commands(void) {
|
||||
// adding the control memory again retires the recordings made in it
|
||||
CALL(nvnCommandBufferAddControlMemory, U(&cmd2), U(ctlmem2), 0x1000);
|
||||
CHECK(!nvn_handle_live(h2) && nvn_handle_live(h), "reusing control memory retires only the handles recorded in it");
|
||||
|
||||
// a buffer that only called a recording is not empty: the call takes control memory and no command memory
|
||||
CALL(nvnCommandBufferAddCommandMemory, U(&cmd2), U(&pool), 0x34000, 0x4000);
|
||||
CALL(nvnCommandBufferBeginRecording, U(&cmd2));
|
||||
CALL(nvnCommandBufferCallCommands, U(&cmd2), 1, U(&h));
|
||||
uint64_t used = CALL(nvnCommandBufferGetCommandMemoryUsed, U(&cmd2));
|
||||
uint64_t ctl_used = CALL(nvnCommandBufferGetControlMemoryUsed, U(&cmd2));
|
||||
CHECK(used == 0 && ctl_used > 0, "a call takes control memory only: command %llu, control %llu bytes",
|
||||
(unsigned long long)used, (unsigned long long)ctl_used);
|
||||
CALL(nvnCommandBufferEndRecording, U(&cmd2));
|
||||
CALL(nvnCommandBufferFinalize, U(&cmd2));
|
||||
probe_pins();
|
||||
n_objects += 5;
|
||||
|
||||
@@ -94,6 +94,7 @@ static void npad_states(Cpu *c, uint32_t want) {
|
||||
if (live) {
|
||||
s.attributes = ATTR_CONNECTED;
|
||||
input_poll(&s.buttons, &s.lx, &s.ly, &s.rx, &s.ry);
|
||||
quicksave_guest(c); // quick save and load call into the game here, between two of its own calls
|
||||
vk_reflex_marker(6, vk_reflex_frame()); // VK_LATENCY_MARKER_INPUT_SAMPLE_NV
|
||||
}
|
||||
*out = s;
|
||||
|
||||
+114
-4
@@ -244,6 +244,12 @@ static char *lang(void) {
|
||||
}
|
||||
|
||||
static void set_env(const char *name, const char *value) { plat_setenv(name, value); } // NULL removes it
|
||||
// A live setting read through a cfg_version cache: the environment wins, and the cfg_set (empty = the default) moves
|
||||
// the version so the cache reads it again.
|
||||
static void set_live(const char *name, const char *value) {
|
||||
set_env(name, value);
|
||||
cfg_set(name, value ? value : "");
|
||||
}
|
||||
|
||||
static void probe_oe(void) {
|
||||
char *keep_lang = cfg_get("TOTK_LANG") ? strdup(cfg_get("TOTK_LANG")) : NULL;
|
||||
@@ -523,6 +529,26 @@ static void probe_time(void) {
|
||||
static int near3(const float *v, double x, double y, double z, double tol) {
|
||||
return fabs(v[0] - x) <= tol && fabs(v[1] - y) <= tol && fabs(v[2] - z) <= tol;
|
||||
}
|
||||
// A gyro sample: rate plus noise. Uniform noise of half-width amp from a fixed LCG, so every run reads the same.
|
||||
static void noisy(const double rate[3], double amp, uint32_t *seed, double out[3]) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
*seed = *seed * 1664525u + 1013904223u;
|
||||
out[i] = rate[i] + amp * ((double)(*seed >> 8) / (1 << 24) * 2 - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Feed secs of samples at the sensor thread's 4 ms; returns the yaw (angle z, revolutions) the last state reads.
|
||||
static double feed_for(MotionFusion *m, const double acc[3], const double rate[3], double amp, uint32_t *seed,
|
||||
double secs, uint64_t *t) {
|
||||
MotionState s;
|
||||
double g[3];
|
||||
for (int i = 0; i < (int)(secs * 250 + 0.5); i++) {
|
||||
noisy(rate, amp, seed, g);
|
||||
motion_feed(m, acc, g, *t += 4000000);
|
||||
}
|
||||
return motion_read(m, &s, 1, *t + 1000000) == 1 ? s.angle[2] : NAN;
|
||||
}
|
||||
|
||||
static int at_rest(const MotionState *s) {
|
||||
return !s->attributes && !s->sampling && near3(s->acc, 0, 0, -1, 0) && near3(s->gyro, 0, 0, 0, 0) &&
|
||||
near3(s->dir, 1, 0, 0, 0) && near3(s->dir + 3, 0, 1, 0, 0) && near3(s->dir + 6, 0, 0, 1, 0);
|
||||
@@ -655,6 +681,87 @@ static void probe_feedback(uint32_t pid, uint32_t style) {
|
||||
fabs(ms[0].gyro[2] - bias[2] / (2 * M_PI)) < 1e-6,
|
||||
"calibration without samples: state %d after 1 s, %d after 6 s; after a reset the raw gyro passes", waiting,
|
||||
failed);
|
||||
// A sensor just switched on reads zero: the frame starts at the first reading, here standing on the bottom edge
|
||||
// (controller y up). Then the down is wrong by a quarter turn (laid flat without turning): a second held still
|
||||
// levels it to within 8 degrees.
|
||||
MotionFusion *u = motion_new();
|
||||
const double standing[3] = {0, -1, 0};
|
||||
motion_feed(u, still, still, t);
|
||||
int before = motion_read(u, ms, 16, t + 1000000);
|
||||
motion_feed(u, standing, still, t += 4000000);
|
||||
int first = motion_read(u, ms, 16, t + 1000000);
|
||||
int upright_y = first == 1 && near3(ms[0].dir + 3, 0, 0, 1, 0.01);
|
||||
for (int i = 0; i < 250; i++) motion_feed(u, down, still, t += 4000000);
|
||||
motion_read(u, ms, 16, t + 1000000);
|
||||
CHECK(before == 0 && upright_y && ms[0].dir[8] > 0.99,
|
||||
"fusion start and levelling: %d states before a reading, %d after (y up %d), z up %.3f after 1 s still",
|
||||
before, first, upright_y, (double)ms[0].dir[8]);
|
||||
|
||||
// Drift at rest (gyro_auto_bias). Table noise is +-0.006 rad/s, a hand's +-0.03; drift is the yaw rate a
|
||||
// controller lying still reads, in rad/s, over the 10 s after the tracker had 10 s to learn.
|
||||
char *keep_auto = cfg_get("TOTK_GYRO_AUTO_BIAS") ? strdup(cfg_get("TOTK_GYRO_AUTO_BIAS")) : NULL;
|
||||
char *keep_cal = cfg_get("TOTK_GYRO_CALIBRATION") ? strdup(cfg_get("TOTK_GYRO_CALIBRATION")) : NULL;
|
||||
set_live("TOTK_GYRO_CALIBRATION", "1");
|
||||
const double drift_b[3] = {0.02, -0.03, 0.05}, rev = 2 * M_PI;
|
||||
uint32_t seed = 1;
|
||||
double drift_rate[2];
|
||||
for (int on = 0; on < 2; on++) {
|
||||
set_live("TOTK_GYRO_AUTO_BIAS", on ? "1" : "0");
|
||||
MotionFusion *d = motion_new();
|
||||
uint64_t td = t;
|
||||
feed_for(d, down, drift_b, 0.006, &seed, 10, &td);
|
||||
double y0 = feed_for(d, down, drift_b, 0.006, &seed, 0.004, &td);
|
||||
drift_rate[on] = (feed_for(d, down, drift_b, 0.006, &seed, 10, &td) - y0) * rev / 10;
|
||||
}
|
||||
CHECK(fabs(drift_rate[0] - drift_b[2]) < 0.002 && fabs(drift_rate[1]) < 0.001,
|
||||
"drift at rest: yaw %.5f rad/s with gyro_auto_bias off, %.5f on (bias %.3f)", drift_rate[0], drift_rate[1],
|
||||
drift_b[2]);
|
||||
// The #1267 case: calibrated, then the bias moved by 0.01 rad/s (the controller warmed up). The tracker takes the
|
||||
// remainder on top of the calibrated bias, and a new calibration starts it over.
|
||||
MotionFusion *c = motion_new();
|
||||
uint64_t tc = t;
|
||||
motion_calibrate_start(c, "probe pad", tc);
|
||||
feed_for(c, down, drift_b, 0.006, &seed, 1.6, &tc);
|
||||
int cal = motion_calib_poll(c, tc);
|
||||
const double warm[3] = {drift_b[0], drift_b[1], drift_b[2] - 0.01};
|
||||
double c0 = feed_for(c, down, warm, 0.006, &seed, 0.004, &tc);
|
||||
double c_early = (feed_for(c, down, warm, 0.006, &seed, 0.5, &tc) - c0) * rev / 0.5;
|
||||
feed_for(c, down, warm, 0.006, &seed, 10, &tc);
|
||||
c0 = feed_for(c, down, warm, 0.006, &seed, 0.004, &tc);
|
||||
double c_late = (feed_for(c, down, warm, 0.006, &seed, 10, &tc) - c0) * rev / 10;
|
||||
CHECK(cal == MOTION_CALIB_DONE && fabs(c_early + 0.01) < 0.002 && fabs(c_late) < 0.001,
|
||||
"drift after calibration: state %d, yaw %.5f rad/s right after, %.5f once learned", cal, c_early, c_late);
|
||||
// In the hand: a slow aim, 0.05 rad/s (3 deg/s) of yaw with a hand's noise, for 10 s. Nothing is learned from it,
|
||||
// so the full turn reaches the game.
|
||||
MotionFusion *h = motion_new();
|
||||
uint64_t th = t;
|
||||
const double pan[3] = {0, 0, 0.05};
|
||||
double h0 = feed_for(h, down, pan, 0.03, &seed, 0.004, &th);
|
||||
double turned = (feed_for(h, down, pan, 0.03, &seed, 10, &th) - h0) * rev;
|
||||
CHECK(fabs(turned - 0.5) < 0.01, "slow aim in the hand: %.4f rad of the 0.5 turned", turned);
|
||||
// Levelling and drift together: the frame starts standing on the bottom edge, then the controller lies flat with
|
||||
// a bias on every axis. The bias tilts the fused down by bias / gain (0.05 / 4 rad, 0.7 degrees) until it is
|
||||
// learned; then the down is level, and yaw holds.
|
||||
MotionFusion *l = motion_new();
|
||||
uint64_t tl = t;
|
||||
feed_for(l, standing, drift_b, 0.006, &seed, 0.004, &tl);
|
||||
feed_for(l, down, drift_b, 0.006, &seed, 1, &tl);
|
||||
motion_read(l, ms, 1, tl + 1000000);
|
||||
double up_1s = ms[0].dir[8];
|
||||
feed_for(l, down, drift_b, 0.006, &seed, 10, &tl);
|
||||
double l0 = feed_for(l, down, drift_b, 0.006, &seed, 0.004, &tl);
|
||||
double l_rate = (feed_for(l, down, drift_b, 0.006, &seed, 10, &tl) - l0) * rev / 10;
|
||||
motion_read(l, ms, 1, tl + 1000000);
|
||||
CHECK(up_1s > 0.99 && ms[0].dir[8] > 0.99999 && fabs(l_rate) < 0.001,
|
||||
"levelling with drift: z up %.5f after 1 s, %.6f after 21 s, yaw %.5f rad/s", up_1s, (double)ms[0].dir[8],
|
||||
l_rate);
|
||||
printf("hid drift at rest: yaw %.5f rad/s off, %.5f on; after calibration %.5f, then %.5f; slow aim %.4f of 0.5 "
|
||||
"rad; levelled z %.5f, yaw %.5f rad/s\n",
|
||||
drift_rate[0], drift_rate[1], c_early, c_late, turned, up_1s, l_rate);
|
||||
set_live("TOTK_GYRO_AUTO_BIAS", keep_auto);
|
||||
set_live("TOTK_GYRO_CALIBRATION", keep_cal);
|
||||
free(keep_auto);
|
||||
free(keep_cal);
|
||||
printf("hid feedback: vibration handles %#x %#x, six-axis %#x, at rest when stopped; fusion quarter turn %.4f rev\n",
|
||||
vh[0], vh[1], sh[0], quarter);
|
||||
}
|
||||
@@ -895,11 +1002,14 @@ static void probe_fonts(void) {
|
||||
CHECK(got == sizeof head && size && size + 8 == (uint64_t)len, "shared font 0: size %llu, file %lld bytes",
|
||||
(unsigned long long)size, (long long)len);
|
||||
const uint8_t *p = (const uint8_t *)(uintptr_t)addr;
|
||||
CHECK(addr && !memcmp(p - 8, head, sizeof head) && ov_bfttf_size(p - 8, size + 8) == size,
|
||||
"shared font 0: the address is not 8 bytes into the BFTTF file");
|
||||
// The pl shared memory layout: the file's BFTTF header unchanged at Address - 8, the decoded sfnt font at Address.
|
||||
CHECK(addr && !memcmp(p - 8, head, 8) && ov_bfttf_size(head, size + 8) == size,
|
||||
"shared font 0: the address is not 8 bytes past the file's BFTTF header");
|
||||
CHECK(!memcmp(p, "\0\1\0\0", 4) || !memcmp(p, "OTTO", 4),
|
||||
"shared font 0: the data at the address is not plain sfnt: %02x %02x %02x %02x", p[0], p[1], p[2], p[3]);
|
||||
CHECK(CALL("pl.GetSharedFontAddress", 0) == addr, "shared font 0: the address changed");
|
||||
printf("pl: shared font 0 (Standard) at %#llx, %llu bytes, BFTTF header checked (%s)\n", (unsigned long long)addr,
|
||||
(unsigned long long)size, path);
|
||||
printf("pl: shared font 0 (Standard) at %#llx, %llu bytes, BFTTF header and decoded sfnt checked (%s)\n",
|
||||
(unsigned long long)addr, (unsigned long long)size, path);
|
||||
}
|
||||
|
||||
// The host catalog (ui_text.c): every menu id has its own English, Russian, Brazilian Portuguese and Simplified
|
||||
|
||||
+14
-4
@@ -775,10 +775,15 @@ static void ov_user_difference(Cpu *c) {
|
||||
|
||||
// ==== nn::pl shared fonts (shared_font.c). TotK asks for them only from its font loader, only with Simplified Chinese,
|
||||
// Korean or Traditional Chinese text, and only for type 0; tools/extract_fonts.py writes
|
||||
// them from the user's firmware. Each type is read on first use into guest-visible memory as the BFTTF file the pl
|
||||
// shared memory holds; Address is 8 bytes past the file start (after the BFTTF header) and Size the decoded font size,
|
||||
// as in MNG. The load state is always Loaded: the game spins until it is, so missing files stop with a named fatal at
|
||||
// Address/Size instead of a hang. TOTK_SHARED_FONTS=<dir> overrides <romfs>/../../firmware/shared-fonts.
|
||||
// them from the user's firmware. Each type is read on first use into guest-visible memory laid out as the pl shared
|
||||
// memory holds it: the file's 8-byte BFTTF header as it is, then the font decoded to plain sfnt data. Address is 8
|
||||
// bytes past the file start (after the header) and Size the decoded font size, as in MNG. The firmware file keeps the
|
||||
// font XOR-encoded, and the game cannot read it that way: its font loader takes the data at Address as a font when the
|
||||
// first word is an sfnt tag and otherwise hands it to nn::fontll::ScalableFontEngineHelper::Decode, which knows only
|
||||
// a BFTTF header at the start and returns NULL for an encoded payload. The face then gets no name, SetFont fails, and
|
||||
// the text draws the previous face's glyphs with the failed face's metrics (the CJK ellipsis above the line; MNG
|
||||
// shared_font.c load decodes the same way since its pull request #2145). The load state is always Loaded: the game
|
||||
// spins until it is, so missing files stop with a named fatal at Address/Size instead of a hang. TOTK_SHARED_FONTS=<dir> overrides <romfs>/../../firmware/shared-fonts.
|
||||
#define SHARED_FONT_TYPES 6
|
||||
#define BFTTF_MAGIC 0x7f9a0218u
|
||||
static const char *const font_files[SHARED_FONT_TYPES] = {
|
||||
@@ -840,6 +845,11 @@ static const uint8_t *font_data(Cpu *c, const char *fn, int64_t t) {
|
||||
fclose(f);
|
||||
uint64_t size = got == (size_t)len ? ov_bfttf_size(p, (uint64_t)len) : 0;
|
||||
if (!size) rt_fatal("nn::pl: shared font %s is not a BFTTF font", path);
|
||||
// Decode the font in place; the words are big-endian, so byte i of each word takes key byte i.
|
||||
uint32_t key = be32(p) ^ BFTTF_MAGIC;
|
||||
for (int64_t i = 8; i < len; i++) p[i] ^= (uint8_t)(key >> (24 - 8 * (i & 3)));
|
||||
if (memcmp(p + 8, "\0\1\0\0", 4) && memcmp(p + 8, "OTTO", 4))
|
||||
rt_fatal("nn::pl: shared font %s is not an sfnt font after decoding", path);
|
||||
fonts.size[t] = size;
|
||||
__atomic_store_n(&fonts.file[t], p, __ATOMIC_RELEASE);
|
||||
rt_log("pl: shared font %lld (%s): %llu bytes from %s", (long long)t, font_type_name(t),
|
||||
|
||||
+96
-10
@@ -8,6 +8,12 @@
|
||||
// code reaches it with one adrp, as MacNativeGames' data page after main (games/totk/runtime/game_patches.c). Its
|
||||
// layout belongs to the sets that use it (frame_rate.c: +0 the 30 Hz ratio, +4 the frame step in seconds, +8 the
|
||||
// step in 60 Hz ticks).
|
||||
//
|
||||
// Contested sites: a site that two or more ordered sets patch (the mods' ExeFS patch files, tools/exefs_patches.py)
|
||||
// tests one byte, rt_patch_pick[site], instead of each set's switch. rt_patch_picks fills it from the sets that are on
|
||||
// and the ranks their owner gave them (mods.c: the Mods tab's position), so the load order decides which mod's code
|
||||
// runs there, as it decides RomFS files and data writes. Generic over what owns a set: a part kind that patches code
|
||||
// (stage 2's plugin hooks) ranks its sets the same way.
|
||||
// Probe modes never call rt_patches_init: every set stays off.
|
||||
#include "cfg.h"
|
||||
#include "platform/platform.h"
|
||||
@@ -24,8 +30,12 @@
|
||||
#ifndef RT_PATCH_COUNT
|
||||
#define RT_PATCH_COUNT 0
|
||||
#endif
|
||||
#ifndef RT_PATCH_PICK_COUNT
|
||||
#define RT_PATCH_PICK_COUNT 0
|
||||
#endif
|
||||
|
||||
uint8_t rt_patch_on[RT_PATCH_COUNT > 0 ? RT_PATCH_COUNT : 1]; // read by the generated C at every patched site
|
||||
uint8_t rt_patch_pick[RT_PATCH_PICK_COUNT > 0 ? RT_PATCH_PICK_COUNT : 1]; // read at every contested site
|
||||
|
||||
#if RT_PATCH_COUNT
|
||||
static const struct { const char *name, *env; int on; } sets[] = {
|
||||
@@ -35,6 +45,26 @@ static const struct { const char *name, *env; int on; } sets[] = {
|
||||
};
|
||||
static void *page;
|
||||
#endif
|
||||
#if RT_PATCH_PICK_COUNT
|
||||
#define X(i, m, o, ...) static const int16_t pick_sets_##i[] = {__VA_ARGS__};
|
||||
RT_PATCH_PICKS(X)
|
||||
#undef X
|
||||
static const RtPatchPick gen_picks[] = {
|
||||
#define X(i, m, o, ...) {m, o, pick_sets_##i, (int)(sizeof pick_sets_##i / sizeof *pick_sets_##i)},
|
||||
RT_PATCH_PICKS(X)
|
||||
#undef X
|
||||
};
|
||||
#else
|
||||
static const RtPatchPick *const gen_picks = NULL;
|
||||
#endif
|
||||
static uint16_t gen_rank[RT_PATCH_COUNT > 0 ? RT_PATCH_COUNT : 1]; // rank + 1; 0 unranked
|
||||
|
||||
// The table in use: the generated one, or --probe-mods' own (rt_patch_probe_table).
|
||||
static int nset = RT_PATCH_COUNT, npick = RT_PATCH_PICK_COUNT;
|
||||
static uint8_t *on = rt_patch_on, *pick = rt_patch_pick;
|
||||
static uint16_t *rank = gen_rank;
|
||||
static const RtPatchPick *picks = gen_picks;
|
||||
static const char *const *probe_names;
|
||||
|
||||
void rt_patches_init(void) {
|
||||
#if RT_PATCH_COUNT
|
||||
@@ -53,26 +83,82 @@ void rt_patches_init(void) {
|
||||
if (n >= sizeof list) n = sizeof list - 1;
|
||||
}
|
||||
rt_log("patches: %s (page %#llx)", list, RT_PATCH_PAGE);
|
||||
rt_patch_picks(); // a set the environment switched on runs at its sites, unranked
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *rt_patch_name(int set) {
|
||||
if (set < 0 || set >= nset) return NULL;
|
||||
if (probe_names) return probe_names[set];
|
||||
#if RT_PATCH_COUNT
|
||||
return sets[set].name;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
int rt_patch_set(const char *name) {
|
||||
#if RT_PATCH_COUNT
|
||||
for (int i = 0; i < RT_PATCH_COUNT; i++)
|
||||
if (!strcmp(sets[i].name, name)) return i;
|
||||
#endif
|
||||
(void)name;
|
||||
for (int i = 0; i < nset; i++)
|
||||
if (!strcmp(rt_patch_name(i), name)) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rt_patch_enabled(int set) { return set >= 0 && set < RT_PATCH_COUNT && rt_patch_on[set]; }
|
||||
int rt_patch_enabled(int set) { return set >= 0 && set < nset && on[set]; }
|
||||
|
||||
void rt_patch_disable(int set) {
|
||||
if (set >= 0 && set < RT_PATCH_COUNT) rt_patch_on[set] = 0;
|
||||
// The place in p's sets of the one that runs: on, the lowest rank, a tie to the later one; -1 when none is on.
|
||||
static int winner(const RtPatchPick *p) {
|
||||
int best = -1;
|
||||
unsigned best_key = 0;
|
||||
for (int j = 0; j < p->nsets; j++) {
|
||||
int s = p->sets[j];
|
||||
if (s < 0 || s >= nset || !on[s]) continue;
|
||||
unsigned key = rank[s] ? rank[s] : 0x10000u;
|
||||
if (best < 0 || key <= best_key) best = j, best_key = key;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
void rt_patch_switch(int set, int on) {
|
||||
if (set >= 0 && set < RT_PATCH_COUNT) __atomic_store_n(&rt_patch_on[set], (uint8_t)(on != 0), __ATOMIC_RELAXED);
|
||||
// The picks of the contested sites set touches (every site for -1).
|
||||
static void repick(int set) {
|
||||
for (int i = 0; i < npick; i++) {
|
||||
int has = set < 0;
|
||||
for (int j = 0; !has && j < picks[i].nsets; j++) has = picks[i].sets[j] == set;
|
||||
if (has) __atomic_store_n(&pick[i], (uint8_t)(winner(&picks[i]) + 1), __ATOMIC_RELAXED);
|
||||
}
|
||||
}
|
||||
|
||||
void rt_patch_disable(int set) {
|
||||
if (set >= 0 && set < nset) on[set] = 0;
|
||||
repick(set);
|
||||
}
|
||||
|
||||
void rt_patch_switch(int set, int value) {
|
||||
if (set < 0 || set >= nset) return;
|
||||
__atomic_store_n(&on[set], (uint8_t)(value != 0), __ATOMIC_RELAXED);
|
||||
repick(set);
|
||||
}
|
||||
|
||||
void rt_patch_rank(int set, int r) {
|
||||
if (set >= 0 && set < nset) rank[set] = (uint16_t)(r < 0 ? 1 : r > 0xFFFE ? 0xFFFF : r + 1);
|
||||
}
|
||||
|
||||
void rt_patch_picks(void) { repick(-1); }
|
||||
int rt_patch_pick_count(void) { return npick; }
|
||||
const RtPatchPick *rt_patch_pick_at(int i) { return i >= 0 && i < npick ? &picks[i] : NULL; }
|
||||
int rt_patch_pick_winner(int i) { return i >= 0 && i < npick ? (int)__atomic_load_n(&pick[i], __ATOMIC_RELAXED) - 1 : -1; }
|
||||
|
||||
void rt_patch_probe_table(const char *const *names, int n, const RtPatchPick *p, int np) {
|
||||
if (probe_names) {
|
||||
free(on);
|
||||
free(pick);
|
||||
free(rank);
|
||||
}
|
||||
probe_names = NULL;
|
||||
nset = RT_PATCH_COUNT, npick = RT_PATCH_PICK_COUNT;
|
||||
on = rt_patch_on, pick = rt_patch_pick, rank = gen_rank, picks = gen_picks;
|
||||
if (!names) return;
|
||||
on = calloc((size_t)n + 1, 1), pick = calloc((size_t)np + 1, 1), rank = calloc((size_t)n + 1, sizeof *rank);
|
||||
probe_names = names, nset = n, npick = np, picks = p;
|
||||
}
|
||||
|
||||
void *rt_patch_page(void) {
|
||||
|
||||
@@ -379,6 +379,17 @@ static inline char *plat_last_sep(const char *path) {
|
||||
if (*p == '/' || *p == '\\') last = (char *)p;
|
||||
return last;
|
||||
}
|
||||
// 1 when path does not depend on the working directory: it starts with a separator (a root or UNC path) or, on
|
||||
// Windows, with a drive letter and a separator.
|
||||
static inline int plat_path_absolute(const char *path) {
|
||||
if (path[0] == '/' || path[0] == '\\') return 1;
|
||||
#ifdef _WIN32
|
||||
char c = path[0];
|
||||
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) && path[1] == ':' && (path[2] == '/' || path[2] == '\\');
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
// Environment variable as UTF-8 into out; its length, or 0 when unset, empty or too long for cap.
|
||||
size_t plat_getenv(const char *name, char *out, size_t cap);
|
||||
// The user's UI language as a BCP-47 tag ("ru-RU", "en-US"); "" when the system gives none. Valid for the process.
|
||||
|
||||
@@ -0,0 +1,703 @@
|
||||
// Mod plugins' inits (recomp/layout.py plugin<N>, an exlaunch plugin such as a mod's exefs/subsdk9), run natively on
|
||||
// this runtime's own kernel and sdk. The design follows #845 by itaskaev2, with the init run natively instead of under
|
||||
// Unicorn, and run again at every start instead of an image taken after one run at build time.
|
||||
//
|
||||
// The service run: totk.exe --plugin-init DIR runs the plugins' DT_INITs, records what the inits did and exits before
|
||||
// any game module's constructor, nnMain, graphics or audio. TOTK_PLUGIN_ONLY names the one plugin module whose init
|
||||
// runs ("-": none); the others stay loaded, as they are at play. tools/exefs_plugins.py runs each plugin on its own,
|
||||
// so a plugin that is refused, crashes or hangs costs only itself; it checks each record and writes the plugin's patch
|
||||
// set (its hook sites, recomp/patches.py `plugin` lines).
|
||||
//
|
||||
// At every start (plugins_start, from the module-init callback in boot.c): when the build has a plugin whose patch set
|
||||
// its mod switched on, sdk's DT_INIT runs first, then the plugin's, in the same environment as in the service run, and
|
||||
// then the game's constructors. That is the order of the Switch's rtld, which runs the modules' DT_INITs from the last
|
||||
// loaded to the first (oss-rtld, librtld/source/ld.cpp __rtld_modules_init walks g_pAutoLoadList backwards; the list is
|
||||
// filled in address order by __rtld_relocate_modules in librtld/source/relocation.cpp: main, subsdk*, sdk), so sdk
|
||||
// runs before a subsdk plugin and the plugin before the game's main. The plugin keeps what its init made: heap blocks,
|
||||
// its GOT, its alias addresses. What the init wrote into the game modules (its hook branches) and the plugin's .text
|
||||
// after it (its stubs and trampolines) are compared with the record the build used (patches.h RT_PLUGIN_WRITES and
|
||||
// RT_PLUGINS): equal, the plugin's set stays on and the generated hook sites call into it; different, the set goes off
|
||||
// for this run, the reason is logged and the mod waits for a rebuild (mods.c mods_plugin_off). Each plugin is compared
|
||||
// right after its own init, and the branches it wrote into main's .text are taken back before the next init: the next
|
||||
// plugin sees the game's own bytes, as in its own service run (two plugins hooking one site each relocate the game's
|
||||
// instruction; the generated site runs the one the Mods tab order picks). The lifted code is the code that runs, and
|
||||
// main keeps the game's bytes.
|
||||
// Without a plugin in the build none of this runs (RT_PLUGIN_COUNT 0).
|
||||
//
|
||||
// What exlaunch's init needs from the process, and how this run gives it:
|
||||
// - Its module walk (exl::util::FindModules) reads QueryMemory from 0 up and takes every Code RX, Code R, CodeData
|
||||
// RW run as a module, the first being rtld and the second main. Our layout has no rtld and reports the host's
|
||||
// ranges as Code RX (memory.c taken_gap), which would make it take a gap for a module. mem_query_hook shows the
|
||||
// game's own rtld NSO (exefs/rtld, read, never run) right below main, and the host's ranges as Inaccessible.
|
||||
// - It picks a random free range in the ASLR region (GetSystemTick seeds it) for its process-memory aliases. Our
|
||||
// ASLR region is almost all host ranges, so a free pool of POOL_SIZE is reserved after the alias region.
|
||||
// - GetInfo 65001 (svc.c) gives it the current process handle; MapProcessMemory maps main's .text and its own pages
|
||||
// at the picked address. Guest addresses are host addresses and the modules are not file-backed, so an alias is a
|
||||
// copy: its pages hold the source's bytes when mapped, and the words written through it are written into the
|
||||
// source when it is unmapped and when the init returns. That is how the stubs reach the plugin's image and the
|
||||
// hook branches reach main's .text.
|
||||
// - nn::oe::GetDisplayVersion is answered with this build's game version, so the plugin picks its table for the
|
||||
// installed game without the applet services.
|
||||
// Only svcs the init needs are allowed (QueryMemory, GetSystemTick, OutputDebugString, GetInfo 2-5, 12-15 and 65001,
|
||||
// Map/UnmapProcessMemory); any other one, such as CreateSession and ReplyAndReceive of exlaunch's process-handle
|
||||
// fallback, ends the run with the reason in the record.
|
||||
//
|
||||
// The record, in DIR: record.json (modules, which plugins' inits ran, the writes into every game module as words, the
|
||||
// alias calls, svc and import counts, the tick offset, a refusal), plugin<N>.img (the plugin's image after its init,
|
||||
// all segments) and plugin<N>.pre.img (the same after loading and relocation, before the init).
|
||||
// TOTK_PLUGIN_TICK_OFFSET adds to every GetSystemTick, so two runs pick different aliases.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "dispatch.h"
|
||||
#include "host.h"
|
||||
#include "kernel.h"
|
||||
#include "mods.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#if __has_include("patches.h")
|
||||
#include "patches.h"
|
||||
#endif
|
||||
#ifndef RT_PLUGIN_COUNT
|
||||
#define RT_PLUGIN_COUNT 0
|
||||
#endif
|
||||
|
||||
#define PAGE 0x1000ull
|
||||
#define GiB (1ull << 30)
|
||||
#define POOL_SIZE (64 * GiB)
|
||||
#define POOL_ALIGN (4 * GiB)
|
||||
#define RTLD_ALIGN 0x200000ull
|
||||
#define MAX_ALIASES 256
|
||||
#define MAX_IMPORTS 64
|
||||
#define CUR_PROCESS 0xFFFF8001u
|
||||
// Horizon memory states and permissions of QueryMemory, and results.
|
||||
enum { ST_FREE = 0, ST_CODE = 3, ST_CODEDATA = 4, ST_SHARED_CODE = 0xF, ST_INACCESSIBLE = 0x10 };
|
||||
enum { PERM_R = 1, PERM_RW = 3, PERM_RX = 5 };
|
||||
#define R_OK 0u
|
||||
#define R_INVALID_ADDRESS 0xcc01u
|
||||
#define R_INVALID_STATE 0xd401u
|
||||
#define R_INVALID_HANDLE 0xe401u
|
||||
#define R_LIMIT_REACHED 0x10801u
|
||||
#define SYM_DISPLAY_VERSION "_ZN2nn2oe17GetDisplayVersionEPNS0_14DisplayVersionE"
|
||||
|
||||
typedef struct {
|
||||
uint64_t dst, src, size;
|
||||
uint8_t *snap; // the source's bytes when mapped: the words that differ from it were written through the alias
|
||||
int live, unmapped;
|
||||
} Alias;
|
||||
static Alias aliases[MAX_ALIASES];
|
||||
static int naliases;
|
||||
static uint64_t rtld_base, rtld_size, rtld_text_end, rtld_data_off;
|
||||
static uint64_t pool_base;
|
||||
static int running; // a plugin's init runs: svcs and imports are counted
|
||||
static int play; // plugins_start: a refused SVC fails the plugin instead of ending the process
|
||||
static char failed[256]; // play: why the running init was refused
|
||||
static uint64_t svc_count[0x80], info_count[16], info_65001;
|
||||
static struct { const char *name; uint64_t calls; } imports[MAX_IMPORTS];
|
||||
static int nimports;
|
||||
static uint8_t **pre; // per loaded module: its image before the plugins' inits
|
||||
static uint8_t *ran; // service run, per loaded module: its init ran
|
||||
|
||||
static uint64_t align_up(uint64_t v, uint64_t a) { return (v + a - 1) & ~(a - 1); }
|
||||
|
||||
static void clip(uint64_t a, uint64_t *lo, uint64_t *hi, uint64_t b, uint64_t n) {
|
||||
if (!n) return;
|
||||
uint64_t e = b + n;
|
||||
if (e <= a && e > *lo) *lo = e;
|
||||
if (b > a && b < *hi) *hi = b;
|
||||
}
|
||||
|
||||
static void clip_aliases(uint64_t a, uint64_t *lo, uint64_t *hi) {
|
||||
for (int i = 0; i < naliases; i++)
|
||||
if (aliases[i].live) clip(a, lo, hi, aliases[i].dst, aliases[i].size);
|
||||
}
|
||||
|
||||
static int in_module(uint64_t a) {
|
||||
for (int i = 0; i < ldr_count(); i++)
|
||||
if (a - ldr_module(i)->base < ldr_module(i)->size) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---- QueryMemory as exlaunch expects it (memory.c mem_query_hook)
|
||||
static void query_hook(uint64_t a, RtMemoryInfo *r) {
|
||||
for (int i = 0; i < naliases; i++) {
|
||||
const Alias *al = &aliases[i];
|
||||
if (al->live && a - al->dst < al->size) {
|
||||
*r = (RtMemoryInfo){.base = al->dst, .size = al->size, .state = ST_SHARED_CODE, .perm = PERM_RW};
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (a - rtld_base < rtld_size) {
|
||||
uint64_t off = a - rtld_base, text = align_up(rtld_text_end, PAGE);
|
||||
if (off < text) *r = (RtMemoryInfo){.base = rtld_base, .size = text, .state = ST_CODE, .perm = PERM_RX};
|
||||
else if (off < rtld_data_off)
|
||||
*r = (RtMemoryInfo){.base = rtld_base + text, .size = rtld_data_off - text, .state = ST_CODE, .perm = PERM_R};
|
||||
else
|
||||
*r = (RtMemoryInfo){.base = rtld_base + rtld_data_off, .size = rtld_size - rtld_data_off,
|
||||
.state = ST_CODEDATA, .perm = PERM_RW};
|
||||
return;
|
||||
}
|
||||
uint64_t lo = r->base, hi = r->base + r->size;
|
||||
if (a - pool_base < POOL_SIZE) {
|
||||
lo = pool_base, hi = pool_base + POOL_SIZE;
|
||||
*r = (RtMemoryInfo){.state = ST_FREE};
|
||||
} else if (r->state == ST_CODE && !in_module(a)) { // a host range (memory.c taken_gap)
|
||||
clip(a, &lo, &hi, rtld_base, rtld_size);
|
||||
clip(a, &lo, &hi, pool_base, POOL_SIZE);
|
||||
*r = (RtMemoryInfo){.state = ST_INACCESSIBLE};
|
||||
} else if (r->state != ST_FREE) {
|
||||
return;
|
||||
}
|
||||
clip_aliases(a, &lo, &hi);
|
||||
r->base = lo;
|
||||
r->size = hi - lo;
|
||||
}
|
||||
|
||||
// ---- Map/UnmapProcessMemory (svc.c rt_process_memory)
|
||||
static const RtLoaded *module_holding(uint64_t a, uint64_t n) {
|
||||
for (int i = 0; i < ldr_count(); i++) {
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
if (a >= m->base && n <= m->size && a - m->base <= m->size - n) return m;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Writes the words changed through an alias into its source. The source's read-only pages (sealed .text and .rodata)
|
||||
// are made writable for the copy and sealed again.
|
||||
static void flush(Alias *al) {
|
||||
const RtLoaded *m = module_holding(al->src, al->size);
|
||||
const uint8_t *now = (const uint8_t *)(uintptr_t)al->dst;
|
||||
for (uint64_t off = 0; off < al->size; off += PAGE) {
|
||||
if (!memcmp(now + off, al->snap + off, PAGE)) continue;
|
||||
uint64_t page = al->src + off;
|
||||
int sealed = page - m->base < m->data_off;
|
||||
if (sealed && !plat_mem_protect(page, PAGE, PLAT_PROT_RW)) rt_fatal("plugin-init: cannot unseal %#llx", (unsigned long long)page);
|
||||
for (uint64_t w = 0; w < PAGE; w += 4)
|
||||
if (memcmp(now + off + w, al->snap + off + w, 4)) memcpy((void *)(uintptr_t)(page + w), now + off + w, 4);
|
||||
if (sealed && !plat_mem_protect(page, PAGE, PLAT_PROT_READ)) rt_fatal("plugin-init: cannot seal %#llx", (unsigned long long)page);
|
||||
}
|
||||
memcpy(al->snap, now, al->size); // flushed: a later flush writes only what changes after this one
|
||||
}
|
||||
|
||||
static uint32_t process_memory(int unmap, uint64_t dst, uint32_t process, uint64_t src, uint64_t size) {
|
||||
if (process != CUR_PROCESS) return R_INVALID_HANDLE;
|
||||
if (!size || ((dst | src | size) & (PAGE - 1))) return R_INVALID_ADDRESS;
|
||||
if (unmap) {
|
||||
for (int i = 0; i < naliases; i++) {
|
||||
Alias *al = &aliases[i];
|
||||
if (!al->live || al->dst != dst || al->src != src || al->size != size) continue;
|
||||
flush(al);
|
||||
if (!plat_mem_decommit(dst, size)) rt_fatal("plugin-init: cannot unmap the alias at %#llx", (unsigned long long)dst);
|
||||
free(al->snap);
|
||||
al->snap = NULL;
|
||||
al->live = 0;
|
||||
al->unmapped = 1;
|
||||
return R_OK;
|
||||
}
|
||||
return R_INVALID_STATE;
|
||||
}
|
||||
if (!module_holding(src, size)) return R_INVALID_STATE; // only the modules' own memory
|
||||
RtMemoryInfo q;
|
||||
mem_query(dst, &q);
|
||||
if (q.state != ST_FREE || dst + size > q.base + q.size) return R_INVALID_STATE;
|
||||
if (naliases == MAX_ALIASES) return R_LIMIT_REACHED;
|
||||
if (!plat_mem_commit(dst, size)) return R_INVALID_STATE; // not inside one of our reservations
|
||||
Alias *al = &aliases[naliases];
|
||||
al->snap = malloc(size);
|
||||
if (!al->snap) rt_fatal("plugin-init: out of memory for a %#llx byte alias", (unsigned long long)size);
|
||||
memcpy((void *)(uintptr_t)dst, (const void *)(uintptr_t)src, size);
|
||||
memcpy(al->snap, (const void *)(uintptr_t)src, size);
|
||||
*al = (Alias){dst, src, size, al->snap, 1, 0};
|
||||
naliases++;
|
||||
return R_OK;
|
||||
}
|
||||
|
||||
// ---- svcs and imports
|
||||
static void write_record(const char *refused);
|
||||
|
||||
static void refuse(const char *why) {
|
||||
rt_log("plugin-init: refused: %s", why);
|
||||
if (play) { // the init goes on with an error result; the plugin stays off (plugins_start)
|
||||
if (!failed[0]) snprintf(failed, sizeof failed, "%s", why);
|
||||
return;
|
||||
}
|
||||
write_record(why);
|
||||
fflush(NULL);
|
||||
plat_exit(3);
|
||||
}
|
||||
|
||||
#define R_NOT_IMPLEMENTED 0xF601u
|
||||
|
||||
static int plugin_svc(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
if (!running) return 0;
|
||||
svc_count[imm & 0x7F]++;
|
||||
char why[256], at[128];
|
||||
switch (imm) {
|
||||
case 0x06: case 0x1E: case 0x27: case 0x74: case 0x75: return 0;
|
||||
case 0x29: {
|
||||
uint32_t id = (uint32_t)c->x[1];
|
||||
if ((id >= 2 && id <= 5) || (id >= 12 && id <= 15)) {
|
||||
info_count[id]++;
|
||||
return 0;
|
||||
}
|
||||
if (id == 65001) {
|
||||
info_65001++;
|
||||
return 0;
|
||||
}
|
||||
snprintf(why, sizeof why, "GetInfo id %u at %s", id, ldr_describe(pc, at, sizeof at));
|
||||
refuse(why);
|
||||
c->x[0] = R_NOT_IMPLEMENTED;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
snprintf(why, sizeof why, "svc %#x at %s (only QueryMemory, GetSystemTick, OutputDebugString, GetInfo 2-5, 12-15 "
|
||||
"and 65001, Map/UnmapProcessMemory are served)", imm, ldr_describe(pc, at, sizeof at));
|
||||
refuse(why);
|
||||
c->x[0] = R_NOT_IMPLEMENTED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Every JUMP_SLOT import of a plugin binds here (loader.c resolve): counted by name, then the guest definition runs,
|
||||
// except nn::oe::GetDisplayVersion, which gets this build's game version.
|
||||
static void plugin_import(Cpu *c) {
|
||||
const char *name = hostfn_name(c->pc);
|
||||
int i = 0;
|
||||
while (i < nimports && strcmp(imports[i].name, name)) i++;
|
||||
if (i == nimports && nimports < MAX_IMPORTS) imports[nimports++].name = name;
|
||||
if (i < MAX_IMPORTS && running) imports[i].calls++;
|
||||
if (!strcmp(name, SYM_DISPLAY_VERSION)) { // DisplayVersion { char value[16]; }
|
||||
char v[16] = {0};
|
||||
snprintf(v, sizeof v, "%d.%d.%d", rt_game_version / 100, rt_game_version / 10 % 10, rt_game_version % 10);
|
||||
memcpy((void *)(uintptr_t)c->x[0], v, sizeof v);
|
||||
return;
|
||||
}
|
||||
rt_original(c);
|
||||
}
|
||||
|
||||
// ---- the record
|
||||
static FILE *open_out(const char *file, const char *mode) {
|
||||
char path[PLAT_PATH_MAX];
|
||||
snprintf(path, sizeof path, "%s/%s", rt_config()->plugin_init, file);
|
||||
FILE *f = fopen(path, mode);
|
||||
if (!f) rt_fatal("plugin-init: cannot write %s", path);
|
||||
return f;
|
||||
}
|
||||
|
||||
static void write_image(const char *file, const void *p, uint64_t n) {
|
||||
FILE *f = open_out(file, "wb");
|
||||
if (fwrite(p, 1, n, f) != n || fclose(f)) rt_fatal("plugin-init: cannot write %s", file);
|
||||
}
|
||||
|
||||
static void sha256_hex(const void *p, uint64_t n, char out[65]) {
|
||||
uint8_t d[32];
|
||||
rt_sha256(p, n, d);
|
||||
for (int i = 0; i < 32; i++) snprintf(out + 2 * i, 3, "%02x", d[i]);
|
||||
}
|
||||
|
||||
static void json_str(FILE *f, const char *s) {
|
||||
fputc('"', f);
|
||||
for (; *s; s++) {
|
||||
if (*s == '"' || *s == '\\') fputc('\\', f);
|
||||
if ((unsigned char)*s < 0x20) fprintf(f, "\\u%04x", *s);
|
||||
else fputc(*s, f);
|
||||
}
|
||||
fputc('"', f);
|
||||
}
|
||||
|
||||
// The words of each game module that differ from its image before the plugins' inits: (module, offset, old, new).
|
||||
static void write_writes(FILE *f) {
|
||||
int first = 1;
|
||||
for (int i = 0; i < ldr_count(); i++) {
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
if (m->plugin || !pre || !pre[i]) continue;
|
||||
const uint8_t *now = (const uint8_t *)(uintptr_t)m->base;
|
||||
for (uint64_t off = 0; off < m->size; off += PAGE) {
|
||||
if (!memcmp(now + off, pre[i] + off, PAGE)) continue;
|
||||
for (uint64_t w = off; w < off + PAGE; w += 4) {
|
||||
uint32_t a, b;
|
||||
memcpy(&a, pre[i] + w, 4);
|
||||
memcpy(&b, now + w, 4);
|
||||
if (a == b) continue;
|
||||
// fn_start: a lifted function starts at the word (a b there replaces the function)
|
||||
fprintf(f, "%s\n {\"module\": \"%s\", \"offset\": \"%#llx\", \"old\": \"%#010x\", \"new\": \"%#010x\", "
|
||||
"\"fn_start\": %s}", first ? "" : ",", m->name, (unsigned long long)w, a, b,
|
||||
rt_dispatch_lookup(m->base + w) ? "true" : "false");
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_record(const char *refused) {
|
||||
for (int i = 0; i < naliases; i++)
|
||||
if (aliases[i].live) flush(&aliases[i]);
|
||||
FILE *f = open_out("record.json", "w");
|
||||
// The marker of generated game-derived files (tools/check_content.py): the record never goes into the repository.
|
||||
fprintf(f, "{\n\"marker\": \"%s%s\",\n\"game_version\": %d,\n\"tick_offset\": \"%#llx\",\n\"refused\": ",
|
||||
"TOTK_RECOMP_", "GENERATED_FROM_GAME_CODE", rt_game_version, (unsigned long long)rt_svc_tick_offset);
|
||||
if (refused) json_str(f, refused);
|
||||
else fputs("null", f);
|
||||
fprintf(f, ",\n\"rtld\": {\"base\": \"%#llx\", \"size\": \"%#llx\"},\n\"pool\": {\"base\": \"%#llx\", \"size\": \"%#llx\"},",
|
||||
(unsigned long long)rtld_base, (unsigned long long)rtld_size, (unsigned long long)pool_base,
|
||||
(unsigned long long)POOL_SIZE);
|
||||
fputs("\n\"modules\": [", f);
|
||||
for (int i = 0; i < ldr_count(); i++) {
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
fprintf(f, "%s\n {\"name\": \"%s\", \"base\": \"%#llx\", \"size\": \"%#llx\", \"text_end\": \"%#llx\", "
|
||||
"\"data_off\": \"%#llx\", \"init\": \"%#llx\", \"plugin\": %s",
|
||||
i ? "," : "", m->name, (unsigned long long)m->base, (unsigned long long)m->size,
|
||||
(unsigned long long)m->text_end, (unsigned long long)m->data_off, (unsigned long long)m->init,
|
||||
m->plugin ? "true" : "false");
|
||||
if (m->plugin) fprintf(f, ", \"ran\": %s", ran && ran[i] ? "true" : "false");
|
||||
if (m->plugin && !refused) {
|
||||
char img[64], pre_img[64], hex[65];
|
||||
snprintf(img, sizeof img, "%s.img", m->name);
|
||||
snprintf(pre_img, sizeof pre_img, "%s.pre.img", m->name);
|
||||
write_image(img, (const void *)(uintptr_t)m->base, m->size);
|
||||
if (pre && pre[i]) write_image(pre_img, pre[i], m->size);
|
||||
sha256_hex((const void *)(uintptr_t)m->base, m->size, hex);
|
||||
fprintf(f, ", \"image\": \"%s\", \"image_sha256\": \"%s\", \"pre_image\": \"%s\"", img, hex, pre_img);
|
||||
}
|
||||
if (m->plugin) { // the lifted function starts: a main write may branch straight to one (tools/exefs_plugins.py)
|
||||
RtModule lm[16];
|
||||
int n = rt_linked_modules(lm, 16);
|
||||
for (int k = 0; k < n; k++) {
|
||||
if (strcmp(lm[k].name, m->name)) continue;
|
||||
fputs(", \"functions\": [", f);
|
||||
for (uint64_t j = 0; j < lm[k].count; j++)
|
||||
fprintf(f, "%s\"%#llx\"", j ? ", " : "", (unsigned long long)(lm[k].addrs[j] - m->base));
|
||||
fputc(']', f);
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < rt_layout_count; k++)
|
||||
if (rt_layout[k].file && !strcmp(rt_layout[k].name, m->name)) {
|
||||
fputs(", \"file\": ", f);
|
||||
json_str(f, rt_layout[k].file);
|
||||
fprintf(f, ", \"nso_sha256\": \"%s\"", rt_layout[k].sha256);
|
||||
}
|
||||
fputc('}', f);
|
||||
}
|
||||
fputs("\n],\n\"writes\": [", f);
|
||||
write_writes(f);
|
||||
fputs("\n],\n\"aliases\": [", f);
|
||||
for (int i = 0; i < naliases; i++)
|
||||
fprintf(f, "%s\n {\"dst\": \"%#llx\", \"src\": \"%#llx\", \"size\": \"%#llx\", \"unmapped\": %s}", i ? "," : "",
|
||||
(unsigned long long)aliases[i].dst, (unsigned long long)aliases[i].src,
|
||||
(unsigned long long)aliases[i].size, aliases[i].unmapped ? "true" : "false");
|
||||
fputs("\n],\n\"svcs\": {", f);
|
||||
int first = 1;
|
||||
for (int i = 0; i < 0x80; i++)
|
||||
if (svc_count[i]) fprintf(f, "%s\"%#x\": %llu", first ? "" : ", ", i, (unsigned long long)svc_count[i]), first = 0;
|
||||
fputs("},\n\"get_info\": {", f);
|
||||
first = 1;
|
||||
for (int i = 0; i < 16; i++)
|
||||
if (info_count[i]) fprintf(f, "%s\"%d\": %llu", first ? "" : ", ", i, (unsigned long long)info_count[i]), first = 0;
|
||||
if (info_65001) fprintf(f, "%s\"65001\": %llu", first ? "" : ", ", (unsigned long long)info_65001);
|
||||
fputs("},\n\"imports\": {", f);
|
||||
for (int i = 0; i < nimports; i++) {
|
||||
fputs(i ? ", " : "", f);
|
||||
json_str(f, imports[i].name);
|
||||
fprintf(f, ": %llu", (unsigned long long)imports[i].calls);
|
||||
}
|
||||
fputs("}\n}\n", f);
|
||||
if (fclose(f)) rt_fatal("plugin-init: cannot write record.json");
|
||||
}
|
||||
|
||||
// ---- setup and run
|
||||
static int layout_plugins(void) {
|
||||
int plugins = 0;
|
||||
for (int i = 0; i < rt_layout_count; i++) plugins += rt_layout[i].file != NULL;
|
||||
return plugins;
|
||||
}
|
||||
|
||||
static void environment(void);
|
||||
|
||||
// Before ldr_load: the import observer, the svc hooks, the pool and the stand-in for rtld.
|
||||
void plugin_init_setup(void) {
|
||||
if (!layout_plugins()) rt_fatal("plugin-init: this build's layout has no plugin module (recomp/gen.py --plugins)");
|
||||
plat_file_mkdir_p(rt_config()->plugin_init);
|
||||
const char *off = cfg_get("TOTK_PLUGIN_TICK_OFFSET");
|
||||
rt_svc_tick_offset = off ? strtoull(off, NULL, 0) : 0;
|
||||
environment();
|
||||
}
|
||||
|
||||
// The environment of a plugin's init, the same in the service run and at every start.
|
||||
static void environment(void) {
|
||||
ldr_plugin_import = plugin_import;
|
||||
rt_process_memory = process_memory;
|
||||
rt_plugin_svc = plugin_svc;
|
||||
|
||||
const RtGuestLayout *g = mem_layout();
|
||||
uint64_t main_base = rt_layout[0].base;
|
||||
rtld_size = ldr_nso_size(rt_config()->exefs, "rtld");
|
||||
rtld_base = main_base - align_up(rtld_size, RTLD_ALIGN);
|
||||
for (uint64_t at = align_up(g->alias.base + g->alias.size, POOL_ALIGN); at + POOL_SIZE <= rtld_base && !pool_base;
|
||||
at += POOL_ALIGN)
|
||||
if (plat_mem_reserve(at, POOL_SIZE, 0)) pool_base = at;
|
||||
if (!pool_base) rt_fatal("plugin-init: no free %llu GiB below main for the alias pool", POOL_SIZE / GiB);
|
||||
if (!plat_mem_reserve(rtld_base, align_up(rtld_size, PAGE), 0))
|
||||
rt_fatal("plugin-init: %#llx below main is taken; rtld goes there", (unsigned long long)rtld_base);
|
||||
ldr_map_image(rt_config()->exefs, "rtld", rtld_base, &rtld_text_end, &rtld_data_off);
|
||||
mem_query_hook = query_hook;
|
||||
rt_log("plugin-init: rtld at %#llx+%#llx, alias pool %#llx+%llu GiB, tick offset %#llx", (unsigned long long)rtld_base,
|
||||
(unsigned long long)rtld_size, (unsigned long long)pool_base, POOL_SIZE / GiB,
|
||||
(unsigned long long)rt_svc_tick_offset);
|
||||
}
|
||||
|
||||
// rt_boot, before ldr_load: the plugins' environment when the build has one (nothing otherwise).
|
||||
void plugins_setup(void) {
|
||||
if (!RT_PLUGIN_COUNT || !layout_plugins()) return;
|
||||
play = 1;
|
||||
environment();
|
||||
}
|
||||
|
||||
// From nn::init::Start's module-init callback (boot.c), in place of the game's constructors. rtld initialises the
|
||||
// modules from the last loaded to the first, so on the Switch sdk's DT_INIT runs before a subsdk plugin's; then each
|
||||
// plugin's, the last first. Exits with the record written.
|
||||
void plugin_init_run(Cpu *c, const RtLoaded *sdk) {
|
||||
rt_log("plugin-init: ENTER %s DT_INIT", sdk->name);
|
||||
rt_call(c, sdk->init, 0);
|
||||
pre = calloc((size_t)ldr_count(), sizeof *pre);
|
||||
if (!pre) rt_fatal("plugin-init: out of memory");
|
||||
for (int i = 0; i < ldr_count(); i++) { // the images before the plugins run
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
pre[i] = malloc(m->size);
|
||||
if (!pre[i]) rt_fatal("plugin-init: out of memory for a copy of %s", m->name);
|
||||
memcpy(pre[i], (const void *)(uintptr_t)m->base, m->size);
|
||||
}
|
||||
const char *only = cfg_get("TOTK_PLUGIN_ONLY");
|
||||
ran = calloc((size_t)ldr_count(), 1);
|
||||
if (!ran) rt_fatal("plugin-init: out of memory");
|
||||
for (int i = ldr_count() - 1; i >= 0; i--) {
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
if (!m->plugin) continue;
|
||||
if (only && *only && strcmp(only, m->name)) {
|
||||
rt_log("plugin-init: %s stays loaded, its init does not run (TOTK_PLUGIN_ONLY=%s)", m->name, only);
|
||||
continue;
|
||||
}
|
||||
ran[i] = 1;
|
||||
if (!m->init) refuse("a plugin without DT_INIT");
|
||||
rt_log("plugin-init: ENTER %s DT_INIT at %#llx (%llu init_array entries)", m->name, (unsigned long long)m->init,
|
||||
(unsigned long long)(m->init_array_size / 8));
|
||||
running = 1;
|
||||
rt_trace |= RT_TRACE_PLUGIN;
|
||||
rt_call(c, m->init, 0);
|
||||
rt_trace &= ~(unsigned)RT_TRACE_PLUGIN;
|
||||
running = 0;
|
||||
rt_log("plugin-init: %s DT_INIT returned", m->name);
|
||||
}
|
||||
write_record(NULL);
|
||||
int live = 0;
|
||||
for (int i = 0; i < naliases; i++) live += aliases[i].live;
|
||||
rt_log("plugin-init: record written to %s (%d process-memory maps, %d still mapped)", rt_config()->plugin_init,
|
||||
naliases, live);
|
||||
fflush(NULL);
|
||||
plat_exit(0);
|
||||
}
|
||||
|
||||
// ---- at every start
|
||||
#if RT_PLUGIN_COUNT
|
||||
static const struct { const char *module; int set; const char *sha256; } plugin_tab[] = {
|
||||
#define X(i, mod, set, sha) {mod, set, sha},
|
||||
RT_PLUGINS(X)
|
||||
#undef X
|
||||
};
|
||||
static const struct { int plugin; const char *module; uint64_t off; uint32_t old, now; } write_tab[] = {
|
||||
#define X(p, mod, off, old, now) {p, mod, off, old, now},
|
||||
RT_PLUGIN_WRITES(X)
|
||||
#undef X
|
||||
};
|
||||
#define NWRITES ((int)(sizeof write_tab / sizeof *write_tab))
|
||||
#ifdef RT_PLUGIN_ROOTS
|
||||
static const struct { const char *module; uint64_t off; } root_tab[] = {
|
||||
#define X(mod, off) {mod, off},
|
||||
RT_PLUGIN_ROOTS(X)
|
||||
#undef X
|
||||
};
|
||||
#define NROOTS ((int)(sizeof root_tab / sizeof *root_tab))
|
||||
#else
|
||||
#define NROOTS 0
|
||||
#endif
|
||||
|
||||
static const RtLoaded *loaded(const char *name) {
|
||||
for (int i = 0; i < ldr_count(); i++)
|
||||
if (!strcmp(ldr_module(i)->name, name)) return ldr_module(i);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TOTK_PLUGIN_TRACE = 1: the first call of each hook entry (patches.h RT_PLUGIN_ROOTS: callbacks, replace and call
|
||||
// targets) is logged with its count so far; the entries run through count_entry, their dispatch slots rerouted once
|
||||
// at start (dispatch.c rt_dispatch_reroute). The calls inside the plugin are direct and not counted.
|
||||
static struct { uint64_t addr; GuestFn fn; uint64_t calls; } traced[64];
|
||||
static int ntraced;
|
||||
|
||||
static void count_entry(Cpu *c) {
|
||||
for (int i = 0; i < ntraced; i++) {
|
||||
if (traced[i].addr != c->pc) continue;
|
||||
if (__atomic_add_fetch(&traced[i].calls, 1, __ATOMIC_RELAXED) == 1) {
|
||||
char at[128];
|
||||
rt_log("plugins: hook entry %s reached (first call)", ldr_describe(c->pc, at, sizeof at));
|
||||
}
|
||||
__attribute__((musttail)) return traced[i].fn(c);
|
||||
}
|
||||
rt_fatal("plugins: traced entry %#llx without its function", (unsigned long long)c->pc);
|
||||
}
|
||||
|
||||
static void trace_entries(void) {
|
||||
#ifdef RT_PLUGIN_ROOTS
|
||||
for (int i = 0; i < NROOTS && ntraced < 64; i++) {
|
||||
const RtLoaded *m = loaded(root_tab[i].module);
|
||||
if (!m) continue;
|
||||
uint64_t a = m->base + root_tab[i].off;
|
||||
GuestFn f = rt_dispatch_lookup(a);
|
||||
if (!f) continue;
|
||||
traced[ntraced] = (typeof(traced[0])){a, f, 0};
|
||||
if (rt_dispatch_reroute(a, count_entry)) ntraced++;
|
||||
else rt_log("plugins: trace: cannot reroute %#llx", (unsigned long long)a);
|
||||
}
|
||||
#endif
|
||||
rt_log("plugins: trace: %d hook entries counted", ntraced);
|
||||
}
|
||||
|
||||
// Takes back a page an init changed in the sealed part (.text, .rodata) of a game module: main keeps the game's own
|
||||
// bytes, the lifted code being what runs.
|
||||
static void restore_page(const RtLoaded *m, uint64_t off, const uint8_t *was) {
|
||||
if (!plat_mem_protect(m->base + off, PAGE, PLAT_PROT_RW)) rt_fatal("plugins: cannot unseal %s+%#llx", m->name,
|
||||
(unsigned long long)off);
|
||||
memcpy((void *)(uintptr_t)(m->base + off), was, PAGE);
|
||||
plat_mem_protect(m->base + off, PAGE, PLAT_PROT_READ);
|
||||
}
|
||||
|
||||
// After plugin i's init: what it wrote into the game modules, word by word, against the record of the build (its
|
||||
// entries of RT_PLUGIN_WRITES). The first difference goes into why (unless a reason is there already). Then the game
|
||||
// modules are made what they were before the init: the sealed part (.text, .rodata) gets the game's bytes back, a
|
||||
// write elsewhere stays and goes into pre, so the next plugin's init is compared only with what it writes itself.
|
||||
// The aliases this init mapped (from first_alias on) are flushed first; an earlier init's were flushed after it.
|
||||
static void check_writes(int plugin, int first_alias, char *why, size_t cap) {
|
||||
for (int i = first_alias; i < naliases; i++)
|
||||
if (aliases[i].live) flush(&aliases[i]);
|
||||
uint8_t seen[NWRITES > 0 ? NWRITES : 1];
|
||||
memset(seen, 0, sizeof seen);
|
||||
int unexpected = 0, missing = 0;
|
||||
char first[160] = "";
|
||||
for (int i = 0; i < ldr_count(); i++) {
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
if (!pre[i]) continue;
|
||||
uint8_t *now = (uint8_t *)(uintptr_t)m->base;
|
||||
for (uint64_t off = 0; off < m->size; off += PAGE) {
|
||||
if (!memcmp(now + off, pre[i] + off, PAGE)) continue;
|
||||
for (uint64_t w = off; w < off + PAGE; w += 4) {
|
||||
uint32_t a, b;
|
||||
memcpy(&a, pre[i] + w, 4);
|
||||
memcpy(&b, now + w, 4);
|
||||
if (a == b) continue;
|
||||
int k = 0;
|
||||
while (k < NWRITES && !(write_tab[k].plugin == plugin && write_tab[k].off == w &&
|
||||
!strcmp(write_tab[k].module, m->name) && write_tab[k].old == a &&
|
||||
write_tab[k].now == b))
|
||||
k++;
|
||||
if (k < NWRITES) {
|
||||
seen[k] = 1;
|
||||
} else if (!unexpected++) {
|
||||
snprintf(first, sizeof first, "%s+%#llx %08x -> %08x", m->name, (unsigned long long)w, a, b);
|
||||
}
|
||||
}
|
||||
if (off < m->data_off) restore_page(m, off, pre[i] + off);
|
||||
else memcpy(pre[i] + off, now + off, PAGE);
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < NWRITES; k++) missing += write_tab[k].plugin == plugin && !seen[k];
|
||||
if (why[0]) return;
|
||||
if (unexpected)
|
||||
snprintf(why, cap, "its init wrote %d words the build did not record (first %s)", unexpected, first);
|
||||
else if (missing)
|
||||
snprintf(why, cap, "%d of the words the build recorded were not written", missing);
|
||||
}
|
||||
#endif
|
||||
|
||||
int plugins_start(Cpu *c, const RtLoaded *sdk) {
|
||||
#if RT_PLUGIN_COUNT
|
||||
if (!play) return 0;
|
||||
int run[RT_PLUGIN_COUNT] = {0}, nrun = 0;
|
||||
char why[RT_PLUGIN_COUNT][256];
|
||||
for (int i = 0; i < RT_PLUGIN_COUNT; i++) {
|
||||
why[i][0] = 0;
|
||||
const RtLoaded *m = loaded(plugin_tab[i].module);
|
||||
if (!rt_patch_enabled(plugin_tab[i].set)) continue;
|
||||
if (!m) { // loader.c left it out (its file is gone or changed): its set cannot run
|
||||
mods_plugin_off(plugin_tab[i].set, "its file is not the one the build lifted");
|
||||
continue;
|
||||
}
|
||||
if (!m->init) {
|
||||
mods_plugin_off(plugin_tab[i].set, "it has no DT_INIT");
|
||||
continue;
|
||||
}
|
||||
run[i] = 1, nrun++;
|
||||
}
|
||||
if (!nrun) { // every plugin's mod off or gone: the game sees its address space as without plugins
|
||||
mem_query_hook = NULL;
|
||||
rt_process_memory = NULL;
|
||||
return 0;
|
||||
}
|
||||
uint64_t t0 = plat_now_ms();
|
||||
rt_log("boot: ENTER %s DT_INIT first: a mod plugin's init runs before the game's constructors", sdk->name);
|
||||
rt_call(c, sdk->init, 0);
|
||||
pre = calloc((size_t)ldr_count(), sizeof *pre);
|
||||
if (!pre) rt_fatal("plugins: out of memory");
|
||||
for (int i = 0; i < ldr_count(); i++) { // the game modules before the plugins run
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
if (m->plugin) continue;
|
||||
pre[i] = malloc(m->size);
|
||||
if (!pre[i]) rt_fatal("plugins: out of memory for a copy of %s", m->name);
|
||||
memcpy(pre[i], (const void *)(uintptr_t)m->base, m->size);
|
||||
}
|
||||
for (int i = RT_PLUGIN_COUNT - 1; i >= 0; i--) {
|
||||
if (!run[i]) continue;
|
||||
const RtLoaded *m = loaded(plugin_tab[i].module);
|
||||
rt_log("plugins: ENTER %s DT_INIT at %#llx", m->name, (unsigned long long)m->init);
|
||||
failed[0] = 0;
|
||||
int first_alias = naliases;
|
||||
running = 1;
|
||||
rt_trace |= RT_TRACE_PLUGIN;
|
||||
rt_call(c, m->init, 0);
|
||||
rt_trace &= ~(unsigned)RT_TRACE_PLUGIN;
|
||||
running = 0;
|
||||
if (failed[0]) snprintf(why[i], sizeof why[i], "its init asked for what the port does not serve: %s", failed);
|
||||
check_writes(i, first_alias, why[i], sizeof why[i]);
|
||||
char hex[65];
|
||||
sha256_hex((const void *)(uintptr_t)m->base, m->text_end, hex);
|
||||
if (!why[i][0] && strcmp(hex, plugin_tab[i].sha256))
|
||||
snprintf(why[i], sizeof why[i], "its code after the init is not the one the build lifted");
|
||||
}
|
||||
for (int i = 0; i < ldr_count(); i++) free(pre[i]);
|
||||
free(pre);
|
||||
pre = NULL;
|
||||
mem_query_hook = NULL; // the game's own QueryMemory sees its address space as without plugins
|
||||
rt_process_memory = NULL; // a callback that maps process memory stops with a named fatal (svc.c)
|
||||
int on = 0;
|
||||
for (int i = 0; i < RT_PLUGIN_COUNT; i++) {
|
||||
if (!run[i]) continue;
|
||||
if (why[i][0]) {
|
||||
rt_log("plugins: %s stays off: %s", plugin_tab[i].module, why[i]);
|
||||
mods_plugin_off(plugin_tab[i].set, why[i]);
|
||||
continue;
|
||||
}
|
||||
int hooks = 0;
|
||||
for (int k = 0; k < NWRITES; k++) hooks += write_tab[k].plugin == i;
|
||||
rt_log("plugins: %s: init ran, %d hooks on (set %s)", plugin_tab[i].module, hooks,
|
||||
rt_patch_name(plugin_tab[i].set));
|
||||
on++;
|
||||
}
|
||||
int live = 0;
|
||||
for (int i = 0; i < naliases; i++) live += aliases[i].live;
|
||||
rt_log("plugins: %d of %d plugins on in %llu ms (%d process-memory maps, %d kept)", on, nrun,
|
||||
(unsigned long long)(plat_now_ms() - t0), naliases, live);
|
||||
if (on && cfg_bool("TOTK_PLUGIN_TRACE")) trace_entries();
|
||||
return 1;
|
||||
#else
|
||||
(void)c, (void)sdk;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
// Quick save and quick load, 1.4.3 only (TOTK_QUICKSAVE, live, default 0): one key saves the game at once and another
|
||||
// loads that save, F6 and F7 by default as in Half-Life (TOTK_QUICKSAVE_KEY, TOTK_QUICKLOAD_KEY: a key name of
|
||||
// input_map.c, or none; live). Keyboard and mouse keys only: a gamepad has no quick save button. No menu shows: quick
|
||||
// save asks the game directly, quick load runs the game's load menu under a held picture.
|
||||
//
|
||||
// Quick save asks the game for an autosave the way its own event graphs do (the execute of the sequence node
|
||||
// OneShotAutoSaveMgrRequestAutoSave, 1.4.3 main+0x24fed3c): component 10 of the game's root is the AutoSaveMgr,
|
||||
// main+0x513ab8 says whether it would autosave now (a cutscene, an event, a fight or a recent autosave say no) and
|
||||
// main+0x1f8ed24 queues the request with kind 4, as that node does. The game then writes one of its autosave slots and
|
||||
// commits the save; fs_host.c reports the slot folder that commit wrote (fs_save_commits), and quicksave copies it to
|
||||
// <profile>/quicksave/slot, its name to <profile>/quicksave/slot.txt. A toast at the top of the picture says "Game
|
||||
// saved" (ui/menu.cpp menu_toast), or why nothing was saved.
|
||||
//
|
||||
// Quick load: the game starts a load only from its own load list (System tab) or its Game Over screen, and loads the
|
||||
// slot that screen names; nothing in play requests one. So quick load drives the load list as a player with a
|
||||
// controller would, under a held picture: the toast "Loading the quick save" shows, the window keeps that picture
|
||||
// (gfx_present_hold) while Plus, R to the System tab, Load, the list's first save and the confirmation's Load are
|
||||
// pressed, and the picture comes back with the game's loading fade. From the confirmation on, the game's reads of the
|
||||
// files of a slot open the quick save's files instead (fs_save_read_from), so it loads the quick save whichever slot
|
||||
// the list offered first, and no slot of the save is written for it (quicksave_poll); the redirect ends with the load
|
||||
// (reads_watch).
|
||||
//
|
||||
// Both start only in play: the world loaded, the HUD's PlayerStatus_00 open, no screen with the focus box, no dialogue
|
||||
// box and no loading fade. Script lines QUICKSAVE and QUICKLOAD (input.c) start them as the keys do.
|
||||
//
|
||||
// Threads. 1.4.3 has no one thread for the AutoSaveMgr: a trace of the hooked functions (function-entry hooks on a test
|
||||
// build) saw the game itself call AUTOSAVE_REQ from at least four guest threads, as events and sequence nodes run on the
|
||||
// game's job workers, and the manager check its pending request (main+0x50ed8c, +0x50f3e8, with AUTOSAVE_CAN) on two
|
||||
// others; the pad was read on six. So quick save calls AUTOSAVE_CAN and AUTOSAVE_REQ the way those events do: from a
|
||||
// game thread between two of the game's own calls, the pad read (quicksave_guest, from ov_input.c's npad_states).
|
||||
// AUTOSAVE_REQ only sets the manager's request flag, and the manager checks AUTOSAVE_CAN again before it saves. As
|
||||
// several threads read the pad at once, one of them at a time steps quick save and quick load (qs_lock); the others give
|
||||
// the game the same presses.
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "fs.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "input_map.h"
|
||||
#include "layout.h"
|
||||
#include "gfx.h"
|
||||
#include "platform/platform.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui_text.h"
|
||||
|
||||
// 1.4.3 main: offsets from MOD_MAIN_BASE
|
||||
#define GAME_ROOT 0x395dc70ull // ** the game's root object (the sequence nodes' first read)
|
||||
#define COMPONENT 0x89f9b0ull // (root, index): the root's component of that index, 0 when none
|
||||
#define AUTOSAVE_INDEX 10 // the AutoSaveMgr's component index
|
||||
#define AUTOSAVE_TYPE 0xc1e348ull // (): AutoSaveMgr's runtime type info, for its vtable's first method (the cast)
|
||||
#define AUTOSAVE_CAN 0x513ab8ull // (mgr, kind, 0): bit 0 when the game would autosave now
|
||||
#define AUTOSAVE_REQ 0x1f8ed24ull // (mgr, kind): queue an autosave
|
||||
#define AUTOSAVE_KIND 4 // the kind OneShotAutoSaveMgrRequestAutoSave asks for
|
||||
#define SAVE_MS 5000 // the most the game takes from the request to the commit of the save (0.5 s seen)
|
||||
#define REQ_FLAGS 0x128ull // mgr+0x128: the request flags; AUTOSAVE_REQ sets bit 0 of their byte 5
|
||||
|
||||
enum { REQ_NONE, REQ_SAVE, REQ_LOAD };
|
||||
static volatile int32_t g_request; // REQ_*, set by the keys or a script, taken by quicksave_guest
|
||||
static int saving; // 1 waiting for the commit of the requested autosave, 2 copying it
|
||||
static uint32_t commits_before;
|
||||
static uint64_t save_started;
|
||||
static uint64_t req_flags; // the request flags' byte AUTOSAVE_REQ set, 0 when the game had set it already
|
||||
|
||||
static int save_key = KEY_F6, load_key = KEY_F7; // KEY_NONE: that key is off
|
||||
static PlatMutex qs_lock = PLAT_MUTEX_INIT; // the pad-reading thread that steps quick save / quick load
|
||||
|
||||
static int key_id(const char *name) {
|
||||
for (int k = KEY_A; k < KEY_COUNT; k++)
|
||||
if (input_key_name(k) && !strcasecmp(name, input_key_name(k))) return k;
|
||||
return KEY_NONE;
|
||||
}
|
||||
|
||||
// A key setting as a KEY_*: a key name of input_map.c (any case) or "none"; anything else is logged and the default
|
||||
// from the settings table is used
|
||||
static int key_setting(const char *var, const char *ini) {
|
||||
const char *v = cfg_value(var), *def = cfg_meta(var)->def;
|
||||
if (!strcasecmp(v, "none")) return KEY_NONE;
|
||||
int k = key_id(v);
|
||||
if (k == KEY_NONE) rt_log("quicksave: %s: unknown key '%s', %s is used", ini, v, def), k = key_id(def);
|
||||
return k;
|
||||
}
|
||||
|
||||
// The keys are read with the switch, so with it off nothing is logged
|
||||
int quicksave_on(void) {
|
||||
static unsigned seen = ~0u;
|
||||
static int on;
|
||||
unsigned v = cfg_version();
|
||||
if (v == seen) return on;
|
||||
int was = on, want = cfg_bool("TOTK_QUICKSAVE");
|
||||
static int told;
|
||||
seen = v, on = RT_V143 && want;
|
||||
// The game's addresses below are 1.4.3's: on 1.1.0 and 1.2.1 the setting is refused once, and no call is made
|
||||
if (want && !RT_V143 && !told) told = 1, rt_log("quicksave: game 1.4.3 only; quick save and quick load stay off");
|
||||
if (!on) return 0;
|
||||
int s = key_setting("TOTK_QUICKSAVE_KEY", "quicksave_key"), l = key_setting("TOTK_QUICKLOAD_KEY", "quickload_key");
|
||||
if (l == s && l != KEY_NONE) {
|
||||
rt_log("quicksave: quickload_key is the quick save key %s: it saves, no key loads", input_key_name(l));
|
||||
l = KEY_NONE;
|
||||
}
|
||||
if (!was || s != save_key || l != load_key)
|
||||
rt_log("quicksave: %s saves, %s loads", s ? input_key_name(s) : "no key", l ? input_key_name(l) : "no key");
|
||||
save_key = s, load_key = l;
|
||||
return on;
|
||||
}
|
||||
|
||||
void quicksave_request(int load) {
|
||||
if (!quicksave_on()) return;
|
||||
plat_cas32(&g_request, load ? REQ_LOAD : REQ_SAVE, REQ_NONE);
|
||||
}
|
||||
|
||||
void quicksave_keys(uint8_t *down, int act) {
|
||||
static int held_s, held_l;
|
||||
int s = save_key && down[save_key], l = load_key && down[load_key];
|
||||
if (act && s && !held_s) quicksave_request(0);
|
||||
if (act && l && !held_l) quicksave_request(1);
|
||||
held_s = s, held_l = l;
|
||||
down[save_key] = down[load_key] = 0; // KEY_NONE is slot 0, never a key
|
||||
}
|
||||
|
||||
// Why play is not at a point where quick save or load may start, NULL when it is
|
||||
static const char *not_in_play(void) {
|
||||
char scr[48];
|
||||
uint64_t node;
|
||||
if (frame_step_world_us() < 0) return "no save is loaded";
|
||||
if (menu_ui_focus(scr, sizeof scr, &node)) return "a menu is open";
|
||||
if (menu_ui_open("LoadingFade_00") || menu_ui_open("EventFade_00")) return "the game is loading";
|
||||
if (menu_ui_open("MessageDialog_00")) return "a dialogue box is open";
|
||||
if (!menu_ui_open("PlayerStatus_00")) return "the HUD is hidden (a cutscene or an event)";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void say(int text, const char *what, const char *why) {
|
||||
rt_log("%s: %s", what, why);
|
||||
menu_toast(text, 2500);
|
||||
}
|
||||
|
||||
static int readable(uint64_t p, uint64_t n) { return p >= 0x10000 && p < (1ull << 47) && mem_guest_readable(p, n); }
|
||||
|
||||
// The game's AutoSaveMgr, found and cast as OneShotAutoSaveMgrRequestAutoSave's execute does; 0 when it has none
|
||||
static uint64_t autosave_mgr(Cpu *c) {
|
||||
uint64_t g = MOD_MAIN_BASE + GAME_ROOT;
|
||||
if (!readable(g, 8) || !readable(LD64(g), 8)) return 0;
|
||||
uint64_t root = LD64(LD64(g));
|
||||
if (!readable(root, 8)) return 0;
|
||||
uint64_t mgr = rt_call(c, MOD_MAIN_BASE + COMPONENT, 2, root, (uint64_t)AUTOSAVE_INDEX);
|
||||
if (!readable(mgr, 0x1a8) || !readable(LD64(mgr), 8)) return 0;
|
||||
uint64_t type = rt_call(c, MOD_MAIN_BASE + AUTOSAVE_TYPE, 0);
|
||||
return rt_call(c, LD64(LD64(mgr)), 2, mgr, type) ? mgr : 0;
|
||||
}
|
||||
|
||||
static void path_of(char *out, size_t cap, const char *leaf) {
|
||||
snprintf(out, cap, "%s/quicksave%s%s", rt_config()->profile, leaf ? "/" : "", leaf ? leaf : "");
|
||||
}
|
||||
|
||||
static void save_start(Cpu *c) {
|
||||
const char *why = not_in_play();
|
||||
if (why) { say(UI_QS_NOT_NOW, "quicksave: not now", why); return; }
|
||||
uint64_t mgr = autosave_mgr(c);
|
||||
if (!mgr) { say(UI_QS_FAILED, "quicksave", "the game has no AutoSaveMgr"); return; }
|
||||
// The manager's timer (+0x150, seconds) holds autosaves back for some ten minutes after the game's last one; a
|
||||
// quick save is the player's own and skips it, as Save in the System tab does. The other checks of AUTOSAVE_CAN
|
||||
// stay: its flags, the game's flag that turns autosaves off (events, fights) and the player's state. AUTOSAVE_REQ
|
||||
// itself drops the request while flag +0x1a0 is set and the state +0x1a4 is 3 (but for kind 2).
|
||||
float timer;
|
||||
memcpy(&timer, (const void *)(uintptr_t)(mgr + 0x150), 4);
|
||||
ST32(mgr + 0x150, 0);
|
||||
int can = rt_call(c, MOD_MAIN_BASE + AUTOSAVE_CAN, 3, mgr, (uint64_t)AUTOSAVE_KIND, 0ull) & 1;
|
||||
if (can && LD8(mgr + 0x1a0) && LD32(mgr + 0x1a4) == 3) can = 0;
|
||||
if (!can) {
|
||||
memcpy((void *)(uintptr_t)(mgr + 0x150), &timer, 4); // the game's own wait goes on as it was
|
||||
say(UI_QS_NOT_NOW, "quicksave: not now", "the game would not autosave here");
|
||||
return;
|
||||
}
|
||||
if (timer > 0) rt_log("quicksave: the game's autosave wait (%.0f s left) skipped", timer);
|
||||
char slot[64];
|
||||
commits_before = fs_save_commits(slot, sizeof slot);
|
||||
uint64_t flags = LD64(mgr + REQ_FLAGS) + 5;
|
||||
if (!readable(flags, 1)) { say(UI_QS_FAILED, "quicksave", "the AutoSaveMgr has no request flags"); return; }
|
||||
int pending = LD8(flags) & 1; // the game's own request, which quick save then waits for
|
||||
rt_call(c, MOD_MAIN_BASE + AUTOSAVE_REQ, 2, mgr, (uint64_t)AUTOSAVE_KIND);
|
||||
if (!(LD8(flags) & 1)) { say(UI_QS_NOT_NOW, "quicksave: not now", "the game dropped the request"); return; }
|
||||
req_flags = pending ? 0 : flags;
|
||||
saving = 1, save_started = plat_now_ms();
|
||||
rt_log("quicksave: autosave requested");
|
||||
}
|
||||
|
||||
// The slot the autosave wrote, copied to <profile>/quicksave on a thread of its own; saving goes back to 0 at its end
|
||||
static char copy_slot[64];
|
||||
static void copy_main(void *arg) {
|
||||
(void)arg;
|
||||
char dir[1200], data[1200], note[1200];
|
||||
path_of(dir, sizeof dir, NULL), path_of(data, sizeof data, "slot"), path_of(note, sizeof note, "slot.txt");
|
||||
plat_fs_mkdir(dir);
|
||||
if (fs_save_copy_slot(copy_slot, data) || !plat_file_write_atomic(note, copy_slot, strlen(copy_slot))) {
|
||||
say(UI_QS_FAILED, "quicksave", "the autosave could not be copied to the quick save");
|
||||
} else {
|
||||
rt_log("quicksave: saved: the game's autosave in %s (%.1f s), kept in %s", copy_slot,
|
||||
(plat_now_ms() - save_started) / 1000.0, data);
|
||||
menu_toast(UI_QS_SAVED, 2500);
|
||||
}
|
||||
__atomic_store_n(&saving, 0, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
// After the request: the first commit that wrote a slot folder is the autosave
|
||||
static void save_wait(void) {
|
||||
if (__atomic_load_n(&saving, __ATOMIC_ACQUIRE) != 1) return; // 2: the copy runs
|
||||
char slot[64];
|
||||
uint32_t n = fs_save_commits(slot, sizeof slot);
|
||||
if (n == commits_before || !slot[0]) {
|
||||
// The game can take the request and still hold the autosave back (a fight in the Depths did): quick save then
|
||||
// takes its request back, so the game does not save some time later on its own, and says so
|
||||
if (plat_now_ms() - save_started > SAVE_MS) {
|
||||
// Atomic: the game's job threads set and read other bits of this byte at the same time
|
||||
if (req_flags) __atomic_fetch_and((uint8_t *)(uintptr_t)req_flags, (uint8_t)~1u, __ATOMIC_SEQ_CST);
|
||||
saving = 0;
|
||||
say(UI_QS_NOT_NOW, "quicksave: not now",
|
||||
req_flags ? "the game held the autosave back; the request is withdrawn" : "the game held its autosave back");
|
||||
}
|
||||
return;
|
||||
}
|
||||
saving = 2; // the copy runs on its own thread: no file I/O on the game thread
|
||||
snprintf(copy_slot, sizeof copy_slot, "%s", slot);
|
||||
if (!plat_thread_spawn(copy_main, NULL, "quicksave", 0)) copy_main(NULL);
|
||||
}
|
||||
|
||||
// ---- quick load: the game's load menu, driven under a held picture
|
||||
enum { ST_IDLE, ST_TOAST, ST_OPEN, ST_TAB, ST_PICK, ST_LIST, ST_CONFIRM, ST_LOADING, ST_CLEANUP };
|
||||
#define PRESS_MS 100 // a press, held long enough for any of the game's reads
|
||||
#define GAP_MS 120 // released after each press before the next step looks again
|
||||
#define SETTLE_MS 200 // a screen that just took the focus box plays its opening: act after this
|
||||
#define TAB_MS 100 // a tab of the pause menu that just took the focus: act after this (R stops at the last)
|
||||
#define TOAST_MS 150 // the toast is presented before the picture is held
|
||||
#define STEP_MS 3000 // the most any step waits for its screen
|
||||
#define LOAD_MS 10000 // the most the game takes from the confirmation to its loading fade
|
||||
#define BACK_MS 500 // the load is over once the HUD has been back this long, the loading fade closed
|
||||
#define READ_MAX_MS 120000 // the redirect ends this long after the confirmation whatever happened
|
||||
#define MAX_TABS 12 // R presses to reach the System tab, the last one (R stops there)
|
||||
#define MAX_BACK 10 // B presses to leave the menus after a failure
|
||||
|
||||
static struct {
|
||||
int state, tries;
|
||||
uint64_t state_at, press_until, gap_until, press_bit, focus_since, started;
|
||||
uint64_t reading, back_since; // reading: when the redirect began, 0 none; back_since: the HUD back since then
|
||||
char focus[48];
|
||||
} m;
|
||||
|
||||
int quicksave_busy(void) { return m.state != ST_IDLE; }
|
||||
|
||||
static void enter(int state, uint64_t now) { m.state = state, m.state_at = now, m.tries = 0; }
|
||||
|
||||
static void press(int bit, uint64_t now) {
|
||||
m.press_bit = 1ull << bit, m.press_until = now + PRESS_MS, m.gap_until = now + PRESS_MS + GAP_MS;
|
||||
}
|
||||
|
||||
static void fail(const char *why, uint64_t now) {
|
||||
rt_log("quickload: %s; leaving the menus", why);
|
||||
fs_save_read_from(NULL);
|
||||
m.reading = m.back_since = 0;
|
||||
menu_toast(UI_QS_LOAD_FAILED, 2500);
|
||||
enter(ST_CLEANUP, now);
|
||||
}
|
||||
|
||||
static void end(uint64_t now) {
|
||||
gfx_present_hold(0);
|
||||
enter(ST_IDLE, now);
|
||||
}
|
||||
|
||||
// Once per pad read on the game thread, after menu_cursor_poll: 1 while quick load runs, with the game's input
|
||||
// replaced by its presses. Quick load shows "Loading the quick save", then holds the window on that picture
|
||||
// (gfx_present_hold) while it opens the pause menu, turns to the System tab, presses Load, picks the list's first save
|
||||
// and confirms; from the confirmation on, the game's reads of a slot's files open the quick save's (fs_save_read_from),
|
||||
// so whichever slot the list offered first, the game loads the quick save. The picture comes back with the game's
|
||||
// loading fade, or as soon as a step fails (B then closes the menus).
|
||||
// The redirect of the slot reads ends with the load: once the game read the quick save's files, its loading fade closed
|
||||
// and the HUD (PlayerStatus_00) has been back BACK_MS; at once when a menu with the focus box opens (the load list
|
||||
// must show and load the slots as they are); after READ_MAX_MS whatever happened.
|
||||
static void reads_end(const char *why) {
|
||||
fs_save_read_from(NULL);
|
||||
rt_log("quickload: slot reads go to the save again (%s, %d files read from the quick save)", why,
|
||||
fs_save_read_from_hits());
|
||||
m.reading = m.back_since = 0;
|
||||
}
|
||||
|
||||
static void reads_watch(uint64_t now) {
|
||||
char scr[48];
|
||||
uint64_t node;
|
||||
if (menu_ui_focus(scr, sizeof scr, &node)) { reads_end("a menu opened"); return; }
|
||||
if (now - m.reading > READ_MAX_MS) { reads_end("the load did not end in time"); return; }
|
||||
int back = fs_save_read_from_hits() > 0 && !menu_ui_open("LoadingFade_00") && menu_ui_open("PlayerStatus_00");
|
||||
if (!back) m.back_since = 0;
|
||||
else if (!m.back_since) m.back_since = now;
|
||||
else if (now - m.back_since >= BACK_MS) reads_end("the load is over");
|
||||
}
|
||||
|
||||
static int poll_locked(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
if (m.reading && m.state == ST_IDLE) reads_watch(plat_now_ms());
|
||||
if (m.state == ST_IDLE && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_LOAD) return 0; // a plain read
|
||||
uint64_t now = plat_now_ms();
|
||||
if (m.state == ST_IDLE) {
|
||||
if (plat_cas32(&g_request, REQ_NONE, REQ_LOAD) != REQ_LOAD || !quicksave_on()) return 0;
|
||||
char data[1200];
|
||||
path_of(data, sizeof data, "slot");
|
||||
if (plat_fs_kind(data) != PLAT_FS_DIR) { say(UI_QS_NONE, "quickload", "there is no quick save"); return 0; }
|
||||
const char *why = not_in_play();
|
||||
if (why) { say(UI_QS_NOT_NOW, "quickload: not now", why); return 0; }
|
||||
rt_log("quickload: through the game's load menu, under the held picture");
|
||||
menu_toast(UI_QS_LOADING, 4000);
|
||||
m.started = now;
|
||||
enter(ST_TOAST, now);
|
||||
}
|
||||
plat_cas32(&g_request, REQ_NONE, REQ_LOAD); // a key pressed while it runs is dropped, not queued
|
||||
*buttons = 0, *lx = *ly = *rx = *ry = 0;
|
||||
if (now < m.press_until) { *buttons = m.press_bit; return 1; }
|
||||
if (now < m.gap_until) return 1;
|
||||
char scr[48];
|
||||
uint64_t node;
|
||||
int focus = menu_ui_focus(scr, sizeof scr, &node);
|
||||
if (!focus || strcmp(scr, m.focus)) m.focus_since = now, snprintf(m.focus, sizeof m.focus, "%s", focus ? scr : "");
|
||||
int settled = focus && now - m.focus_since >= SETTLE_MS;
|
||||
uint64_t waited = now - m.state_at;
|
||||
if (m.state != ST_CLEANUP && m.state != ST_LOADING && now - m.started > 4 * STEP_MS) {
|
||||
fail("took too long", now);
|
||||
return 1;
|
||||
}
|
||||
switch (m.state) {
|
||||
case ST_TOAST: // the toast reaches the screen; then the picture is held and Plus opens the pause menu
|
||||
if (waited < TOAST_MS) break;
|
||||
gfx_present_hold(1);
|
||||
press(B_PLUS, now);
|
||||
enter(ST_OPEN, now);
|
||||
break;
|
||||
case ST_OPEN: // the pause menu (Pouch_00) takes the focus box
|
||||
if (focus && strcmp(scr, "Pouch_00")) { fail("another menu opened", now); break; }
|
||||
if (settled) enter(ST_TAB, now);
|
||||
else if (waited > STEP_MS) fail("the pause menu did not open", now);
|
||||
break;
|
||||
case ST_TAB: { // R until the System tab's buttons show
|
||||
int ok;
|
||||
if (focus && strcmp(scr, "Pouch_00")) { fail("another menu opened", now); break; }
|
||||
if (!focus || now - m.focus_since < TAB_MS) {
|
||||
if (waited > STEP_MS) fail("the pause menu lost the focus", now);
|
||||
break;
|
||||
}
|
||||
if (menu_ui_button("PaCommonBtnThin_00", "Pa_Button_01", &ok)) { enter(ST_PICK, now); break; }
|
||||
if (m.tries++ >= MAX_TABS) { fail("the System tab was not found", now); break; }
|
||||
press(B_R, now);
|
||||
m.state_at = now; // each tab gets its own wait
|
||||
break;
|
||||
}
|
||||
case ST_PICK: { // Load (Pa_Button_01) takes the focus, then A
|
||||
int ok = 0;
|
||||
uint64_t b = menu_ui_button("PaCommonBtnThin_00", "Pa_Button_01", &ok);
|
||||
if (!b) { fail("the System tab closed", now); break; }
|
||||
if (!ok) { fail("the game does not allow loading now", now); break; }
|
||||
if (menu_ui_focus_to(b)) { press(B_A, now); enter(ST_LIST, now); }
|
||||
else if (waited > STEP_MS) fail("the focus did not move to Load", now);
|
||||
break;
|
||||
}
|
||||
case ST_LIST: { // the load list (SystemLoadList_00): its first save takes the focus, then A
|
||||
if (!settled || strcmp(scr, "SystemLoadList_00")) {
|
||||
if (focus && settled && strcmp(scr, "Pouch_00")) fail("another menu opened", now);
|
||||
else if (waited > STEP_MS) fail("the list of saves did not open", now);
|
||||
break;
|
||||
}
|
||||
uint64_t b = menu_ui_first_save();
|
||||
if (!b) { fail("the list holds no save", now); break; }
|
||||
if (menu_ui_focus_to(b)) { press(B_A, now); enter(ST_CONFIRM, now); }
|
||||
else if (waited > STEP_MS) fail("the focus did not move to the save", now);
|
||||
break;
|
||||
}
|
||||
case ST_CONFIRM: { // "Load this save?" (SystemSaveLoad_00): its first button and A, the slot reads redirected
|
||||
if (!settled || strcmp(scr, "SystemSaveLoad_00")) {
|
||||
if (focus && settled && strcmp(scr, "SystemLoadList_00")) fail("another menu opened", now);
|
||||
else if (waited > STEP_MS) fail("the game did not ask to confirm", now);
|
||||
break;
|
||||
}
|
||||
uint64_t b = menu_ui_button("PaCommonBtnThin_00", "Pa_CheckButton_00", NULL);
|
||||
if (!b) { fail("the confirmation has no first button", now); break; }
|
||||
if (menu_ui_focus_to(b)) {
|
||||
char data[1200];
|
||||
path_of(data, sizeof data, "slot");
|
||||
fs_save_read_from(data);
|
||||
m.reading = now, m.back_since = 0;
|
||||
press(B_A, now);
|
||||
enter(ST_LOADING, now);
|
||||
} else if (waited > STEP_MS) fail("the focus did not move to the confirmation", now);
|
||||
break;
|
||||
}
|
||||
case ST_LOADING: // the game fades out and loads: the picture comes back with its fade
|
||||
if (menu_ui_open("LoadingFade_00")) {
|
||||
rt_log("quickload: loading the quick save (%.1f s)", (now - m.started) / 1000.0);
|
||||
end(now);
|
||||
} else if (focus && settled && strcmp(scr, "SystemSaveLoad_00")) {
|
||||
fail("another menu opened instead of loading", now);
|
||||
}
|
||||
else if (waited > LOAD_MS) fail("the load did not start", now);
|
||||
break;
|
||||
case ST_CLEANUP: // B until no menu has the focus box; then the picture comes back
|
||||
if (!focus) { end(now); break; }
|
||||
if (m.tries++ >= MAX_BACK) {
|
||||
rt_log("quickload: a menu stays open after %d presses of B", MAX_BACK);
|
||||
end(now);
|
||||
break;
|
||||
}
|
||||
press(B_B, now);
|
||||
m.gap_until = now + PRESS_MS + 2 * GAP_MS;
|
||||
break;
|
||||
}
|
||||
if (now < m.press_until) *buttons = m.press_bit;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int quicksave_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
if (!m.reading && m.state == ST_IDLE && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_LOAD) return 0;
|
||||
if (!plat_mutex_trylock(&qs_lock)) { // another pad read steps it: this one gets the same presses
|
||||
if (m.state == ST_IDLE) return 0;
|
||||
*buttons = plat_now_ms() < m.press_until ? m.press_bit : 0, *lx = *ly = *rx = *ry = 0;
|
||||
return 1;
|
||||
}
|
||||
int r = poll_locked(buttons, lx, ly, rx, ry);
|
||||
plat_mutex_unlock(&qs_lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
static void guest_locked(Cpu *c);
|
||||
|
||||
// Once per game pad read (ov_input.c), with the reading thread's Cpu: quick save
|
||||
void quicksave_guest(Cpu *c) {
|
||||
if (!saving && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_SAVE) return; // a plain read when idle
|
||||
if (!plat_mutex_trylock(&qs_lock)) return;
|
||||
guest_locked(c);
|
||||
plat_mutex_unlock(&qs_lock);
|
||||
}
|
||||
|
||||
static void guest_locked(Cpu *c) {
|
||||
if (!saving && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_SAVE) return; // a plain read when idle
|
||||
if (saving) {
|
||||
save_wait();
|
||||
plat_cas32(&g_request, REQ_NONE, REQ_SAVE); // a key pressed while it saves is dropped, not queued
|
||||
return;
|
||||
}
|
||||
if (plat_cas32(&g_request, REQ_NONE, REQ_SAVE) != REQ_SAVE || !quicksave_on()) return;
|
||||
if (m.state != ST_IDLE) return;
|
||||
save_start(c);
|
||||
}
|
||||
+56
-23
@@ -58,6 +58,7 @@
|
||||
static struct {
|
||||
int decided;
|
||||
unsigned ow, oh, sw, sh; // output and scene
|
||||
unsigned aw, ah; // the output TOTK_OUTPUT_RES asks for, before shape_fallback
|
||||
int scene_set; // the scene differs from the game's 5/6 of the output
|
||||
int heapdef_ok; // romfs.c serves the grown HeapDef
|
||||
int on; // res_init switched the patch sets on
|
||||
@@ -95,6 +96,19 @@ static int dlss_dll(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int res_dlss_dll(void) {
|
||||
static int dll = -1;
|
||||
if (dll < 0) dll = dlss_dll();
|
||||
return dll;
|
||||
}
|
||||
|
||||
// The engine picked at start can run, as far as is known before the device exists: DLSS needs its DLL (dlss_dll); FSR
|
||||
// 3.1 is built in (vk_fsr3.cpp). Off: nothing to run.
|
||||
static int upscaler_ready(void) {
|
||||
int e = vk_upscaler_engine();
|
||||
return e == UPSCALER_DLSS ? res_dlss_dll() : e == UPSCALER_FSR3;
|
||||
}
|
||||
|
||||
static uint64_t shadow_kib(void);
|
||||
|
||||
// The scene size for a share k of the output, within SCENE_MAX a side and within what a texture heap of DTA_MAX_KIB
|
||||
@@ -117,15 +131,17 @@ static int scene_for(double k, unsigned *w, unsigned *h) {
|
||||
}
|
||||
|
||||
// The scene's share of the output for a TOTK_DLSS mode; 0 for dlaa (the scene keeps base_k), while DLSS/DLAA is off
|
||||
// (the mode the menu still holds would shrink the scene for the plain upscaler) and where DLSS cannot run (dlss_dll).
|
||||
// (the mode the menu still holds would shrink the scene for the plain upscaler) and where the engine picked at start
|
||||
// cannot run (upscaler_ready).
|
||||
static double dlss_share(const char *m) {
|
||||
static const struct { const char *name; double k; } dlss[] = {
|
||||
{"quality", 2.0 / 3.0}, {"balanced", 0.58}, {"performance", 0.5}, {"ultra_performance", 1.0 / 3.0}};
|
||||
static int dll = -1;
|
||||
if (!cfg_bool("TOTK_DLAA")) return 0;
|
||||
static int told;
|
||||
if (!vk_upscaler_on()) return 0;
|
||||
for (int i = 0; i < (int)(sizeof dlss / sizeof dlss[0]); i++)
|
||||
if (!strcmp(m, dlss[i].name)) {
|
||||
if (dll < 0 && !(dll = dlss_dll())) {
|
||||
int ready = upscaler_ready();
|
||||
if (!ready && !told++) {
|
||||
#ifdef _WIN32
|
||||
rt_log("resolution: DLSS %s needs nvngx_dlss.dll next to totk.exe, which is missing: the scene follows "
|
||||
"render_scale", m);
|
||||
@@ -134,7 +150,7 @@ static double dlss_share(const char *m) {
|
||||
"scene follows render_scale", m);
|
||||
#endif
|
||||
}
|
||||
return dll ? dlss[i].k : 0;
|
||||
return ready ? dlss[i].k : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -161,14 +177,14 @@ static void shape_fallback(void) {
|
||||
static void decide(void) {
|
||||
if (R.decided) return;
|
||||
R.decided = 1;
|
||||
R.ow = BASE_W;
|
||||
R.oh = BASE_H;
|
||||
R.ow = R.aw = BASE_W;
|
||||
R.oh = R.ah = BASE_H;
|
||||
const char *o = cfg_value("TOTK_OUTPUT_RES");
|
||||
unsigned w = 0, h = 0;
|
||||
char tail;
|
||||
if (sscanf(o, "%ux%u%c", &w, &h, &tail) == 2 && w >= 1280 && h >= 720 && w <= 7680 && h <= 4320) {
|
||||
R.ow = w & ~1u;
|
||||
R.oh = h & ~1u;
|
||||
R.ow = R.aw = w & ~1u;
|
||||
R.oh = R.ah = h & ~1u;
|
||||
shape_fallback();
|
||||
} else {
|
||||
rt_log("resolution: TOTK_OUTPUT_RES=%s is not <width>x<height> in 1280x720..7680x4320; 1920x1080", o);
|
||||
@@ -191,12 +207,13 @@ static void decide(void) {
|
||||
if (n >= 256 && n <= 4096 && !(n & 7)) R.shadow = n;
|
||||
else rt_log("resolution: TOTK_SHADOW_RES=%s is not game or a size 256..4096 (a multiple of 8); game", sr);
|
||||
}
|
||||
// A DLSS mode other than dlaa sets the scene size instead. On 1.4.3 with DLSS able to run (DLAA on, the DLL there)
|
||||
// A DLSS mode other than dlaa sets the scene size instead. On 1.4.3 with the scene upscaler able to run (DLSS with
|
||||
// its DLL there, or FSR 3.1 in the build)
|
||||
// the mode can change while the game runs (res_dlss_mode): the scene patch is then always on and the heap is sized
|
||||
// for the largest scene the modes ask for. Everyone else keeps the game's own scene size and its dynamic resolution
|
||||
// unless render_scale or a DLSS mode asks for another, and a heap sized for that scene alone.
|
||||
R.base_k = k;
|
||||
R.live = RT_V143 && cfg_bool("TOTK_DLAA") && dlss_dll();
|
||||
R.live = RT_V143 && vk_upscaler_on() && upscaler_ready();
|
||||
const char *m = cfg_value("TOTK_DLSS");
|
||||
R.dlss_k = dlss_share(m);
|
||||
if (R.dlss_k) rt_log("resolution: DLSS %s: the scene at %.0f %% of the output (render_scale ignored)", m, R.dlss_k * 100);
|
||||
@@ -510,9 +527,10 @@ static void shadow_init(uint8_t *page) {
|
||||
// ---- start: the patch page and the sets
|
||||
static uint64_t pack(unsigned w, unsigned h) { return (uint64_t)h << 32 | w; }
|
||||
|
||||
// TOTK_SHADOW_RANGE (percent, 50 to 400; 100 = the game's): the sun's shadow cascades end at 20, 40, 80 and 160 m.
|
||||
// Other values multiply those distances through the cascade patch set (recomp/patches-v143.txt), so the sharp first
|
||||
// cascade reaches further and the visible steps between cascades move away from the player, at the cost of shadow
|
||||
// TOTK_SHADOW_RANGE (percent, 50 to 400; 100 = the game's): the sun's shadow cascades end at 20, 40, 80 and 160 m by
|
||||
// the depth shadow parameters' defaults; in the field the shadow controller computes the boundaries from the camera
|
||||
// each frame instead. Other values multiply the boundaries through the cascade patch set (recomp/patches-v143.txt and
|
||||
// patches-v121.txt; the controller's sites take page +64 over 20 as the factor), so the sharp first cascade reaches further and the visible steps between cascades move away from the player, at the cost of shadow
|
||||
// texels per metre (TOTK_SHADOW_SCALE pays that back).
|
||||
static void res_shadow_range(void) {
|
||||
int pct = cfg_int("TOTK_SHADOW_RANGE"), set = rt_patch_set("cascade");
|
||||
@@ -625,10 +643,10 @@ int res_wants_wide_overlay(const unsigned out[2]) {
|
||||
return !res_is_16x9(out[0], out[1]) && rt_patch_set("aspect") >= 0;
|
||||
}
|
||||
|
||||
// Field of view (TOTK_FOV, percent of the game's own, 70..140, live): the camera's vertical view angle times the
|
||||
// factor on page +60 (recomp/patches-v143.txt, set fov). The horizontal angle follows through the aspect ratio. 100
|
||||
// switches the set off, so the camera code is the game's own. Runs on a settings change (gfx_present.c
|
||||
// window_settings_live), the first time at the first present.
|
||||
// Field of view (TOTK_FOV, percent of the game's own, 70..140, live): the camera's vertical view angle times the factor
|
||||
// on page +60 (recomp/patches-v110.txt, patches-v121.txt and patches-v143.txt, set fov). The horizontal angle follows
|
||||
// through the aspect ratio. 100 switches the set off, so the camera code is the game's own. Runs on a settings change
|
||||
// (gfx_present.c window_settings_live), the first time at the first present.
|
||||
#define FOV_MIN 70
|
||||
#define FOV_MAX 140
|
||||
void res_fov_live(void) {
|
||||
@@ -648,7 +666,7 @@ void res_fov_live(void) {
|
||||
rt_log("resolution: field of view %d%% of the game's", pct);
|
||||
}
|
||||
|
||||
// TOTK_DYNAMIC_RES = 0 holds the game's dynamic resolution at 100 % (recomp/patches-v121.txt and patches-v143.txt,
|
||||
// TOTK_DYNAMIC_RES = 0 holds the game's dynamic resolution at 100 % (patches-v110.txt, patches-v121.txt and patches-v143.txt,
|
||||
// set fixres), so the scene renders at the size render_scale chose. The game picks its tier (100, 90 or 80 %) mostly
|
||||
// from a fixed cost model made for the Switch: one term grows with the object counts, one with (scene width / 1600)
|
||||
// squared. The GPU time it also measures (two NVN report timestamps, a frame apart) only lowers that prediction when the
|
||||
@@ -656,19 +674,29 @@ void res_fov_live(void) {
|
||||
// 2867-wide scene stays at 100 %, one wider than about 2970 does not, and a 4267-wide one (5120x1440 at render_scale
|
||||
// 83) fits no tier and falls back to 80 % every frame, whatever the GPU's load. 1 (the default) leaves the game's own
|
||||
// stepping and the set off. Runs on a settings change (gfx_present.c window_settings_live), like res_fov_live.
|
||||
// FSR 3.1 as the scene upscaler holds it at 100 % whatever dynamic_res says, as codexx-dev's pull request #1245 does
|
||||
// for its FSR: each tier is a scene of another size, so every step starts FSR's history again, and below 100 % the
|
||||
// game ends its frame another way (a frame log on 1.4.3: its copy shader scales the scene straight into the
|
||||
// output-sized target instead of the scaling FXAA draw), which #1245 measured as a picture that went soft and sharp in
|
||||
// turns at a 2560x1440 scene. A 1280x720 scene (1080p, quality) stayed at 100 % through a 70 s town run, so it gains
|
||||
// nothing there; the hold matters for the wide scenes the cost model steps down.
|
||||
void res_dynres_live(void) {
|
||||
static int set = -2, shown = -1;
|
||||
if (set == -2) set = rt_patch_set("fixres");
|
||||
int dyn = cfg_bool("TOTK_DYNAMIC_RES");
|
||||
if (dyn == shown) return;
|
||||
shown = dyn;
|
||||
int fsr = vk_upscaler_on() && vk_upscaler_engine() == UPSCALER_FSR3;
|
||||
int dyn = cfg_bool("TOTK_DYNAMIC_RES") && !fsr;
|
||||
int state = dyn | fsr << 1;
|
||||
if (state == shown) return;
|
||||
shown = state;
|
||||
if (set < 0) {
|
||||
if (!dyn) rt_log("resolution: this game version has no fixed-resolution patch; the game keeps its dynamic resolution");
|
||||
return;
|
||||
}
|
||||
rt_patch_switch(set, !dyn);
|
||||
rt_log("resolution: dynamic resolution %s",
|
||||
dyn ? "on: the game's own 100, 90 or 80 %" : "off: the scene stays at 100 %");
|
||||
dyn ? "on: the game's own 100, 90 or 80 %"
|
||||
: fsr ? "off while FSR 3.1 upscales the scene: the scene stays at 100 %"
|
||||
: "off: the scene stays at 100 %");
|
||||
}
|
||||
|
||||
void res_wanted(unsigned out[2]) {
|
||||
@@ -676,6 +704,11 @@ void res_wanted(unsigned out[2]) {
|
||||
out[0] = R.ow, out[1] = R.oh;
|
||||
}
|
||||
|
||||
void res_asked(unsigned out[2]) {
|
||||
decide();
|
||||
out[0] = R.aw, out[1] = R.ah;
|
||||
}
|
||||
|
||||
// A TOTK_DLSS change while the game runs (vk_dlaa.c, at a present): the new scene size goes to the patch page, where
|
||||
// the game reads it when it sets its render size (main+0x585e48). 1.4.3 does that once, at start: its renderer setup
|
||||
// (main+0x7000e67028) calls main+0x585bd0(renderer, force), which picks the console mode's sizes and flags the render
|
||||
|
||||
+174
-85
@@ -467,7 +467,8 @@ static const char *owner_name(const Overlay *o) {
|
||||
return o->mod ? mods_at(o->mod - 1)->name : o->prio ? "romfs_mods" : "the port's patches";
|
||||
}
|
||||
|
||||
// One overlay per path: the highest prio serves it; the others are dropped and counted on their mod.
|
||||
// One overlay per path: the highest prio serves it; the others are dropped and counted on their mod, and a file one
|
||||
// mod takes from another goes into the conflict table (mods_conflict).
|
||||
static void overlay_contest(void) {
|
||||
if (!noverlay) return;
|
||||
qsort(overlays, noverlay, sizeof *overlays, contest_order);
|
||||
@@ -478,7 +479,7 @@ static void overlay_contest(void) {
|
||||
if (o->mod) {
|
||||
ModInfo *m = mods_at(o->mod - 1);
|
||||
m->overridden++;
|
||||
if (!m->overridden_by[0]) snprintf(m->overridden_by, sizeof m->overridden_by, "%s", owner_name(w));
|
||||
if (w->mod) mods_conflict(mods_at(w->mod - 1)->id, m->id, MOD_PART_FILES, 1);
|
||||
} else if (w->mod) {
|
||||
rt_log("RomFS overlay: %s from mod %s replaces the one of %s", o->name, owner_name(w), owner_name(o));
|
||||
}
|
||||
@@ -509,10 +510,10 @@ static void mods_overlay_log(void) {
|
||||
for (int k = 0; k < mods_count(); k++) {
|
||||
const ModInfo *m = mods_at(k);
|
||||
if (!m->enabled || !(m->kind & MOD_ROMFS) || m->problem != MOD_OK) continue;
|
||||
rt_log("mods: %s: %u files served (%u replaced, %u added), %u overridden%s%s, %u for another game version",
|
||||
m->name, m->replaced + m->added, m->replaced, m->added, m->overridden, m->overridden ? " by " : "",
|
||||
m->overridden_by, m->other_version);
|
||||
rt_log("mods: %s: %u files served (%u replaced, %u added), %u overridden, %u for another game version",
|
||||
m->name, m->replaced + m->added, m->replaced, m->added, m->overridden, m->other_version);
|
||||
}
|
||||
mods_conflicts_log(MOD_PART_FILES);
|
||||
}
|
||||
|
||||
static int overlay_order(const void *a, const void *b) {
|
||||
@@ -933,14 +934,15 @@ static void camera_overlay(void) {
|
||||
// did not load (ROMFS_PROMPTS_*). The menu compares them with the settings in effect (ui/menu.cpp prompts_note).
|
||||
// Each folder keeps its name, but at a game resolution of another shape than 16:9 its files come from dir,
|
||||
// <name>-<w>x<h> (overlay_init), and ready is that one's.
|
||||
static struct { const char *name; int ready; char dir[64]; } prompts_folders[3];
|
||||
#define PROMPTS_FOLDERS 5 // the two Xbox folders, the two PlayStation ones, the PC one (overlay_init)
|
||||
static struct { const char *name; int ready; char dir[64]; } prompts_folders[PROMPTS_FOLDERS];
|
||||
static const char *prompts_wanted, *prompts_loaded;
|
||||
static int prompts_off;
|
||||
|
||||
const char *romfs_prompts(void) { return prompts_loaded; }
|
||||
|
||||
int romfs_prompts_ready(const char *folder) {
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < PROMPTS_FOLDERS; i++)
|
||||
if (folder && prompts_folders[i].name && !strcmp(prompts_folders[i].name, folder)) return prompts_folders[i].ready;
|
||||
return 0;
|
||||
}
|
||||
@@ -969,39 +971,60 @@ static void overlay_drop(size_t a, size_t b) {
|
||||
noverlay -= b - a;
|
||||
}
|
||||
|
||||
// The folder <prefix>-<w>x<h> the game resolution w x h takes in base: that exact size when it has a manifest (an
|
||||
// The HUD cap for the canonical shape. An inapplicable cap is full, as in installer/steps.py shape_hud. The generator
|
||||
// takes that same shape, so a resolution alias near the one-percent boundary cannot ask for an invalid variant.
|
||||
static const char *hud_suffix(unsigned w, unsigned h) {
|
||||
unsigned shape[2] = {w, h};
|
||||
cfg_shape_size(w, h, shape);
|
||||
const char *value = cfg_value("TOTK_HUD_WIDTH");
|
||||
double cap = !strcmp(value, "21:9") ? 21.0 / 9 : !strcmp(value, "16:9") ? 16.0 / 9 : 0;
|
||||
return cap && shape[1] && cap < (double)shape[0] / shape[1] * 0.99
|
||||
? (cap > 2 ? "-hud21x9" : "-hud16x9") : "";
|
||||
}
|
||||
|
||||
// The folder <prefix>-<w>x<h><suffix> the game resolution w x h takes in base: that exact size when it has a manifest (an
|
||||
// install by a setup that wrote every size, or make_romfs_patches.py --aspect <w>x<h> in a source build), else the
|
||||
// size of its shape (cfg.c cfg_shape_size), the one folder per shape installer/steps.py Shapes writes. name gets the
|
||||
// folder found, or the shape's one when neither has a manifest (for the log). 1 when found.
|
||||
static int shaped_name(const char *base, const char *prefix, unsigned w, unsigned h, char *name, size_t cap) {
|
||||
static int shaped_name(const char *base, const char *prefix, unsigned w, unsigned h, const char *suffix,
|
||||
char *name, size_t cap) {
|
||||
char path[2400];
|
||||
unsigned s[2] = {w, h};
|
||||
for (int pass = 0; pass < 2; pass++) {
|
||||
if (pass && !cfg_shape_size(w, h, s)) break;
|
||||
if (pass && s[0] == w && s[1] == h) break;
|
||||
snprintf(name, cap, "%s-%ux%u", prefix, s[0], s[1]);
|
||||
if (snprintf(name, cap, "%s-%ux%u%s", prefix, s[0], s[1], suffix) >= (int)cap) return 0;
|
||||
if (snprintf(path, sizeof path, "%s/%s/manifest.tsv", base, name) < (int)sizeof path && plat_file_exists(path))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Prefer the selected HUD at both exact and canonical sizes. Boot may fall back to the full HUD, but preparation
|
||||
// and the menu's missing-layout note use strict lookup so a full layout cannot hide a missing capped variant.
|
||||
static int selected_shape(const char *base, const char *prefix, unsigned w, unsigned h, char *name, size_t cap,
|
||||
int fallback) {
|
||||
const char *suffix = hud_suffix(w, h);
|
||||
if (shaped_name(base, prefix, w, h, suffix, name, cap)) return 1;
|
||||
return fallback && *suffix && shaped_name(base, prefix, w, h, "", name, cap);
|
||||
}
|
||||
|
||||
static void overlay_init(void) {
|
||||
// TOTK_ROMFS_PATCHES unset: romfs-patches next to romfs-index.bin if it has a manifest (tools/make_romfs_patches.py).
|
||||
// A game resolution that is not 16:9 takes romfs-patches-<w>x<h> instead when it is there (shaped_name: the exact
|
||||
// size, else the folder of its shape): the same overlay with the UI laid out for that shape
|
||||
// (make_romfs_patches.py --aspect), when the game version has the camera aspect patch the layout goes with
|
||||
// (res_wants_wide_overlay).
|
||||
// With prompts = xbox, the Xbox prompts' folder for the pad layout in its place (input_prompts_folder): the same
|
||||
// patches with Xbox button icons (make_romfs_patches.py --prompts); prompts = pc takes romfs-patches-pc whatever
|
||||
// the pad layout. The game reads the archives once at boot, so the prompts stay until restart even though the
|
||||
// layout itself changes live. Each folder replaces romfs-patches as a whole. At a game resolution of another shape
|
||||
// the prompts come from <folder>-<w>x<h> (make_romfs_patches.py --prompts <style> --aspect): it carries that
|
||||
// shape's UI layout too, so it replaces romfs-patches-<w>x<h> as the folder replaces romfs-patches. Without it the
|
||||
// Switch prompts stay with the shape's layout. So they do when a RomFS mod (the TOTK_ROMFS_MODS manifest or a
|
||||
// player mod) replaces one of the prompts' fonts: romfs-patches loads in their place, so the mod's file is not
|
||||
// served beside prompts files made for the game's own. A mod's resource size table is no clash: restbl_overlay
|
||||
// merges it with the prompts' one.
|
||||
// With prompts = xbox or playstation, that controller's prompts' folder for the pad layout in its place
|
||||
// (input_prompts_folder): the same patches with Xbox or PlayStation button icons (make_romfs_patches.py
|
||||
// --prompts); prompts = pc takes romfs-patches-pc whatever the pad layout. The game reads the archives once at
|
||||
// boot, so the prompts stay until restart even though the layout itself changes live. Each folder replaces
|
||||
// romfs-patches as a whole. At a game resolution of another shape the prompts come from <folder>-<w>x<h>
|
||||
// (make_romfs_patches.py --prompts <style> --aspect): it carries that shape's UI layout too, so it replaces
|
||||
// romfs-patches-<w>x<h> as the folder replaces romfs-patches. Without it the Switch prompts stay with the shape's
|
||||
// layout. So they do when a RomFS mod (the TOTK_ROMFS_MODS manifest or a player mod) replaces one of the prompts'
|
||||
// fonts: romfs-patches loads in their place, so the mod's file is not served beside prompts files made for the
|
||||
// game's own. A mod's resource size table is no clash: restbl_overlay merges it with the prompts' one.
|
||||
char def[2100], path[2100];
|
||||
const char *patches = cfg_get("TOTK_ROMFS_PATCHES"), *mods = cfg_get("TOTK_ROMFS_MODS");
|
||||
int wide = 0;
|
||||
@@ -1011,22 +1034,31 @@ static void overlay_init(void) {
|
||||
cfg_shape_size(out[0], out[1], shape);
|
||||
if (!patches && res_wants_wide_overlay(out)) {
|
||||
char name[128];
|
||||
if (shaped_name(index_dir, "romfs-patches", out[0], out[1], name, sizeof name) &&
|
||||
if (selected_shape(index_dir, "romfs-patches", out[0], out[1], name, sizeof name, 1) &&
|
||||
snprintf(def, sizeof def, "%s/%s", index_dir, name) < (int)sizeof def) {
|
||||
patches = def, wide = 1;
|
||||
rt_log("RomFS overlay: the UI layout for %ux%u from %s", out[0], out[1], name);
|
||||
const char *suffix = hud_suffix(out[0], out[1]);
|
||||
if (*suffix && !ends_with(name, suffix))
|
||||
rt_log("RomFS overlay: the selected HUD layout is missing; using the full HUD (an install makes it "
|
||||
"in the background below; a source build: tools/make_romfs_patches.py --aspect %ux%u --hud %s)",
|
||||
shape[0], shape[1], cfg_value("TOTK_HUD_WIDTH"));
|
||||
} else {
|
||||
rt_log("RomFS overlay: no %s for this game resolution, the UI keeps its 16:9 layout (run the setup again, "
|
||||
"or tools/make_romfs_patches.py --aspect %ux%u)", name, shape[0], shape[1]);
|
||||
}
|
||||
}
|
||||
static const char *const layouts[2] = {"nintendo", "xbox"}; // one of each Xbox folder, then the PC one
|
||||
for (int i = 0; i < 3; i++) {
|
||||
const char *name = i < 2 ? input_prompts_folder(PROMPTS_XBOX, layouts[i]) : input_prompts_folder(PROMPTS_PC, 0);
|
||||
// one of each Xbox and PlayStation folder, then the PC one
|
||||
static const char *const layouts[2] = {"nintendo", "xbox"};
|
||||
for (int i = 0; i < PROMPTS_FOLDERS; i++) {
|
||||
const char *name = i < 2 ? input_prompts_folder(PROMPTS_XBOX, layouts[i])
|
||||
: i < 4 ? input_prompts_folder(PROMPTS_PLAYSTATION, layouts[i - 2])
|
||||
: input_prompts_folder(PROMPTS_PC, 0);
|
||||
char *dir = prompts_folders[i].dir;
|
||||
prompts_folders[i].name = name;
|
||||
if (wide) {
|
||||
prompts_folders[i].ready = shaped_name(index_dir, name, out[0], out[1], dir, sizeof prompts_folders[i].dir);
|
||||
prompts_folders[i].ready = selected_shape(index_dir, name, out[0], out[1], dir,
|
||||
sizeof prompts_folders[i].dir, 1);
|
||||
continue;
|
||||
}
|
||||
snprintf(dir, sizeof prompts_folders[i].dir, "%s", name);
|
||||
@@ -1035,11 +1067,17 @@ static void overlay_init(void) {
|
||||
}
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
|
||||
int pick = input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout);
|
||||
const char *style = pick == PROMPTS_PC ? "keyboard and mouse" : "Xbox";
|
||||
const char *style = pick == PROMPTS_PC ? "keyboard and mouse"
|
||||
: pick == PROMPTS_PLAYSTATION ? "PlayStation"
|
||||
: "Xbox";
|
||||
prompts_wanted = input_prompts_folder(pick, layout);
|
||||
const char *wanted_dir = prompts_wanted; // the folder its files come from
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < PROMPTS_FOLDERS; i++)
|
||||
if (prompts_wanted && !strcmp(prompts_folders[i].name, prompts_wanted)) wanted_dir = prompts_folders[i].dir;
|
||||
const char *suffix = hud_suffix(out[0], out[1]);
|
||||
if (wide && prompts_wanted && romfs_prompts_ready(prompts_wanted) && *suffix && !ends_with(wanted_dir, suffix))
|
||||
rt_log("RomFS overlay: the %s prompts have no selected HUD layout; their full HUD loads instead (an "
|
||||
"install makes it in the background below)", style);
|
||||
prompts_off = !prompts_wanted ? ROMFS_PROMPTS_OK
|
||||
: patches && !wide ? ROMFS_PROMPTS_PATCHES
|
||||
: !romfs_prompts_ready(prompts_wanted) ? (wide ? ROMFS_PROMPTS_SHAPE : ROMFS_PROMPTS_MISSING)
|
||||
@@ -1066,8 +1104,18 @@ static void overlay_init(void) {
|
||||
snprintf(why, sizeof why, "%s", prompts_off == ROMFS_PROMPTS_PATCHES
|
||||
? "TOTK_ROMFS_PATCHES is set"
|
||||
: "their folder has no manifest.tsv (run the setup again)");
|
||||
rt_log("RomFS overlay: prompts = %s, but %s; Switch prompts stay", pick == PROMPTS_PC ? "pc" : "xbox", why);
|
||||
rt_log("RomFS overlay: prompts = %s, but %s; Switch prompts stay",
|
||||
pick == PROMPTS_PC ? "pc" : pick == PROMPTS_PLAYSTATION ? "playstation" : "xbox", why);
|
||||
}
|
||||
// A folder the settings in effect ask for and the install lacks (an older setup, a failed setup step, a display
|
||||
// of another shape): its generator starts in the background for the next start when the setup's tools are next to
|
||||
// the game (romfs_folders_prepare). The size is the one output_res asks for: without its shape's layout the game
|
||||
// draws 16:9 this time (resolution.c shape_fallback). Without an output_res it is the display's shape, which the
|
||||
// default keeps only while that shape has the prompts' folder (cfg.c cfg_screen_size). Nothing with
|
||||
// TOTK_ROMFS_PATCHES set; a source build has no build-cache/rebuild.txt and keeps the lines above.
|
||||
unsigned asked[2];
|
||||
if (!cfg_screen_size(asked)) res_asked(asked);
|
||||
romfs_folders_prepare(asked[0], asked[1], prompts_wanted);
|
||||
size_t prompts_end = noverlay;
|
||||
char plain[2100]; // romfs-patches, when it has a manifest
|
||||
int plain_ok = snprintf(plain, sizeof plain, "%s/romfs-patches/manifest.tsv", index_dir) < (int)sizeof plain &&
|
||||
@@ -1127,27 +1175,33 @@ static void index_folder(char *dir, size_t cap) {
|
||||
}
|
||||
|
||||
// 1 when the folder overlay_init takes for <prefix> at w x h (shaped_name) has a manifest next to romfs-index.bin.
|
||||
static int shaped_folder_ready(const char *prefix, unsigned w, unsigned h) {
|
||||
static int shaped_folder_ready(const char *prefix, unsigned w, unsigned h, int fallback) {
|
||||
char dir[2100], name[128];
|
||||
index_folder(dir, sizeof dir);
|
||||
return shaped_name(dir, prefix, w, h, name, sizeof name);
|
||||
return selected_shape(dir, prefix, w, h, name, sizeof name, fallback);
|
||||
}
|
||||
|
||||
// 1 when the game resolution w x h has the UI layout of its shape: romfs-patches-<w>x<h> of that size or of its shape,
|
||||
// the folder overlay_init looks for.
|
||||
int romfs_shaped_ready(unsigned w, unsigned h) { return shaped_folder_ready("romfs-patches", w, h); }
|
||||
int romfs_shaped_ready(unsigned w, unsigned h) { return shaped_folder_ready("romfs-patches", w, h, 1); }
|
||||
|
||||
// 1 when it has a prompts' folder (input_prompts_folder) with that layout too: <folder>-<w>x<h>, which overlay_init
|
||||
// loads in its place with those prompts.
|
||||
int romfs_shaped_prompts_ready(const char *folder, unsigned w, unsigned h) { return shaped_folder_ready(folder, w, h); }
|
||||
int romfs_shaped_prompts_ready(const char *folder, unsigned w, unsigned h) { return shaped_folder_ready(folder, w, h, 1); }
|
||||
|
||||
// ---- the layout for a new screen, from the settings menu (ui/menu.cpp row_output_res)
|
||||
// The setup writes the shaped folders for the displays connected when it ran (installer/steps.py Shapes). After a
|
||||
// monitor change the menu can start the same generator for the shape of the game resolution: the setup's Python and
|
||||
// tools/make_romfs_patches.py, which build-cache/rebuild.txt names (installer/steps.py write_rebuild_command: line 1 the
|
||||
// Python, pythonw on Windows, so no console opens; line 4 the setup's folder), on the install folder's romfs/. Child
|
||||
// processes the game does not wait for: the generator writes manifest.tsv last, so a folder it has not finished is not
|
||||
// taken, and the next start loads the finished one.
|
||||
// ---- missing folders, made in the background (the settings menu, ui/menu.cpp folders_tick, and the start,
|
||||
// overlay_init)
|
||||
// The setup writes the 16:9 prompts' folders on every install (installer/steps.py Prepare, PcPrompts) and the shaped
|
||||
// folders for the displays connected when it ran (Shapes). An install by an older setup, a failed setup step, a
|
||||
// monitor change or a change of resolution, HUD width, prompts or pad layout can ask for a folder it did not write.
|
||||
// The game then starts the same generator: the setup's Python and tools/make_romfs_patches.py, which
|
||||
// build-cache/rebuild.txt names (installer/steps.py write_rebuild_command: line 1 the Python, pythonw on Windows, so
|
||||
// no console opens; line 4 the setup's folder; both relative to the install folder for the build kit,
|
||||
// installer/layout.py), on the install folder's romfs/. Child processes the game does not wait for. With --background
|
||||
// the generator writes into a folder of its own beside the output and renames it into place at the end, unless a
|
||||
// folder with a manifest is there by then: a folder this game or another start loaded is never written into, and two
|
||||
// generators for one folder (the menu and the start, or a restart while the last one runs) do not mix their files.
|
||||
// The next start loads the finished folder.
|
||||
static int prepare_tools(char *python, size_t pcap, char *script, size_t scap, char *dir, size_t dcap) {
|
||||
char path[2400];
|
||||
index_folder(dir, dcap);
|
||||
@@ -1165,21 +1219,35 @@ static int prepare_tools(char *python, size_t pcap, char *script, size_t scap, c
|
||||
lines[k++] = p;
|
||||
p = e + 1;
|
||||
}
|
||||
int ok = k >= 4 && !strcmp(lines[1], "-c") && snprintf(python, pcap, "%s", lines[0]) < (int)pcap &&
|
||||
snprintf(script, scap, "%s/tools/make_romfs_patches.py", lines[3]) < (int)scap;
|
||||
int ok = k >= 4 && !strcmp(lines[1], "-c");
|
||||
if (ok) { // the build kit's lines are relative to the install folder
|
||||
const char *at0 = plat_path_absolute(lines[0]) ? "" : dir, *at3 = plat_path_absolute(lines[3]) ? "" : dir;
|
||||
ok = snprintf(python, pcap, "%s%s%s", at0, *at0 ? "/" : "", lines[0]) < (int)pcap &&
|
||||
snprintf(script, scap, "%s%s%s/tools/make_romfs_patches.py", at3, *at3 ? "/" : "", lines[3]) < (int)scap;
|
||||
}
|
||||
free(text);
|
||||
snprintf(path, sizeof path, "%s/romfs/romfs.bin", dir);
|
||||
return ok && plat_file_exists(python) && plat_file_exists(script) && plat_file_exists(path);
|
||||
}
|
||||
|
||||
int romfs_shape_missing(unsigned w, unsigned h, const char *prompts_folder) {
|
||||
unsigned out[2] = {w, h};
|
||||
if (!res_wants_wide_overlay(out)) return 0;
|
||||
return !shaped_folder_ready("romfs-patches", w, h) ||
|
||||
(prompts_folder && romfs_prompts_ready(prompts_folder) && !shaped_folder_ready(prompts_folder, w, h));
|
||||
// 1 when folder (a name next to romfs-index.bin) has a manifest.
|
||||
static int plain_folder_ready(const char *folder) {
|
||||
char dir[2100], path[2400];
|
||||
index_folder(dir, sizeof dir);
|
||||
return snprintf(path, sizeof path, "%s/%s/manifest.tsv", dir, folder) < (int)sizeof path && plat_file_exists(path);
|
||||
}
|
||||
|
||||
int romfs_shape_can_prepare(void) {
|
||||
int romfs_folders_missing(unsigned w, unsigned h, const char *prompts_folder) {
|
||||
unsigned out[2] = {w, h};
|
||||
if (cfg_get("TOTK_ROMFS_PATCHES")) return 0;
|
||||
int need = prompts_folder && !plain_folder_ready(prompts_folder) ? ROMFS_NEED_PROMPTS : 0;
|
||||
if (!res_wants_wide_overlay(out)) return need;
|
||||
if (!shaped_folder_ready("romfs-patches", w, h, 0)) need |= ROMFS_NEED_LAYOUT;
|
||||
if (prompts_folder && !shaped_folder_ready(prompts_folder, w, h, 0)) need |= ROMFS_NEED_SHAPED_PROMPTS;
|
||||
return need;
|
||||
}
|
||||
|
||||
int romfs_folders_can_prepare(void) {
|
||||
static int known = -1;
|
||||
if (known < 0) {
|
||||
char python[1024], script[1100], dir[2100];
|
||||
@@ -1188,11 +1256,12 @@ int romfs_shape_can_prepare(void) {
|
||||
return known;
|
||||
}
|
||||
|
||||
// The folders a generator was started for in this process. The menu thread alone calls romfs_shape_prepare, so no
|
||||
// lock. The game picks its overlay at start, so a folder is not started twice before the next start, even when its
|
||||
// generator has ended: a second click, or the same size chosen again, starts no second generator writing into it.
|
||||
static char shape_started[8][160];
|
||||
static int shape_started_n;
|
||||
// The folders a generator was started for in this process, under shape_lock: the start (overlay_init) and the menu
|
||||
// thread both start them. The game picks its overlay at start, so a folder is not started twice before the next start,
|
||||
// even when its generator has ended: the same setting chosen again starts no second generator for it.
|
||||
static PlatMutex shape_lock = PLAT_MUTEX_INIT;
|
||||
static char (*shape_started)[160];
|
||||
static int shape_started_n, shape_started_cap;
|
||||
|
||||
static int shape_was_started(const char *folder) {
|
||||
for (int i = 0; i < shape_started_n; i++)
|
||||
@@ -1201,51 +1270,71 @@ static int shape_was_started(const char *folder) {
|
||||
}
|
||||
|
||||
// Starts the generator for folder (a name in dir) unless one was started for it before. 1 when one runs for it, 0 when
|
||||
// it could not start. plat_spawn starts it detached and closes its handles without waiting, so a click costs the menu
|
||||
// thread one CreateProcess.
|
||||
// it could not start. plat_spawn starts it detached and closes its handles without waiting, so a start costs the
|
||||
// calling thread one CreateProcess.
|
||||
static int shape_spawn(const char *const *argv, const char *dir, const char *folder) {
|
||||
if (shape_was_started(folder)) return 1;
|
||||
if (!plat_spawn(argv, dir)) return 0;
|
||||
if (shape_started_n < (int)(sizeof shape_started / sizeof *shape_started))
|
||||
snprintf(shape_started[shape_started_n++], sizeof *shape_started, "%s", folder);
|
||||
return 1;
|
||||
plat_mutex_lock(&shape_lock);
|
||||
int ok = 1;
|
||||
if (!shape_was_started(folder)) {
|
||||
if (shape_started_n == shape_started_cap) {
|
||||
int cap = shape_started_cap ? shape_started_cap * 2 : 8;
|
||||
void *grown = realloc(shape_started, (size_t)cap * sizeof *shape_started);
|
||||
if (grown) shape_started = grown, shape_started_cap = cap;
|
||||
}
|
||||
// never start a writer whose folder cannot be remembered for deduplication
|
||||
ok = shape_started_n < shape_started_cap && plat_spawn(argv, dir);
|
||||
if (ok) snprintf(shape_started[shape_started_n++], sizeof *shape_started, "%s", folder);
|
||||
}
|
||||
plat_mutex_unlock(&shape_lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
int romfs_shape_prepare(unsigned w, unsigned h, const char *prompts_folder) {
|
||||
int romfs_folders_prepare(unsigned w, unsigned h, const char *prompts_folder) {
|
||||
char python[1024], script[1100], dir[2100], romfs[2200], out[2300], reuse[2300], binds[2300], size[32], version[8],
|
||||
name[128], folder[160];
|
||||
unsigned s[2];
|
||||
if (!cfg_shape_size(w, h, s) || !prepare_tools(python, sizeof python, script, sizeof script, dir, sizeof dir))
|
||||
return 0;
|
||||
folder[160];
|
||||
int need = romfs_folders_missing(w, h, prompts_folder);
|
||||
if (!need || !prepare_tools(python, sizeof python, script, sizeof script, dir, sizeof dir)) return 0;
|
||||
unsigned s[2] = {w, h};
|
||||
int shaped = cfg_shape_size(w, h, s);
|
||||
snprintf(size, sizeof size, "%ux%u", s[0], s[1]);
|
||||
snprintf(version, sizeof version, "v%d", rt_game_version);
|
||||
snprintf(romfs, sizeof romfs, "%s/romfs", dir);
|
||||
const char *suffix = shaped ? hud_suffix(w, h) : "", *hud = *suffix ? cfg_value("TOTK_HUD_WIDTH") : "full";
|
||||
const char *style = prompts_folder ? prompts_folder + strlen("romfs-patches-") : NULL;
|
||||
// The keyboard and mouse prompts are drawn from totk.ini's bind_ lines, as the setup's PcPrompts and Shapes steps
|
||||
// draw them (installer/steps.py pc_binds); a file without such lines gives the keyboard defaults.
|
||||
snprintf(binds, sizeof binds, "%s/totk.ini", dir);
|
||||
int pc = style && !strcmp(style, "pc") && plat_file_exists(binds);
|
||||
static const int order[3] = {ROMFS_NEED_PROMPTS, ROMFS_NEED_LAYOUT, ROMFS_NEED_SHAPED_PROMPTS};
|
||||
int started = 0, failed = 0;
|
||||
if (!shaped_name(dir, "romfs-patches", w, h, name, sizeof name)) {
|
||||
snprintf(folder, sizeof folder, "romfs-patches-%s", size);
|
||||
for (int k = 0; k < 3; k++) {
|
||||
int what = order[k];
|
||||
if (!(need & what) || (what != ROMFS_NEED_PROMPTS && !shaped)) continue;
|
||||
if (what == ROMFS_NEED_PROMPTS) snprintf(folder, sizeof folder, "%s", prompts_folder);
|
||||
else if (what == ROMFS_NEED_LAYOUT) snprintf(folder, sizeof folder, "romfs-patches-%s%s", size, suffix);
|
||||
else snprintf(folder, sizeof folder, "%s-%s%s", prompts_folder, size, suffix);
|
||||
snprintf(out, sizeof out, "%s/%s", dir, folder);
|
||||
const char *argv[] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--aspect", size,
|
||||
NULL};
|
||||
const char *argv[24] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--background"};
|
||||
int argc = 9;
|
||||
if (what != ROMFS_NEED_LAYOUT) argv[argc++] = "--prompts", argv[argc++] = style;
|
||||
if (what != ROMFS_NEED_PROMPTS) {
|
||||
argv[argc++] = "--aspect", argv[argc++] = size;
|
||||
argv[argc++] = "--hud", argv[argc++] = hud;
|
||||
}
|
||||
// The shaped prompts differ from their 16:9 folder in the UI archive alone, so its fonts are linked, not
|
||||
// compressed again; a 16:9 folder still being made has nothing to link yet.
|
||||
if (what == ROMFS_NEED_SHAPED_PROMPTS && !(need & ROMFS_NEED_PROMPTS)) {
|
||||
snprintf(reuse, sizeof reuse, "%s/%s", dir, prompts_folder);
|
||||
argv[argc++] = "--reuse", argv[argc++] = reuse;
|
||||
}
|
||||
if (pc && what != ROMFS_NEED_LAYOUT) argv[argc++] = "--binds", argv[argc++] = binds;
|
||||
argv[argc] = NULL;
|
||||
if (shape_spawn(argv, dir, folder)) started++;
|
||||
else failed++;
|
||||
}
|
||||
snprintf(reuse, sizeof reuse, "%s/%s/manifest.tsv", dir, prompts_folder ? prompts_folder : "");
|
||||
if (prompts_folder && plat_file_exists(reuse) && !shaped_name(dir, prompts_folder, w, h, name, sizeof name)) {
|
||||
const char *style = prompts_folder + strlen("romfs-patches-");
|
||||
snprintf(reuse, sizeof reuse, "%s/%s", dir, prompts_folder);
|
||||
snprintf(folder, sizeof folder, "%s-%s", prompts_folder, size);
|
||||
snprintf(out, sizeof out, "%s/%s", dir, folder);
|
||||
// The keyboard and mouse prompts are drawn from totk.ini's bind_ lines, as the setup's PcPrompts and Shapes
|
||||
// steps draw them (installer/steps.py pc_binds); a file without such lines gives the keyboard defaults.
|
||||
snprintf(binds, sizeof binds, "%s/totk.ini", dir);
|
||||
int pc = !strcmp(style, "pc") && plat_file_exists(binds);
|
||||
const char *argv[] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--prompts", style,
|
||||
"--aspect", size, "--reuse", reuse, pc ? "--binds" : NULL, binds, NULL};
|
||||
if (shape_spawn(argv, dir, folder)) started++;
|
||||
else failed++;
|
||||
}
|
||||
rt_log("RomFS overlay: making the layout for %s in the background (%d generators running, %d failed; %s)", size,
|
||||
started, failed, script);
|
||||
rt_log("RomFS overlay: making %d missing folder%s for %ux%u%s%s in the background (%d failed to start; %s)",
|
||||
started + failed, started + failed == 1 ? "" : "s", w, h, style ? ", prompts " : "", style ? style : "",
|
||||
failed, script);
|
||||
return started && !failed;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ layout(local_size_x = 8, local_size_y = 8) in;
|
||||
|
||||
layout(binding = 0) uniform sampler2D lin_depth; // the game's linear depth: view distance / far
|
||||
layout(binding = 1, r11f_g11f_b10f) uniform image2D scene; // the lit scene colour, darkened in place
|
||||
layout(binding = 2) uniform sampler2D sun_vis; // half-resolution lighting: alpha is sun visibility
|
||||
|
||||
layout(push_constant) uniform Params {
|
||||
vec4 proj; // projection x scale, y scale, far plane, strength (0..1)
|
||||
vec4 light; // view-space direction toward the sun (xyz), march length in metres at 10 m (w)
|
||||
vec4 size; // width, height, 1/width, 1/height
|
||||
vec4 opt; // x: debug (1: write the shadow factor as grey)
|
||||
vec4 opt; // x: debug (1: the shadow factor as grey, 2: the sun visibility), y: 1 with sun_vis bound
|
||||
} pc;
|
||||
|
||||
vec3 view_pos(vec2 uv, float z) { // z: distance in front of the camera
|
||||
@@ -58,6 +59,14 @@ void main() {
|
||||
float z = d * pc.proj.z;
|
||||
if (z > 80.0) return;
|
||||
vec2 uv = (vec2(px) + 0.5) * pc.size.zw;
|
||||
// Direct sunlight on this pixel as the game's lighting found it: 0 in the shadow maps' shadow and underground, where
|
||||
// darkening would take away ambient light and texture detail (flat caves). Without that pass every pixel counts as lit.
|
||||
float vis = pc.opt.y > 0.5 ? textureLod(sun_vis, uv, 0.0).a : 1.0;
|
||||
if (pc.opt.x > 1.5) {
|
||||
imageStore(scene, px, vec4(vis, vis, vis, 1.0));
|
||||
return;
|
||||
}
|
||||
if (vis <= 0.0 && pc.opt.x < 0.5) return;
|
||||
vec3 p = view_pos(uv, z);
|
||||
// A contact shadow can only take away direct sunlight, and a surface turned away from the sun gets none: its march
|
||||
// runs into the surface itself at once, and darkening it would darken the ambient light and the fog the composite
|
||||
@@ -84,7 +93,7 @@ void main() {
|
||||
}
|
||||
}
|
||||
float fade = 1.0 - smoothstep(40.0, 80.0, z);
|
||||
float k = 1.0 - pc.proj.w * occ * fade * lit;
|
||||
float k = 1.0 - pc.proj.w * occ * fade * lit * vis;
|
||||
if (pc.opt.x > 0.5) {
|
||||
imageStore(scene, px, vec4(k, k, k, 1.0));
|
||||
return;
|
||||
|
||||
@@ -27,8 +27,8 @@ layout(location = 0) in vec4 uv;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
layout(set = 0, binding = 0, std140) uniform SupportBuffer {
|
||||
vec4 pad[90];
|
||||
vec4 hdr; // byte 1440 (vk_exec_draw.c support_fill): game white / HUD white, peak / game white, hue correction
|
||||
vec4 pad[92];
|
||||
vec4 hdr; // byte 1472 (vk_exec_draw.c support_fill): game white / HUD white, peak / game white, hue correction
|
||||
} support_buffer;
|
||||
layout(set = 0, binding = 1) uniform sampler2D fp_t_tcb_8;
|
||||
layout(set = 0, binding = 2) uniform sampler2D fp_t_tcb_A;
|
||||
|
||||
+18
-4
@@ -3,6 +3,8 @@
|
||||
// The SVC entry of the lifted code: preemption checkpoint, trace, then the thread and
|
||||
// synchronization SVCs (kernel.c), IPC (ipc.c), memory (memory.c), Break, OutputDebugString, GetInfo and ExitProcess. The 21 SVCs
|
||||
// TotK has but never reaches on MNG's boot path stop with a named fatal, the caller and the guest backtrace.
|
||||
// GetSystemTick, GetInfo 65001 and Map/UnmapProcessMemory are for mod plugins (exlaunch): the game calls none of them,
|
||||
// and process memory is mapped only in the plugin service run (plugin_init.c).
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -17,9 +19,13 @@
|
||||
#define ST_STACK 0xBu
|
||||
#define PERM_RW 3u
|
||||
#define PROGRAM_ID 0x0100f2c0115b6000ull
|
||||
#define CUR_PROCESS 0xFFFF8001u // Horizon's pseudo handle of the current process
|
||||
|
||||
static uint64_t g_svcs;
|
||||
void (*volatile svc_test_exit_hook)(unsigned code);
|
||||
uint64_t rt_svc_tick_offset;
|
||||
int (*rt_plugin_svc)(Cpu *c, uint32_t imm, uint64_t pc);
|
||||
uint32_t (*rt_process_memory)(int unmap, uint64_t dst, uint32_t process, uint64_t src, uint64_t size);
|
||||
|
||||
RtStats rt_stats(void) {
|
||||
return (RtStats){__atomic_load_n(&g_svcs, __ATOMIC_RELAXED), kern_threads_created(), hostfn_calls()};
|
||||
@@ -121,6 +127,7 @@ static void get_info(Cpu *c, uint64_t pc) {
|
||||
case 18: v = PROGRAM_ID; break;
|
||||
case 20: v = user_exception_context(); break; // the SDK keeps e.g. the dying message at +0x1C0
|
||||
case 23: v = 1; break;
|
||||
case 65001: v = CUR_PROCESS; break; // Mesosphere's current process handle (exlaunch's way to its own memory)
|
||||
default: {
|
||||
char why[64];
|
||||
snprintf(why, sizeof why, "GetInfo id %u (handle %#x, sub id %#llx)", id, (uint32_t)c->x[2],
|
||||
@@ -151,11 +158,13 @@ void rt_svc(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
|
||||
static void svc_body(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
__atomic_fetch_add(&g_svcs, 1, __ATOMIC_RELAXED);
|
||||
if (rt_trace & RT_TRACE_SVC) {
|
||||
if (rt_trace & (RT_TRACE_SVC | RT_TRACE_PLUGIN)) {
|
||||
if ((rt_trace & RT_TRACE_PLUGIN) && rt_plugin_svc && rt_plugin_svc(c, imm, pc)) return; // refused, x0 set
|
||||
char at[160];
|
||||
rt_log("svc %#x at %s x0=%#llx x1=%#llx x2=%#llx x3=%#llx", imm, ldr_describe(pc, at, sizeof at),
|
||||
(unsigned long long)c->x[0], (unsigned long long)c->x[1], (unsigned long long)c->x[2],
|
||||
(unsigned long long)c->x[3]);
|
||||
if (rt_trace & RT_TRACE_SVC)
|
||||
rt_log("svc %#x at %s x0=%#llx x1=%#llx x2=%#llx x3=%#llx", imm, ldr_describe(pc, at, sizeof at),
|
||||
(unsigned long long)c->x[0], (unsigned long long)c->x[1], (unsigned long long)c->x[2],
|
||||
(unsigned long long)c->x[3]);
|
||||
}
|
||||
if (kern_svc(c, imm)) return;
|
||||
uint64_t *x = c->x;
|
||||
@@ -210,6 +219,11 @@ static void svc_body(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
return;
|
||||
}
|
||||
case 0x29: get_info(c, pc); return;
|
||||
case 0x1E: x[0] = rt_ticks() + rt_svc_tick_offset; return; // GetSystemTick (19.2 MHz)
|
||||
case 0x74: case 0x75: // MapProcessMemory / UnmapProcessMemory(x0 dst, w1 process, x2 src, x3 size)
|
||||
if (!rt_process_memory) svc_fatal(c, imm, pc, "process memory is mapped only in the plugin service run");
|
||||
x[0] = rt_process_memory(imm == 0x75, x[0], (uint32_t)x[1], x[2], x[3]);
|
||||
return;
|
||||
case 0x07: { // ExitProcess, as closing the window (gfx_window_closed): pipeline cache, shader records and
|
||||
// profile saved, logs flushed, exit code 0
|
||||
char at[160];
|
||||
|
||||
@@ -372,6 +372,15 @@ static int test_import(pool_t *pool) {
|
||||
GCHECK(vk_mem_changed(RT_KERNEL_BASE, 0x1000, 0, &g3) == -1, "the kernel region is reported as tracked");
|
||||
printf("probe-vkmem: write watch: CPU writes reported page-exact; generations see CPU and explicit writes\n");
|
||||
g_gpu_checks += 7;
|
||||
int ah = vk_ahead_selftest(a, pool->size);
|
||||
GCHECK(!ah, "sync-ahead check self test failed at check %d", ah);
|
||||
printf("probe-vkmem: sync-ahead check: a write after the frame wait into the read set is flagged, one before it is not\n");
|
||||
g_gpu_checks++;
|
||||
int aw = vk_mem_ahead_selftest();
|
||||
GCHECK(!aw, "sync-ahead pending-write list self test failed at check %d", aw);
|
||||
printf("probe-vkmem: sync-ahead in place: the pending-write list names the newest writer below a bound, prunes at "
|
||||
"completion and joins when full\n");
|
||||
g_gpu_checks++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
This file is part of the FidelityFX SDK.
|
||||
|
||||
Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
# AMD FidelityFX SDK 1.1.4 (subset)
|
||||
|
||||
From <https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/tree/v1.1.4>, MIT (`LICENSE.txt`), via Savage Wind
|
||||
(<https://github.com/Revivedx/SavageWindRecomp>, MIT, `third_party/FidelityFX`). `runtime/vk_fg.cpp` drives the frame
|
||||
interpolation and optical flow of FSR 3 on the SDK's Vulkan backend directly, without the SDK's frame interpolation
|
||||
swapchain or its ffx-api DLL layer; `runtime/vk_fsr3.cpp` drives the FSR 3.1 upscaler the same way.
|
||||
|
||||
What is here:
|
||||
|
||||
- `sdk/include/FidelityFX/host`: the SDK's public headers; `gpu`: the shader headers of frame interpolation, optical
|
||||
flow, the FSR 3 upscaler, SPD (which optical flow and the upscaler include) and FSR 1 (the upscaler's RCAS). The host
|
||||
headers of the other effects stay, unchanged, because the SDK's own headers include each other.
|
||||
- `sdk/src/components/frameinterpolation`, `opticalflow`, `fsr3upscaler`: the three effects.
|
||||
- `sdk/src/backends/vk/ffx_vk.cpp` and its `shaders/frameinterpolation`, `shaders/opticalflow`, `shaders/fsr3upscaler`
|
||||
(GLSL).
|
||||
- `sdk/src/shared`: the SDK's assert, message and object-management helpers.
|
||||
- `sdk/src/backends/shared/ffx_shader_blobs.h`: the declaration of the blob lookup, which `runtime/vk_fg.cpp` implements
|
||||
(the upscaler's blobs through `runtime/vk_fsr3.cpp` `vk_fsr3_blob`).
|
||||
- `spirv/ffx_shaders_vk.h`: the shaders compiled to SPIR-V with their bindings, by `tools/ffx_shaders.py`
|
||||
(glslangValidator from MSYS2 UCRT64 or the Vulkan SDK) in place of the SDK's Windows-only FidelityFX_SC.exe. Only the
|
||||
permutations used. Committed like `runtime/*_spv.h`: AMD's shaders, no game data. Regenerate after changing the GLSL:
|
||||
`python tools/ffx_shaders.py`.
|
||||
- `spirv/ffx_fsr3upscaler_vk.h`: the same for the FSR 3 upscaler (`python tools/ffx_shaders.py --effects fu`), one
|
||||
permutation per pass: HDR input (the scene's linear light before the bloom), render-size motion vectors without
|
||||
jitter, depth not inverted, the reference Lanczos and Savage Wind's Catmull-Rom history reprojection, in 32-bit and
|
||||
16-bit floats (the 16-bit ones where the SDK asks for them and the device has shaderFloat16 and shaderInt16).
|
||||
- `ffx_compat.h`: force-included into the SDK's sources (`tools/build_game.py`, rule `cc_ffx`) so they build with clang.
|
||||
|
||||
Changes to the SDK's files (marked "Savage Wind" in them):
|
||||
|
||||
- `sdk/src/backends/vk/ffx_vk.cpp`: the arrays the backend lays out in its scratch memory are aligned to 64 bytes
|
||||
instead of 4, and start 64-byte aligned after its context. With 4, clang's aligned SSE stores into them (`movdqa`)
|
||||
faulted; MSVC emits unaligned ones.
|
||||
- `sdk/include/FidelityFX/host/ffx_types.h`: the contexts' default size is doubled outside Windows, where `wchar_t`
|
||||
(their resources' debug names) is 4 bytes instead of 2.
|
||||
- `sdk/src/backends/vk/ffx_vk.cpp`: the global descriptor pool is created with all six of the sizes it lists. It passed
|
||||
five, leaving out the storage buffers (the validation layer reports it).
|
||||
- `sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_reproject.h`: the history reprojected with a Catmull-Rom
|
||||
filter from 5 bilinear samples (`FFX_FSR3UPSCALER_OPTION_REPROJECT_CATMULL_ROM_5`), a Savage Wind addition.
|
||||
|
||||
Changes of our own (marked "TotK Recomp"):
|
||||
|
||||
- `sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_callbacks_glsl.h`: the luma history's storage image is
|
||||
declared `rgba16f`, the format of its images (R16G16B16A16_FLOAT in `ffx_fsr3upscaler.cpp`). It was `rgba8`, which
|
||||
the Vulkan validation layer reports as a format mismatch with undefined loads and stores.
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// Savage Wind: force-included (-include) into the FidelityFX SDK's C++ sources, so that they build with clang/gcc
|
||||
// (MinGW-w64 and Linux) unchanged: what MSVC's headers bring in on their own, and its _s functions where the C library
|
||||
// has none.
|
||||
#pragma once
|
||||
#ifdef __cplusplus
|
||||
#include <cmath>
|
||||
#include <codecvt> // (std::wstring_convert, which ffx_vk.cpp uses for the debug names: MSVC's headers bring it)
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
#include <locale>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#define swprintf_s swprintf // (the SDK passes the size)
|
||||
#if defined(__cplusplus) && !defined(_countof)
|
||||
template <typename T, size_t N> constexpr size_t ffx_countof_(T (&)[N]) { return N; }
|
||||
#define _countof(a) ffx_countof_(a) // (stdlib.h's on Windows; glibc has none)
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
#include <stddef.h>
|
||||
#include <wchar.h>
|
||||
static inline int wcscpy_s(wchar_t *d, size_t n, const wchar_t *s) {
|
||||
size_t l = wcslen(s);
|
||||
if (l >= n) l = n - 1;
|
||||
wmemcpy(d, s, l);
|
||||
d[l] = 0;
|
||||
return 0;
|
||||
}
|
||||
static inline int wcscat_s(wchar_t *d, size_t n, const wchar_t *s) {
|
||||
size_t l = wcslen(d);
|
||||
return l < n ? wcscpy_s(d + l, n - l, s) : 0;
|
||||
}
|
||||
static inline int strcpy_s(char *d, size_t n, const char *s) {
|
||||
size_t l = strlen(s);
|
||||
if (l >= n) l = n - 1;
|
||||
memcpy(d, s, l);
|
||||
d[l] = 0;
|
||||
return 0;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
template <size_t N> static inline int wcscpy_s(wchar_t (&d)[N], const wchar_t *s) { return wcscpy_s(d, N, s); }
|
||||
template <size_t N> static inline int strcpy_s(char (&d)[N], const char *s) { return strcpy_s(d, N, s); }
|
||||
template <size_t N, typename... A> static inline int sprintf_s(char (&d)[N], const char *f, A... a) { return snprintf(d, N, f, a...); }
|
||||
template <typename... A> static inline int sprintf_s(char *d, size_t n, const char *f, A... a) { return snprintf(d, n, f, a...); }
|
||||
#endif
|
||||
#ifndef FFX_UNUSED
|
||||
#define FFX_UNUSED(x) ((void)(x)) // (ffx_message.cpp: defined by the SDK's Windows headers only)
|
||||
#endif
|
||||
#define sprintf_s snprintf // (the SDK passes the size and uses what it returns: the length written)
|
||||
#ifndef _countof
|
||||
#define _countof(a) (sizeof(a) / sizeof((a)[0])) // (MSVC's and MinGW's stdlib.h have it)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The contexts are opaque arrays of FFX_SDK_DEFAULT_CONTEXT_SIZE words, sized for Windows, where wchar_t is 2 bytes:
|
||||
// with Linux's 4-byte wchar_t the frame interpolation context's own part is 768,072 bytes (401,992 with 2-byte
|
||||
// wchar_t), past its 524,288 (a static assertion in ffx_frameinterpolation.cpp). Twice the room where wchar_t is wider.
|
||||
#include <FidelityFX/host/ffx_types.h>
|
||||
#if __SIZEOF_WCHAR_T__ > 2
|
||||
#undef FFX_SDK_DEFAULT_CONTEXT_SIZE
|
||||
#define FFX_SDK_DEFAULT_CONTEXT_SIZE (1024 * 256)
|
||||
#endif
|
||||
#define FFX_UNUSED(x) ((void)(x)) // (as ffx_util.h has it: ffx_message.cpp uses it through ffx_assert.h alone)
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files(the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef FFX_BRIXELIZER_HOST_GPU_SHARED_H
|
||||
#define FFX_BRIXELIZER_HOST_GPU_SHARED_H
|
||||
|
||||
#include "../ffx_core.h"
|
||||
|
||||
#define FFX_BRIXELIZER_MAX_CASCADES 24
|
||||
#define FFX_BRIXELIZER_MAX_INSTANCES (FfxUInt32(1) << FfxUInt32(16))
|
||||
#define FFX_BRIXELIZER_CASCADE_RESOLUTION 64
|
||||
#define FFX_BRIXELIZER_MAX_INSTANCES (FfxUInt32(1) << FfxUInt32(16))
|
||||
#define FFX_BRIXELIZER_INVALID_ID 0x00ffffffu
|
||||
#define FFX_BRIXELIZER_UNINITIALIZED_ID 0xffffffffu
|
||||
#define FFX_BRIXELIZER_INVALID_BOTTOM_AABB_NODE 0x7fff
|
||||
#define FFX_BRIXELIZER_MAX_BRICKS_X8 (1 << 18)
|
||||
#define FFX_BRIXELIZER_MAX_BRICKS FFX_BRIXELIZER_MAX_BRICKS_X8
|
||||
#define FFX_BRIXELIZER_BRICK_AABBS_STRIDE (sizeof(FfxUInt32))
|
||||
#define FFX_BRIXELIZER_BRICK_AABBS_SIZE (FFX_BRIXELIZER_MAX_BRICKS_X8 * FFX_BRIXELIZER_BRICK_AABBS_STRIDE)
|
||||
#define FFX_BRIXELIZER_CASCADE_AABB_TREE_SIZE ((16 * 16 * 16) * sizeof(FfxUInt32) + (4 * 4 * 4 + 1) * sizeof(FfxFloat32x3) * 2)
|
||||
#define FFX_BRIXELIZER_CASCADE_AABB_TREE_STRIDE (sizeof(FfxUInt32))
|
||||
#define FFX_BRIXELIZER_CASCADE_BRICK_MAP_SIZE (FFX_BRIXELIZER_CASCADE_RESOLUTION * FFX_BRIXELIZER_CASCADE_RESOLUTION * FFX_BRIXELIZER_CASCADE_RESOLUTION * sizeof(FfxUInt32))
|
||||
#define FFX_BRIXELIZER_CASCADE_BRICK_MAP_STRIDE (sizeof(FfxUInt32))
|
||||
|
||||
#define FFX_BRIXELIZER_BRICK_ID_MASK 0xffffff
|
||||
|
||||
#define FFX_BRIXELIZER_CASCADE_DEGREE FfxUInt32(6)
|
||||
#define FFX_BRIXELIZER_CASCADE_WRAP_MASK FfxUInt32(63)
|
||||
|
||||
#define FFX_BRIXELIZER_STATIC_CONFIG_SDF_ATLAS_SIZE FfxUInt32(512)
|
||||
|
||||
#if defined(FFX_CPU)
|
||||
#define FFX_BRIXELIZER_CONST static const
|
||||
#elif defined(FFX_HLSL)
|
||||
#define FFX_BRIXELIZER_CONST static const
|
||||
#elif defined(FFX_GLSL)
|
||||
#define FFX_BRIXELIZER_CONST const
|
||||
#else
|
||||
FFX_STATIC_ASSERT(0)
|
||||
#endif
|
||||
|
||||
#ifdef FFX_CPU
|
||||
#define FFX_BRIXELIZER_BEGIN_STRUCT(name) typedef struct name {
|
||||
#define FFX_BRIXELIZER_END_STRUCT(name) } name;
|
||||
#define FFX_BRIXELIZER_BEGIN_ENUM(name) typedef enum name {
|
||||
#define FFX_BRIXELIZER_END_ENUM(name) } name;
|
||||
#define FFX_BRIXELIZER_ENUM_VALUE(name, value) name = value,
|
||||
#else
|
||||
#define FFX_BRIXELIZER_BEGIN_STRUCT(name) struct name {
|
||||
#define FFX_BRIXELIZER_END_STRUCT(name) };
|
||||
#define FFX_BRIXELIZER_BEGIN_ENUM(name)
|
||||
#define FFX_BRIXELIZER_END_ENUM(name)
|
||||
#define FFX_BRIXELIZER_ENUM_VALUE(name, value) FFX_BRIXELIZER_CONST FfxUInt32 name = value;
|
||||
#endif
|
||||
|
||||
/// An enumeration of flags which can be specified for different options when doing a cascade update.
|
||||
///
|
||||
/// @ingroup Brixelizer
|
||||
FFX_BRIXELIZER_BEGIN_ENUM(FfxBrixelizerCascadeUpdateFlags)
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_CASCADE_UPDATE_FLAG_NONE, FfxUInt32(0)) ///< No flags.
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_CASCADE_UPDATE_FLAG_RESET, FfxUInt32(1) << FfxUInt32(0)) ///< Reset the cascade. This clears and frees all bricks currently in the cascade ready to rebuild the cascade completely.
|
||||
FFX_BRIXELIZER_END_ENUM(FfxBrixelizerCascadeUpdateFlags)
|
||||
|
||||
/// An enumeration of the different possible debug outputs for the Brixelizer debug visualization.
|
||||
///
|
||||
/// @ingroup Brixelizer
|
||||
FFX_BRIXELIZER_BEGIN_ENUM(FfxBrixelizerTraceDebugModes)
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_TRACE_DEBUG_MODE_DISTANCE, 0) ///< Display a visualisation of the distance to hit, with closer hits in blue and further hits in green.
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_TRACE_DEBUG_MODE_UVW, 1) ///< Display the UVW coordinates of hits.
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_TRACE_DEBUG_MODE_ITERATIONS, 2) ///< Display a heatmap visualizing number of iterations in the scene.
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_TRACE_DEBUG_MODE_GRAD, 3) ///< Display the normals at hits.
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_TRACE_DEBUG_MODE_BRICK_ID, 4) ///< Display each brick in its own color.
|
||||
FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_TRACE_DEBUG_MODE_CASCADE_ID, 5) ///< Display each cascade in itw own color.
|
||||
FFX_BRIXELIZER_END_ENUM(FfxBrixelizerTraceDebugModes)
|
||||
|
||||
/// A structure of parameters describing a cascade. This structure is primarily for Brixelizer
|
||||
/// internal use.
|
||||
///
|
||||
/// @ingroup Brixelizer
|
||||
FFX_BRIXELIZER_BEGIN_STRUCT(FfxBrixelizerCascadeInfo)
|
||||
FfxFloat32x3 grid_min;
|
||||
FfxFloat32 voxel_size;
|
||||
|
||||
FfxFloat32x3 grid_max;
|
||||
FfxUInt32 flags; ///< the latest build_flags; see FfxBrixelizerCascadeUpdateFlags
|
||||
|
||||
FfxUInt32x3 clipmap_offset;
|
||||
FfxUInt32 pad00;
|
||||
|
||||
FfxInt32x3 clipmap_invalidation_offset;
|
||||
FfxUInt32 pad33;
|
||||
|
||||
FfxInt32x3 ioffset;
|
||||
FfxUInt32 index;
|
||||
|
||||
FfxFloat32x3 grid_mid;
|
||||
FfxUInt32 is_enabled;
|
||||
|
||||
FfxUInt32x2 rel_grid_min_fp16;
|
||||
FfxUInt32x2 rel_grid_max_fp16;
|
||||
|
||||
FfxUInt32 pad11;
|
||||
FfxUInt32 pad22;
|
||||
FfxFloat32 ivoxel_size;
|
||||
FfxUInt32 is_initialized;
|
||||
FFX_BRIXELIZER_END_STRUCT(FfxBrixelizerCascadeInfo)
|
||||
|
||||
/// A structure of parameters describing the Brixelizer context. This structure is primarily
|
||||
/// for Brixelizer internal use.
|
||||
///
|
||||
/// @ingroup Brixelizer
|
||||
FFX_BRIXELIZER_BEGIN_STRUCT(FfxBrixelizerContextInfo)
|
||||
FfxUInt32 num_bricks;
|
||||
FfxUInt32 frame_index;
|
||||
FfxFloat32 imesh_unit;
|
||||
FfxFloat32 mesh_unit;
|
||||
|
||||
FfxBrixelizerCascadeInfo cascades[FFX_BRIXELIZER_MAX_CASCADES];
|
||||
FFX_BRIXELIZER_END_STRUCT(FfxBrixelizerContextInfo)
|
||||
|
||||
// =============================================================================
|
||||
// Debug/context counters
|
||||
// =============================================================================
|
||||
// Important to match the first a couple of counters with the FfxBrixelizerScratchCounters to share code
|
||||
#define MEMBER_LIST \
|
||||
MEMBER(brickCount, BRICK_COUNT, 0) \
|
||||
MEMBER(dirtyBricks, DIRTY_BRICKS, 1) \
|
||||
MEMBER(freeBricks, FREE_BRICKS, 2) \
|
||||
MEMBER(clearBricks, CLEAR_BRICKS, 3) \
|
||||
MEMBER(mergeBricks, MERGE_BRICKS, 4) \
|
||||
MEMBER(numDebugAABBs, NUM_DEBUG_AABBS, 5)
|
||||
|
||||
/// A structure containing all the counters used by the Brixelizer context. These can
|
||||
/// be read back from the context after processing each update for analysis.
|
||||
/// <c><i>brickCount</i></c> gives the total number of bricks allocated.
|
||||
/// <c><i>dirtyBricks</i></c> gives the total number of bricks requiring an eikonal pass for completion.
|
||||
/// <c><i>freeBricks</i></c> gives the total number of free bricks. This is the maximum number of bricks which can be allocated within a frame.
|
||||
/// <c><i>clearBricks</i></c> gives the total number of bricks to be cleared in a frame. Bricks are cleared by having all distance values reset to 1.
|
||||
/// <c><i>mergeBricks</i></c> gives the total number of bricks to be merged in a frame.
|
||||
/// <c><i>numDebugAABBs</i></c> gives the total number of debug AABBs requested to be drawn in a debug visualization.
|
||||
///
|
||||
/// @ingroup Brixelizer
|
||||
FFX_BRIXELIZER_BEGIN_STRUCT(FfxBrixelizerDebugCounters)
|
||||
#define MEMBER(camel_name, _upper_name, _index) FfxUInt32 camel_name;
|
||||
MEMBER_LIST
|
||||
#undef MEMBER
|
||||
FFX_BRIXELIZER_END_STRUCT(FfxBrixelizerDebugCounters)
|
||||
|
||||
FFX_BRIXELIZER_BEGIN_ENUM(FfxBrixelizerContextCounterIndex)
|
||||
#define MEMBER(_camel_name, upper_name, index) FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_CONTEXT_COUNTER_##upper_name, index)
|
||||
MEMBER_LIST
|
||||
#undef MEMBER
|
||||
FFX_BRIXELIZER_END_ENUM(FfxBrixelizerContextCounterIndex)
|
||||
|
||||
#define MEMBER(_camel_name, _upper_name, _index) + 1
|
||||
FFX_BRIXELIZER_CONST FfxUInt32 FFX_BRIXELIZER_NUM_CONTEXT_COUNTERS = 0 MEMBER_LIST;
|
||||
#undef MEMBER
|
||||
#undef MEMBER_LIST
|
||||
|
||||
// =============================================================================
|
||||
// Scratch counters
|
||||
// =============================================================================
|
||||
#define MEMBER_LIST \
|
||||
MEMBER(triangles, TRIANGLES, 0) \
|
||||
MEMBER(maxTriangles, MAX_TRIANGLES, 1) \
|
||||
MEMBER(references, REFERENCES, 2) \
|
||||
MEMBER(maxReferences, MAX_REFERENCES, 3) \
|
||||
MEMBER(groupIndex, GROUP_INDEX, 4) \
|
||||
MEMBER(compressionBricks, COMPRESSION_BRICKS, 5) \
|
||||
MEMBER(storageOffset, STORAGE_OFFSET, 6) \
|
||||
MEMBER(storageSize, STORAGE_SIZE, 7) \
|
||||
MEMBER(numBricksAllocated, NUM_BRICKS_ALLOCATED, 8) \
|
||||
MEMBER(clearBricks, CLEAR_BRICKS, 9)
|
||||
|
||||
/// A structure containing the counters used by the Brixelizer context for each cascade
|
||||
/// update. This can be readback and used for analysis after each update. The following
|
||||
/// members contain useful information for analysing Brixelizer resource usage.
|
||||
///
|
||||
/// <c><i>triangles</i></c> is used to store the total amount of storage space requested within the triangle buffer during an update. This is useful for determining a sensible value of <c><i>triangleSwapSize</i></c> in either <c><i>FfxBrixelizerRawCascadeUpdateDescription</i></c> or <c><i>FfxBrixelizerUpdateDescription</i></c>.
|
||||
/// <c><i>references</i></c> is used to store the total number of reference allocations requested by Brixelizer during an update. This is useful for determining a sensible value of <c><i>maxReferences</i></c> in either <c><i>FfxBrixelizerRawCascadeUpdateDescription</i></c> or <c><i>FfxBrixelizerUpdateDescription</i></c>.
|
||||
/// <c><i>numBricksAllocated</i></c> is used to store the number of brick allocations requested in an update. This is useful for determining a sensible value of <c><i>maxBricksPerBake</i></c> in either <c><i>FfxBrixelizerRawCascadeUpdateDescription</i></c> or <c><i>FfxBrixelizerUpdateDescription</i></c>.
|
||||
///
|
||||
/// The following counters are used internally by Brixelizer.
|
||||
///
|
||||
/// <c><i>maxTriangles</i></c> is used to store the storage size of the triangle buffer.
|
||||
/// <c><i>maxReferences</i></c> is used to store the maxmimum number of references that can be stored.
|
||||
/// <c><i>groupIndex</i></c> is used as a global atomic for wavefront synchronisation.
|
||||
/// <c><i>compressionBricks</i></c> the number of bricks to compress (i.e. calculate AABBs for) this udpate.
|
||||
/// <c><i>storageOffset</i></c> the next free position in the bricks scratch buffer.
|
||||
/// <c><i>storageSize</i></c> the size of the bricks scratch buffer.
|
||||
/// <c><i>clearBricks</i></c> the amount of bricks in the scratch buffer to initialize.
|
||||
///
|
||||
/// @ingroup Brixelizer
|
||||
FFX_BRIXELIZER_BEGIN_STRUCT(FfxBrixelizerScratchCounters)
|
||||
#define MEMBER(camel_name, _upper_name, _index) FfxUInt32 camel_name;
|
||||
MEMBER_LIST
|
||||
#undef MEMBER
|
||||
FFX_BRIXELIZER_END_STRUCT(FfxBrixelizerScratchCounters)
|
||||
|
||||
FFX_BRIXELIZER_BEGIN_ENUM(FfxBrixelizerScratchCounterIndex)
|
||||
#define MEMBER(_camel_name, upper_name, index) FFX_BRIXELIZER_ENUM_VALUE(FFX_BRIXELIZER_SCRATCH_COUNTER_##upper_name, index)
|
||||
MEMBER_LIST
|
||||
#undef MEMBER
|
||||
FFX_BRIXELIZER_END_ENUM(FfxBrixelizerScratchCounterIndex)
|
||||
|
||||
#define MEMBER(_camel_name, _upper_name, _index) + 1
|
||||
FFX_BRIXELIZER_CONST FfxUInt32 FFX_BRIXELIZER_NUM_SCRATCH_COUNTERS = 0 MEMBER_LIST;
|
||||
#undef MEMBER
|
||||
#undef MEMBER_LIST
|
||||
|
||||
#endif
|
||||
Loaded 100 of 294 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user