mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 20:25:57 +00:00
Compare commits
No files matched your search
+1
-1
@@ -36,7 +36,7 @@ Open pull requests against `dev`. Branch from the current `dev` and rebase on it
|
||||
### Before you start
|
||||
|
||||
- Search the open pull requests and issues on the topic. When another pull request already covers it, improve that one or say in yours how they differ.
|
||||
- Fixes are reviewed before features, in order of how many players the bug hits. A feature with a design in [docs/milestones/](docs/milestones/) (mods, cheats, the menu) follows that design. For a feature without one, open an issue first.
|
||||
- Fixes are reviewed before features, in order of how many players the bug hits. A feature with a design in `docs/milestones/` (mods, cheats, the menu) follows that design. For a feature without one, open an issue first.
|
||||
- Find out where the bug reproduces: OS, GPU vendor and generation, driver, game update, settings. Put that in the description.
|
||||
|
||||
### What the change must keep
|
||||
|
||||
@@ -10,10 +10,10 @@ Code copied or adapted from another project is listed here with its source, the
|
||||
| MacNativeGames TotK host runtime: dynamic linking, identity check, module permissions, guest memory and SVCs, threads, IPC, audio renderer, system services, RomFS and save storage, boot sequence, the NVN proc name list | https://github.com/ly05010419/MacNativeGames @ `b75be8cfa704df3701e86130c8ced268e79d6b11` (`games/totk/runtime/`, `games/totk/scripts/prepare_runtime.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `runtime/loader.c`, `runtime/memory.c`; `runtime/kernel.c`, `runtime/svc.c`, `runtime/ipc.c`, `runtime/ipc.h`, `runtime/audren.c`, `runtime/audren.h`, `runtime/audio_mixer.c`, `runtime/audio_effects.c`, `runtime/audio_effects.h`, `runtime/audio_reverb.c`, `runtime/audio_reverb.h` (SDL3 output replaces CoreAudio), `runtime/ov_system.c` (also `shared_font.c`: the BFTTF layout behind nn::pl), `runtime/ov_input.c` (also `hid_feedback.c`: vibration and six-axis handles and calls), `runtime/motion_fusion.c` (six-axis fusion of `motion_fusion.c`), `runtime/ov_media.c` (hardware Opus decoder over libopus), `runtime/swkbd_win.c` (`swkbd_host.c`: ShowKeyboardArg offsets, UTF-8/UTF-16 conversion, disabled-key filter, result codes; Win32 window replaces the macOS text bar), `runtime/ov_gfx.c`, `runtime/romfs.c`, `runtime/romfs_path.h`, `runtime/fs_host.c`, `runtime/fs.h`, `runtime/boot.c`; `runtime/gfx_window.c`; `tools/gen_nvn_procs.py`, `runtime/nvn_procs.inc` (`NVN/names.txt` and the `NVN_EXTRA` names of `totk_nvn_ext.c`) |
|
||||
| MacNativeGames TotK frame-rate patches: 60 fps present-interval controller, real-time frame step and its present sampling, hair and cloth clock, trampoline slow-motion check (instruction words and 1.2.1 sites), player position chain; quick-menu capture background RomFS overlay | https://github.com/ly05010419/MacNativeGames @ `ebe621de99bfc48f3c42f2d2aa73e04fbcc6eae2` (`games/totk/runtime/game_patches.c`, `game_version.h`, `world_survey.c`, `games/totk/scripts/make_romfs_patches.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `runtime/frame_rate.c`, `recomp/patches-v121.txt`, `tools/make_romfs_patches.py` |
|
||||
| MacNativeGames TotK 1.4.3 fade fix: the four distance / LOD and pre-actor fade sites, their instruction words and the floor of the fade step at 1 | https://github.com/ly05010419/MacNativeGames @ `3e9e7f67fdfdd3404134dcfa0f24969a9425a33f` (`games/totk/runtime/game_patches_v143.c` patch_fade_increment), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v143.txt` (set fade; the floor without flags, clz >> 5, as in pull request #78) |
|
||||
| MacNativeGames TotK 1.2.1 cursor and aim steps: the map cursor, vertical Ultrahand aim and vertical gyro aim sites, their instruction words and the step scaled by the frame ratio | https://github.com/ly05010419/MacNativeGames @ `363a6eb50434387f7d623349934bcf1e910be48f` (`games/totk/runtime/game_patches.c` patch_cursor_speed), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v121.txt` (set cursor) |
|
||||
| MacNativeGames TotK aspect ratio: the camera and viewport sites that hand the perspective projection its aspect ratio, and the UI layout edits for a canvas wider than 16:9 | https://github.com/ly05010419/MacNativeGames @ `933b6a0d1438de160208a0a13eb5e8d7a2cb8094` (`games/totk/runtime/aspect_patch.h`, `aspect_math.h`, `game_patches_v143.c`, `games/totk/scripts/ultrawide_layout.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v143.txt` (set aspect), `tools/ultrawide_layout.py`, `tools/make_romfs_patches.py` (--aspect) |
|
||||
| MacNativeGames TotK 1.2.1 cursor and aim steps: the map cursor, vertical Ultrahand aim and vertical gyro aim sites, their instruction words and the step scaled by the frame ratio | https://github.com/ly05010419/MacNativeGames @ `363a6eb50434387f7d623349934bcf1e910be48f` (`games/totk/runtime/game_patches.c` patch_cursor_speed), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v121.txt`, `recomp/patches-v110.txt` (set cursor) |
|
||||
| MacNativeGames TotK aspect ratio: the camera and viewport sites that hand the perspective projection its aspect ratio, and the UI layout edits for a canvas wider than 16:9 | https://github.com/ly05010419/MacNativeGames @ `933b6a0d1438de160208a0a13eb5e8d7a2cb8094` (`games/totk/runtime/aspect_patch.h`, `aspect_math.h`, `game_patches_v143.c`, `games/totk/scripts/ultrawide_layout.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v110.txt`, `recomp/patches-v143.txt` (set aspect), `tools/ultrawide_layout.py`, `tools/make_romfs_patches.py` (--aspect) |
|
||||
| MacNativeGames TotK button icons: the Xbox controller's shoulder buttons, triggers, Menu, View and d-pad drawn with letters from the game's own text fonts, the .bfotf key, the button guide's images and their block-linear layout, the resource size table raised for the archives that grew | https://github.com/ly05010419/MacNativeGames @ `933b6a0d1438de160208a0a13eb5e8d7a2cb8094` (`games/totk/scripts/make_button_icons.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `tools/button_icons.py`, `tools/make_romfs_patches.py` (--prompts) |
|
||||
| RenoDX TotK mod (game mod by souperman9, tonemapper by Musa, RenoDX framework by ShortFuse, RenoVK fork by Ritsu): the approach of the HDR tonemap (the game's 1 - e^-x curve kept below a pivot and continued along its tangent above it, the saturation grade applied to the colour scaled into 0..1) and the observation that the passes after the tonemap keep values above 1. No code copied; the shader is our own | https://github.com/clshortfuse/renodx @ `b6f87272ad1bfdc0e6444910a93606815944a085` (`src/games/totk/tonemap.slang`, `addon.cpp`), Copyright (c) 2025 Carlos Lopez Jr. | MIT | `runtime/shaders/hdr_tonemap.frag`, `runtime/vk_hdr.c` |
|
||||
| RenoDX TotK mod (game mod by souperman9, tonemapper by Musa, RenoDX framework by ShortFuse, RenoVK fork by Ritsu): the HDR tonemap's colour reconstruction (the game's 1 - e^-x curve continued along its tangent above 0.18, the SDR result as hue and purity donor through MacLeod-Boynton in BT.2020, the saturation grade on a Neutwo-compressed colour, per-channel Neutwo to the peak in BT.2020, the sRGB to gamma 2.2 correction) adapted into GLSL, and the observation that the passes after the tonemap keep values above 1 | https://github.com/clshortfuse/renodx @ `43c067b755a6a741f6500b2b936570f1462dcfbe` (`src/games/totk/tonemap.slang`, `src/games/totk/macleod_boynton.hlsli`, `src/shaders/colorcorrect.hlsl`, `src/shaders/tonemap/neutwo.hlsl`), Copyright (c) 2025 Carlos Lopez Jr. | MIT | `runtime/shaders/hdr_tonemap.frag`, `runtime/vk_hdr.c` |
|
||||
| TOTK-Ultrawide, the community mod for emulators: the list of UI panes the ultrawide layout edits and the distances they move (data only, no code copied; the edit code is our own, and MacNativeGames' `ultrawide_layout.py` in the row above already carries the same values). The mod's repository URL and licence version are not recorded in this repository | TOTK-Ultrawide (community mod; URL not recorded here) | GPL (version not recorded here) | `tools/ultrawide_layout.py` (`KEEP_ROOT`, `edits`, `anim_edits`) |
|
||||
| MacNativeGames TotK virtual-core preemption: asynchronous preemption of an owner in top-level game code, priority inheritance through guest mutexes, the SDK's preemption-disable protocol (TLR+0x100/+0x102, SVC 0x36), the core-wait diagnostics | https://github.com/ly05010419/MacNativeGames @ `33e8fa83052ea1ae09a3583137008e9797e12950` (`games/totk/runtime/threads.c`, commits 8bf0893 and 19730cd), Copyright (c) 2026 MacNativeGames contributors | MIT | `runtime/kernel.c` (SuspendThread and a register-saving stub replace SIGUSR2), `runtime/hostfn.c`, `runtime/svc.c` (host depth) |
|
||||
| MacNativeGames RomFS index builder (`TOTKRFS1` layout) | https://github.com/ly05010419/MacNativeGames @ `b75be8cfa704df3701e86130c8ced268e79d6b11` (`games/totk/scripts/prepare_romfs_backend.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `tools/romfs_index.py` |
|
||||
@@ -31,6 +31,7 @@ Code copied or adapted from another project is listed here with its source, the
|
||||
| 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/`) |
|
||||
| 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 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` |
|
||||
| Vulkan Memory Allocator 3.4.0 (MSYS2 `mingw-w64-ucrt-x86_64-vulkan-memory-allocator`), header-only, compiled into `totk.exe` | https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator, Copyright (c) 2017-2026 Advanced Micro Devices, Inc. | MIT | `runtime/vk_vma.cpp` (the allocator behind `runtime/vk_memory.c`) |
|
||||
@@ -41,6 +42,7 @@ Code copied or adapted from another project is listed here with its source, the
|
||||
| AMD Display Library (ADL) declarations: `AdapterInfo`, `ADLSingleSensorData`, `ADLPMLogDataOutput`, the `ADL_PMLOG_*` sensor numbers and the `ADL2_*` function signatures | https://github.com/GPUOpen-LibrariesAndSDKs/display-library @ `84c881cb2136f04287eb3af12de00a9e2867aa9e` (`include/adl_structures.h`, `include/adl_defines.h`, `include/adl_sdk.h`), Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. | MIT | `runtime/perfmon.c` |
|
||||
| Zstandard 1.5.7 (MSYS2 `mingw-w64-ucrt-x86_64-zstd`), static link | https://github.com/facebook/zstd, Copyright (c) Meta Platforms, Inc. and affiliates | BSD-3-Clause | `runtime/resolution.c` (the HeapDef table), `runtime/ov_zstd.c` (the game's zstd frames decoded on the host) |
|
||||
| musl `fma.c`, `fmaf.c` and `scalbn.c`, adapted into one file for the x86-64-v2 build | https://github.com/kraj/musl @ `5a56ad13e1e0790c06122978aad2a14d6b9efc1a` (mirror of https://git.musl-libc.org/cgit/musl), Copyright (c) 2005-2020 Rich Felker and contributors | MIT | `runtime/fma.c` (the correctly rounded fma/fmaf the FP lowering needs on CPUs without FMA3) |
|
||||
| MacNativeGames texture pool offset fix: widen the 32-bit texture storage and packaged-data offsets unsigned | https://github.com/ly05010419/MacNativeGames @ `ca311e2d` (`games/totk/runtime/game_patches.c` patch_pool_offset), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v110.txt` (set pooloff; sites located again in 1.1.0) |
|
||||
|
||||
## Compiler runtime in a source build
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
|
||||
| a host core at 100% while the game waits | game spin loops without system calls | profile: which guest function spins |
|
||||
| crash on world load | sizes the game reads from the driver (command memory used) differ from the console's | the sizes the game asks for against the console's |
|
||||
| crash with one save only | the save itself; some crash on a real Switch | the same save on another build and, if possible, on hardware |
|
||||
| random crash after minutes to hours, access violation reading `0xffffffffffffffff` or a small address such as `0x90` in a game function (Windows reports any non-canonical address as `0xffffffffffffffff`) | an invalid value (-1, `0xffff0000ffffffff`) in an optional reference the game checks only for null; in main+0x1bd0138 (Recall / Ultrahand picking a target) also a reused holder whose actor points into other memory. Sets `optref` and `ability` in `recomp/patches-v143.txt` guard both there | the crash dump's faulting host instruction, the register it loads through and the field that register came from; `ability: target dropped` lines in the log |
|
||||
| crash while using Ultrahand or aiming, in the model scene's report loop (1.4.3 main+0xa22bc..0xa234c) | a report row index read from the report buffer with no bound (Weeping of the Empire #52, #73); set `report` sends a negative handle or an index from 0x8000 to the game's own reset | the faulting address against the report rows base (x12) |
|
||||
|
||||
## Device lost, hangs, black window
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@ MacNativeGames cannot run on x86-64 as is: its CPU path executes ARM64 code nati
|
||||
(`recomp/flags.py`, `recomp/regs.py`): registers are stored back where they changed, before calls, SVCs and
|
||||
exits, and reloaded after them. A call reloads only X0-X18 and X30, as AAPCS64 has the callee preserve X19-X29 and
|
||||
SP; `gen.py --no-callee-saved-trust` reloads those too.
|
||||
- `gen.py --v-locals K` keeps the K most used V registers of each function in a local `u128 vr[32]` that clang
|
||||
holds in XMM registers (`recomp/vlocals.py`, the `RT_VLOCALS` accessors of `runtime/simd.h`): loaded at entry,
|
||||
stored where they may have changed before calls and exits, reloaded after calls; `--v-trust` does not reload
|
||||
V8-V15, whose low halves AAPCS64 has the callee preserve. K is 8 by default; K = 0 keeps every V register in the `Cpu`.
|
||||
- Coverage oracle: MacNativeGames' NSO rewriter lists every site where game code touches the OS (SVCs, TLS reads, counter reads, `x18`, exclusive windows, jump tables): 68,968 sites in 1.4.3 `main`. The lifter must handle every one.
|
||||
- Memory: guest address equals host address, all below 2^39 (IPC encodes 39-bit addresses). The heap, stacks and the alias region are reserved with `MEM_WRITE_WATCH`, so the graphics back end can ask which pages the CPU wrote since the last upload (`runtime/memory.c`).
|
||||
- Indirect branches go through `rt_dispatch` (`runtime/dispatch.c`), which looks the target up in the address table and tail-calls it.
|
||||
@@ -86,7 +90,7 @@ 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, `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. 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.
|
||||
- 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
|
||||
|
||||
+8
-3
@@ -100,7 +100,7 @@ of them.
|
||||
objects before it links: any AVX, BMI or other instruction above x86-64-v2 outside a function listed there as
|
||||
dispatched by a runtime CPU check stops the build.
|
||||
|
||||
`gen.py` sizes its emit pool from the CPU count and the free memory; `--jobs N` sets it, and so does the environment variable `TOTK_LIFT_JOBS=N`, which the installer's lift step honours too (it has no `--jobs`). When a worker runs out of memory, the pool restarts with half the workers (`emit: out of memory with N workers, retrying with M`), down to one; only an out-of-memory error with one worker fails the step.
|
||||
`gen.py` sizes its emit pool from the CPU count and the free memory; `--jobs N` sets it, and so does the environment variable `TOTK_LIFT_JOBS=N`, which the installer's lift step honours too (it has no `--jobs`). When a worker runs out of memory, the pool restarts with half the workers (`emit: out of memory with N workers, retrying with M`), down to one; only an out-of-memory error with one worker fails the step. A later lift into the same `--out` lifts again only the chunks whose inputs changed (`<mod>/lift_cache.json`, see the top of `recomp/gen.py`); `--no-cache`, or `TOTK_LIFT_CACHE=0` (which the installer's lift step honours too), lifts every chunk.
|
||||
|
||||
Lifting takes about 15 s, a clean compile about 200 s on 24 threads; later builds recompile only what changed.
|
||||
A compiler cache in front of clang shortens it further: with `SCCACHE` set to an sccache executable, `build_game.py`
|
||||
@@ -200,7 +200,7 @@ re-protecting imported memory invalidates the driver's userptr buffer on every s
|
||||
amdgpu), and importing pins the pages, which drops their write protection. Each CPU-visible pool therefore gets a
|
||||
host-visible copy (shadow storage, `runtime/vk_memory.c`): the pages the CPU wrote go in before each submit, and the GPU's
|
||||
writes come back at its fence. In play that costs about 0.2 ms a frame and doubles the memory of those pools (about
|
||||
1.1 GB). `TOTK_SHADOW=1` turns it on under Windows too. The Steam Deck's RADV has `VK_EXT_external_memory_host` as
|
||||
1.1 GB). `shadow = 1` in `totk.ini` (or `TOTK_SHADOW=1`) turns it on under Windows too. The Steam Deck's RADV has `VK_EXT_external_memory_host` as
|
||||
well: the shadow copies are chosen for the measured cost above, not for a missing extension.
|
||||
|
||||
The Deck's GPU (Van Gogh) has no native ASTC, so its textures go through the compute decoder (`runtime/vk_astc.c`,
|
||||
@@ -222,7 +222,12 @@ when a setting is described neither in `totk.ini.example` nor in [settings.md](s
|
||||
`.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
|
||||
(`runtime/cheats.c`, `tools/cheats.py`) passes `.venv\Scripts\python tests\cheats_vm_check.py`, which runs both on
|
||||
cheats of its own with clang from PATH (`--cc` names another).
|
||||
cheats of its own with clang from PATH (`--cc` names another). A change to what a generated chunk depends on, or to
|
||||
the lift cache of `recomp/gen.py` (`<mod>/lift_cache.json`), passes `.venv\Scripts\python tests\lift_cache_test.py`,
|
||||
which lifts a module it makes itself with and without the cache and compares the output (no game files); a new input
|
||||
of the chunk text goes into `chunk_key` with a case there. On game files, a lift with the cache into a used output
|
||||
folder and a `--no-cache` lift into an empty one give the same files apart from `manifest.json` and
|
||||
`lift_cache.json`.
|
||||
|
||||
The lifter (`recomp/`) and the CPU headers (`runtime/cpu.h`, `runtime/simd.h`) are checked against Unicorn. Every lifter
|
||||
change passes these, all run with `.venv`:
|
||||
|
||||
+30
-6
@@ -29,7 +29,7 @@ The log names the layout in effect (`input: gamepad layout ...`); the menu shows
|
||||
| Minus | Back | M | map |
|
||||
| Right stick shaken left and right | shake the right stick | G | detach a fused part from what Ultrahand holds |
|
||||
|
||||
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 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.
|
||||
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
|
||||
|
||||
@@ -65,7 +65,7 @@ At a game resolution of another shape than 16:9 the game loads `romfs-patches-xb
|
||||
|
||||
| Switch | Prompt |
|
||||
|---|---|
|
||||
| A, B, X, Y | E, Shift, Space, left click |
|
||||
| A, B, X, Y | E, Shift, Space, left click (T in text prompts) |
|
||||
| L, R, ZL, ZR | Q, R, right click, F |
|
||||
| Plus, Minus | Tab, M |
|
||||
| D-pad | 1 (left), 2 (up), 3 (right), 4 (down), as a cross or the keys of the directions meant |
|
||||
@@ -74,7 +74,8 @@ At a game resolution of another shape than 16:9 the game loads `romfs-patches-xb
|
||||
|
||||
- The glyphs keep the width of the game's own, so the right-aligned guides do not run into their text. A key is a rounded square with its label cut out in the game's own text fonts (Shift: an arrow over its name); a mouse button is a mouse with that button filled and the others hollow.
|
||||
- The button guide in play draws every button from images of the Common archive (`Nt_KeyTexA/B/X/Y/L/ZL_00`, `Nt_KeyTexLSt_00` and `_01`, the stick tilted and pressed): all of them are painted with the same icons. The letters of the action prompt's diamond are one character of the Normal font each: E, an arrow for Shift, a bar for Space, L and R for the mouse buttons.
|
||||
- Like the Xbox prompts they follow the defaults and not the bindings. `--binds <totk.ini>` draws the first key of each `bind_` line of that file instead, for a folder made by hand.
|
||||
- Y has two keys, the left mouse button and T. The button guide in play and the action prompt show the left button, which attacks there; the prompts in text (the menus' guides such as *Sort*, the dialogue log's) show T, because while a menu has the pointer the left button is that menu's A, and T presses Y everywhere (`PC_TEXT_KEYS` in `tools/button_icons.py`). With a `bind_y` line, the text prompts take its first key that is not a mouse button (its only key when all are mouse buttons).
|
||||
- They follow the bindings of the install's `totk.ini` as the setup found them: its *Drawing the keyboard and mouse prompts* step passes the file as `--binds` (the first key of each `bind_` line), and the keyboard defaults without one. After a change on the Controls tab run the setup again: that step alone runs, since it is keyed by the `bind_` lines (`PcPrompts` in `installer/steps.py`). The Xbox prompts follow the defaults.
|
||||
- At a game resolution of another shape than 16:9 the game loads `romfs-patches-pc-<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 pc --aspect <w>x<h> --reuse <install>\romfs-patches-pc --out <install>\romfs-patches-pc-<w>x<h>`. The setup writes one for each of the fifteen sizes it lays the UI out for, 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*).
|
||||
|
||||
## Window keys
|
||||
@@ -93,7 +94,7 @@ The *Controls* tab of the settings menu lists, under the button layout, every Sw
|
||||
|
||||
The tab writes `totk.ini` lines, one per Switch button or stick direction: `bind_<button> = <entry>, <entry>, ...`. The button is `A B X Y L R ZL ZR PLUS MINUS LEFT UP RIGHT DOWN LCLICK RCLICK`, or a stick direction `LSTICK_LEFT LSTICK_UP LSTICK_RIGHT LSTICK_DOWN` (movement, W A S D by default) and `RSTICK_...` (camera, the arrow keys), or `SHAKE` (keys only, G by default). An entry is `pad:<name>` or `key:<name>`:
|
||||
|
||||
- pad names: `south east west north l r zl zr start back lstick rstick dpad_left dpad_up dpad_right dpad_down lpaddle1 rpaddle1 lpaddle2 rpaddle2` (`zl`, `zr` are the triggers; the paddles are the back buttons of an Xbox Elite, DualSense Edge or Steam Controller, upper pair 1, lower pair 2, and no Switch button has them by default)
|
||||
- pad names: `south east west north l r zl zr start back lstick rstick dpad_left dpad_up dpad_right dpad_down lpaddle1 rpaddle1 lpaddle2 rpaddle2 touchpad` (`zl`, `zr` are the triggers; the paddles are the back buttons of an Xbox Elite, DualSense Edge or Steam Controller, upper pair 1, lower pair 2; `touchpad` is the touchpad click of a DualSense or DualShock 4; no Switch button has the paddles or the touchpad by default)
|
||||
- key names: `a` to `z`, `0` to `9`, `f2` to `f7`, `f9`, `f12`, `num0` to `num9`, `space tab enter backspace lshift rshift lctrl rctrl lalt capslock insert delete home end pageup pagedown up down left right`, `num_add num_sub num_mul num_div num_decimal`, `minus equals lbracket rbracket semicolon apostrophe comma period slash backslash grave`, `mouse_l mouse_r mouse_m mouse_x1 mouse_x2`
|
||||
- `key:default` and `pad:default` keep that part's defaults (`pad:default` is each layout's own button).
|
||||
- `none` leaves the button unbound.
|
||||
@@ -174,7 +175,8 @@ The horizontal quick lists (D-pad up/left/right: materials, shields and weapons)
|
||||
with at least 32 ms of neutral between them. At sensitivity 1, 32 horizontal counts request a step; a large flick
|
||||
cannot queue continued scrolling after the mouse stops. Vertical movement is ignored in these lists. Switching or
|
||||
releasing a selector resets its cursor/step state without sending the last movement to the camera. Selector input is
|
||||
not consumed by the direct camera or Ultrahand hooks.
|
||||
not consumed by the direct camera or Ultrahand hooks. The scroll wheel steps these lists too: each notch is one step,
|
||||
away from you to the left, towards you to the right.
|
||||
To detach a fused part from what Ultrahand holds, shake the mouse left and right, or press G (`bind_SHAKE`). A press
|
||||
swings the right stick left and right for 0.8 s, holding the key keeps it swinging. With `mouse_mode = direct` a shake
|
||||
of the mouse while Ultrahand holds an object swings the right stick with it: once the swings (10 degrees of camera turn
|
||||
@@ -199,10 +201,30 @@ The stick direction bits (`StickLLeft` to `StickRDown`) are derived from the sti
|
||||
|
||||
## Mouse in the game's menus
|
||||
|
||||
On game 1.4.3, while one of the game's menus has its focus box (the frame the d-pad moves: the title, the save list, the inventory and its System tab, Options, shops, dialogue choices), the cursor is released from the mouse camera and shown in the middle of the window. A focus gap of up to 300 ms (a tab switch, a popup opening: the game drops the focus box for a frame or two) keeps the pointer where it is instead of capturing and centring it again. The item under the pointer takes the focus as if the d-pad had moved there, with the game's highlight, sound and description; a left click is A on it, a right click is B. The middle and side mouse buttons keep their bindings (bound to L and R they turn the tabs), and T presses Y (sort). The keys and the pad keep working, and the focus moves only when the pointer moves. This happens only while the keyboard and mouse are the device used last: after a gamepad button press or a stick pushed past half way the menus are as on the console, with no pointer, until the mouse moves or a key is pressed (`input_kbm_last` in `runtime/input.c`). The ability wheel, the d-pad strips, Autobuild and the Purah Pad's camera stay gameplay: the mouse keeps the camera there. The map has no focus box; it is found in `eui::ScreenMgr`'s list of open screens (every 100 ms: the Purah Pad's frame `AppMenuOverlay_00` with `AppMap_00` and the menu background `AppMenuBG_00`), and there the mouse moves the map's cursor as the left stick does, with the cursor still captured, and the scroll wheel zooms: each notch is a full-tilt push of the right stick (the map's zoom) for 100 ms with 50 ms of neutral after it, up (in) for a turn away from you; a fast scroll's notches wait their turn (at most four), a turn the other way drops them. The Scope opens the same map screen without the menu background and keeps the mouse camera. When the menu closes the cursor is captured again.
|
||||
On game 1.4.3, while one of the game's menus has its focus box (the frame the d-pad moves: the title, the save list, the inventory and its System tab, Options, shops, dialogue choices), the cursor is released from the mouse camera and shown in the middle of the window. A focus gap of up to 300 ms (a tab switch, a popup opening: the game drops the focus box for a frame or two) keeps the pointer where it is instead of capturing and centring it again. The item under the pointer takes the focus as if the d-pad had moved there, with the game's highlight, sound and description; a left click is A on it, a right click is B. The middle and side mouse buttons keep their bindings (bound to L and R they turn the tabs), and T presses Y (sort). The scroll wheel moves the focus up and down, one step a notch (a full-tilt push of the left stick for 70 ms with 50 ms of neutral after it, up for a turn away from you), so a long list of items scrolls without moving the pointer; `menu_cursor = 0` turns this off with the pointer. The keys and the pad keep working, and the focus moves with the pointer only when the pointer moves: after the wheel, a key or the pad moved the focus off the pointer's item, the pointer takes it back once it has moved 6 layout units (the menus' 1280 x 720: about 9 window pixels at 1080p, 18 at 4K) from where it was then (`DEAD_ZONE` in `runtime/menu_cursor.c`), so a hand resting on the mouse does not undo a scroll; a click acts at once. With `pointer_image = 1` (off by default) the game window shows a pointer of its own while the cursor is not captured, a gold arrowhead drawn at the window's DPI (`runtime/cursor_art.c`), in place of the system arrow. This happens only while the keyboard and mouse are the device used last: after a gamepad button press or a stick pushed past half way the menus are as on the console, with no pointer, until the mouse moves or a key is pressed (`input_kbm_last` in `runtime/input.c`). The ability wheel, the d-pad strips, Autobuild and the Purah Pad's camera stay gameplay: the mouse keeps the camera there. The map has no focus box; it is found in `eui::ScreenMgr`'s list of open screens (every 100 ms: the Purah Pad's frame `AppMenuOverlay_00` with `AppMap_00` and the menu background `AppMenuBG_00`), and there the mouse moves the map's cursor as the left stick does, with the cursor still captured, and the scroll wheel zooms: each notch is a full-tilt push of the right stick (the map's zoom) for 100 ms with 50 ms of neutral after it, up (in) for a turn away from you; a fast scroll's notches wait their turn (at most four), a turn the other way drops them. The Scope opens the same map screen without the menu background and keeps the mouse camera. The Purah Pad's camera (the ability wheel's camera) opens the frame and its pointer `CameraPointer_00` without `AppMap_00` (the Scope has it); there the scroll wheel zooms as the camera's guide shows: each notch is a press of the d-pad's up (in, for a turn away from you) or down for 100 ms with 50 ms of release after it (`menu_cursor_camera`). The Scope itself has no zoom; the wheel does nothing there. When the menu closes the cursor is captured again.
|
||||
|
||||
`runtime/menu_cursor.c` reads eui's screens at each pad read and moves the focus with the writes `eui::BoxCursorMgr::moveBoxCursor` makes, so no game code is called. `menu_cursor = 0` (`TOTK_MENU_CURSOR=0`, live; the *Mouse in the game's menus* row of the Controls tab) turns it off; `TOTK_MENU_CURSOR_LOG=1` logs every screen it reads (by default the first six), with the layout size, the node count and the hit panes it uses.
|
||||
|
||||
### Left click on the map
|
||||
|
||||
With `map_click = 1` (off by default, so each key presses one controller button as everywhere else), on game 1.4.3, while the Purah Pad's map is open (found as above; the Scope is not the map), the left mouse button presses A at the map's cursor instead of the button it is bound to (Y by default). A press is A or the binding from the moment the button goes down until it is released, so a button held as the map opens or closes keeps what it pressed (`poll_merged` in `runtime/input.c`). `map_click = 1` (`TOTK_MAP_CLICK=1`, live; the *Left click on the map* row of the Controls tab) turns it on and `0`, the default, leaves the left button on its binding there. The map is found only while `menu_cursor` is on.
|
||||
|
||||
### Clicks in dialogue
|
||||
|
||||
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 ...`).
|
||||
|
||||
## 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:
|
||||
|
||||
- **Ultrahand object rotation**: turning the mouse wheel while Ultrahand holds an object rotates it directly without holding R or pressing the D-pad (`gameplay_ultrahand_rotate = 1`, sensitivity `gameplay_rotation_sensitivity = 1`). Holding C while scrolling rotates around the alternate axis (`gameplay_ultrahand_c_axis = 1`).
|
||||
- **Ultrahand distance**: holding the right mouse button while scrolling pushes or pulls the held object closer or farther (`gameplay_ultrahand_distance = 1`, sensitivity `gameplay_distance_sensitivity = 1`).
|
||||
- **Free-roam weapon switching**: scrolling the mouse wheel in free roam steps through equipped weapons (`gameplay_weapon_wheel = 1`, sensitivity `gameplay_weapon_sensitivity = 1`). Press E to confirm the chosen weapon; right click or pressing B cancels.
|
||||
- **Quick-selection menus**: scrolling the mouse wheel browses items while a quick-selection menu (weapons, bows, shields, materials) is open (`gameplay_item_wheel = 1`, sensitivity `gameplay_item_sensitivity = 1`). A and D keys step left and right through the strip (`gameplay_item_ad = 1`).
|
||||
- **Smooth map zoom**: the mouse wheel performs continuous inertial zooming on the Purah Pad map (`gameplay_map_zoom = 1`, sensitivity `gameplay_map_zoom_sensitivity = 1`).
|
||||
|
||||
All sub-toggles default to 1 and sensitivities to 1 (range 0.25 to 4.0), so enabling `gameplay_tweaks_enabled` activates the full suite immediately while allowing individual features to be toggled or tuned.
|
||||
|
||||
## Nintendo Switch 2 controllers
|
||||
|
||||
Windows does not present the Switch 2 Pro Controller as a gamepad SDL can open (the log says `input: no gamepad`), so it needs a bridge program that wakes it and creates a virtual gamepad. The DS4Windows fork by hbashton ([github.com/hbashton/DS4Windows](https://github.com/hbashton/DS4Windows), tested with release VIIPERRC4.5.1, a pre-release) with the output set to an emulated DualSense gives buttons, rumble, gyro and accelerometer, and reads the sticks through the controller's calibration (they rest at 0 to 2%). The game reads its virtual DualSense directly; the log then shows `input: gamepad "DualSense Wireless Controller" (rumble, gyro and accelerometer, ...)` and `input: motion sensors on`. Its release notes also list Joy-Con 2 support, which is untested here.
|
||||
@@ -220,6 +242,8 @@ Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as teste
|
||||
@<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>` 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.
|
||||
|
||||
+32
-13
@@ -72,32 +72,47 @@ loads the saves 1.4.3 wrote.
|
||||
`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 four times: `romfs-patches`, `romfs-patches-xbox` and `romfs-patches-xbox-label`
|
||||
The patches are written three 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`), and `romfs-patches-pc` (keyboard and mouse prompts for `prompts = pc`). Each of the three prompt
|
||||
folders is then laid out once more for each game resolution of another shape, `romfs-patches-<style>-<w>x<h>`
|
||||
(`--prompts <style> --aspect`). Those differ from `romfs-patches-<style>` in the UI archive only, and `--reuse`
|
||||
hard-links the other files from it, so the forty-five folders take seconds and a few MiB each. The prompt folders are optional: when one cannot be made, the
|
||||
setup warns and finishes.
|
||||
and `auto`). 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
|
||||
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. **DLSS** (the window's tick box, on by default, or `--dlss`; Windows with an NVIDIA RTX GPU): download
|
||||
7. **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:
|
||||
`xrandr`, else the DRM connectors), of the `output_res` the game defaults to on each, and of the `totk.ini`
|
||||
`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
|
||||
`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.
|
||||
8. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write
|
||||
9. **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, so the next lift rewrites only the chunks whose C changed and
|
||||
Ninja recompiles only those: a new or edited code cheat costs the lift (under a minute on 24 cores, a few minutes on 4)
|
||||
and a few dozen chunks, not a full compile, and the shaders stay prepared.
|
||||
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.
|
||||
|
||||
`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`
|
||||
@@ -105,8 +120,12 @@ whatever the working folder), one argument per line. When an enabled mod has cod
|
||||
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. `[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.
|
||||
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.
|
||||
|
||||
## Command line
|
||||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ Source shorthands:
|
||||
|---|---|---|---|---|
|
||||
| 1.1 | **Colour target the fragment shader does not write keeps its old texel**, even with blending enabled. | Undefined value written/blended. | NXN: zero write mask and no blend for unwritten outputs (`reflection colors`). Already fixed here. | NXN; MNG `games/totk/tests/metal_semantics/probe.m:5` |
|
||||
| 1.2 | **Unwritten vertex outputs read as (0, 0, 0, 1)** in the next stage, including the unwritten components of a partly written output (VS writes xyz, FS divides by w). | FS input with no VS output: interface mismatch, value undefined; an unwritten component of a written output is undefined (AMD: whatever the register holds, often 0). | Ryujinx initialises exactly the components the next stage reads, but only when stages are linked (`Translation/Translator.cs:212-227`, `NextInputAttributesComponents`); position starts (0,0,0,1) (`:259`). NXN Link's Awakening: sun shadow lookups divided by w = 0, scene dim, no shadows. Ours: missing outputs padded with (0, 0, 0, 1), unlinked outputs initialised by translator patch 0006 (section 7, check 2). | NXN |
|
||||
| 1.3 | **Clears honour the scissor and the clear's own channel / stencil write mask**, and may come between draws inside a pass. `SET_CLEAR_SURFACE_CONTROL` (0x10f8) has `RESPECT_STENCIL_MASK`, `USE_CLEAR_RECT`, `USE_SCISSOR0`, `USE_VIEWPORT_CLIP0`. | `vkCmdClearAttachments` takes a rect but **ignores the colour write mask**; load-op clears are whole-attachment. | NXN/MNG draw a triangle with the clear's mask (`clear_color_tri`, `clear_ds_tri`); TotK uses mid-pass, partial-mask and partial-scissor clears (NXN). yuzu: "red dot" was clears hitting the wrong RT index (YZ-2305, PR 10243). Hardware recipe (DK3D): `CLEAR_BUFFERS` (`0x674` = 0x19d0) carries the colour channel mask (bits 2-5), depth (0), stencil (1), target id (6-9) and layer (10-20) in one word; `ClearBufferFlags` (`0x43E` = 0x10f8) is set once to `StencilMask | Scissor` (`maxwell/gpu_3d_base.cpp:69`), so every clear is cut by scissor 0 and its stencil bits by the stencil front write mask register, and DK3D's colour clear does not program `ColorWriteMask` (`0x680`). A stencil clear writes `StencilFrontMask` (`0x4E7`) and `ClearStencil` (`0x368`) just before the clear and restores the shadowed state after (`gpu_3d_base.cpp:497-510`). Multisample raster is switched off around a colour clear (`:459, :465`). Arrays: an MME macro repeats the clear for every layer (`maxwell/clear_buffers.mme:5-22`). No pass concept: clears sit between draws. Ours: masked colour and stencil clears are **skipped** (check 3). | OGD 0x10f8; NXN; DK3D `maxwell/gpu_3d_base.cpp:444-512`, `engine_3d.def:305, 644` |
|
||||
| 1.3 | **Clears honour the scissor and the clear's own channel / stencil write mask**, and may come between draws inside a pass. `SET_CLEAR_SURFACE_CONTROL` (0x10f8) has `RESPECT_STENCIL_MASK`, `USE_CLEAR_RECT`, `USE_SCISSOR0`, `USE_VIEWPORT_CLIP0`. | `vkCmdClearAttachments` takes a rect but **ignores the colour write mask**; load-op clears are whole-attachment. | NXN/MNG draw a triangle with the clear's mask (`clear_color_tri`, `clear_ds_tri`); TotK uses mid-pass, partial-mask and partial-scissor clears (NXN). yuzu: "red dot" was clears hitting the wrong RT index (YZ-2305, PR 10243). Hardware recipe (DK3D): `CLEAR_BUFFERS` (`0x674` = 0x19d0) carries the colour channel mask (bits 2-5), depth (0), stencil (1), target id (6-9) and layer (10-20) in one word; `ClearBufferFlags` (`0x43E` = 0x10f8) is set once to `StencilMask \| Scissor` (`maxwell/gpu_3d_base.cpp:69`), so every clear is cut by scissor 0 and its stencil bits by the stencil front write mask register, and DK3D's colour clear does not program `ColorWriteMask` (`0x680`). A stencil clear writes `StencilFrontMask` (`0x4E7`) and `ClearStencil` (`0x368`) just before the clear and restores the shadowed state after (`gpu_3d_base.cpp:497-510`). Multisample raster is switched off around a colour clear (`:459, :465`). Arrays: an MME macro repeats the clear for every layer (`maxwell/clear_buffers.mme:5-22`). No pass concept: clears sit between draws. Ours: masked colour and stencil clears are **skipped** (check 3). | OGD 0x10f8; NXN; DK3D `maxwell/gpu_3d_base.cpp:444-512`, `engine_3d.def:305, 644` |
|
||||
| 1.4 | **Conditional rendering** (`SET_RENDER_ENABLE_A..C` 0x1550-0x1558, NVN `SetRenderEnableConditional`) compares two 64-bit counters at `addr` and `addr+16` on the GPU, in command order. TotK wraps nearly every clear in it. A `TIMESTAMP` report writes 0 to the counter field. | `VK_EXT_conditional_rendering` tests one 32-bit word against zero. | NXN: honouring it fixed the black 3D scene (light-volume depth never cleared). deko3d has no conditional rendering at all (no `SET_RENDER_ENABLE` in `engine_3d.def`), so it cannot settle the compare rule. Ours: evaluated on the CPU at record time; a report from an unfinished submission counts as 0 (check 5). | OGD; NXN |
|
||||
| 1.5 | **Depth mode** is runtime state: `nvnDeviceSetDepthMode` near = -w (GL, NVN default) or 0. Register `SET_VIEWPORT_Z_CLIP` (0x0d7c) `NEGATIVE_W_TO_POSITIVE_W` / `ZERO_TO_POSITIVE_W`. | Vulkan clips z < 0 unless `VK_EXT_depth_clip_control` `negativeOneToOne`. | Ryujinx infers the mode from the viewport transform, falling back to the register (`GetDepthMode`, RYU-SU). NXN: wrong mode either clips everything (black window) or puts all depth in 0.5..1 (DOF blurs the screen). Ours: `negativeOneToOne` from NVN state. DK3D programs both halves: `SetDepthMode` (`0x35F` = 0xd7c) selects the pre-transform clip range, and the viewport transform maps z to [near, far] itself: scale z = `0.5 * (far - near)` and offset z = `0.5 * (near + far)` for -1..1, scale `far - near` and offset `near` for 0..1 (`maxwell/gpu_3d_base.cpp:143-147, 336-343`). Same maths as Vulkan `negativeOneToOne`. | OGD 0x0d7c; NXN-64, NXN; DK3D `maxwell/gpu_3d_base.cpp:136-147, 321-362` |
|
||||
| 1.6 | **Depth clamp / clip**: `SET_VIEWPORT_CLIP_CONTROL` (0x193c) has separate `PIXEL_MIN_Z`/`PIXEL_MAX_Z` CLIP or CLAMP and geometry-clip modes. | `depthClampEnable` also disables z clipping (unless `VK_EXT_depth_clip_enable`). RADV had a dynamic depth clamp driver bug causing TotK vertex explosions. | Ryujinx: clamp = `!(clip & DepthClampDisabled)` (RYU-SU `UpdateDepthClampState`). yuzu disabled dynamic depth clamp on affected RADV (YZ-2305, PR 10262). DK3D has one switch, `depthClampEnable`, and writes `VIEW_VOLUME_CLIP_CONTROL` (`0x64F` = 0x193c) with `0x101A` when on and `0x181D` when off (default at setup is `0x181D`); it labels the bits "todo: figure out what this actually does". Bits 3-4 (`DepthClampNear/Far`) are set in both values, bits 0-2 and 11 differ. There is no separate depth-clip toggle. The viewport near/far registers (`Viewport` array words 2-3) carry the clamp range and are swapped when far < near (`:349-350`). Vulkan clamp to [min, max] of the viewport depth matches. | OGD 0x193c; DK3D `maxwell/gpu_3d_state.cpp:42`, `gpu_3d_base.cpp:135-139, 349-350`, `engine_3d.def:621` |
|
||||
@@ -81,7 +81,7 @@ Source shorthands:
|
||||
| 3.2 | **FMZ multiply mode** (`FMUL/FFMA/...` field `Fmz`, `.FMZ`): 0 × anything = 0, including Inf/NaN (DX9 rule). | IEEE: 0 × Inf = NaN. | Ryujinx decodes `Fmz` (`Decoders/InstDecoders.cs:306-309, 1901`) but no emitter reads it. Ours: same. Census needed (check 13). | RYU-SH |
|
||||
| 3.3 | **Denormals**: per-instruction `.FTZ`. | AMD flushes fp32 denormals by default; `VK_KHR_shader_float_controls` sets it per shader. | Ryujinx ignores `.FTZ`. Low risk. | RYU-SH (no `Ftz` use in `Instructions/`) |
|
||||
| 3.4 | **Warp size 32**: `SHFL`, `VOTE`, `S2R LANEID`, ballots are 32-bit. | AMD RDNA runs wave32 or wave64 per shader (the driver chooses; RADV fragment default wave64); `VK_EXT_subgroup_size_control` `requiredSubgroupSize = 32` fixes it. | Ryujinx adapts lane masks to `QueryHostSubgroupSize()` (default 32, `IGpuAccessor.cs:218`; `Instructions/InstEmitWarp.cs:72, 106`, `InstEmitMove.cs:175-185`). Ours: not overridden, no required size (check 6). | <https://docs.mesa3d.org/envvars.html> (`RADV_PERFTEST=pswave32`) |
|
||||
| 3.5 | **Discard (`KIL`)** keeps the quad's derivatives valid (demote semantics). | `OpKill` terminates; later derivatives in the quad undefined. | Ryujinx emits `OpKill` (`CodeGen/Spirv/Instructions.cs:508`). | — |
|
||||
| 3.5 | **Discard (`KIL`)** keeps the quad's derivatives valid (demote semantics). | `OpKill` terminates; later derivatives in the quad undefined. | Ryujinx emits `OpKill` (`CodeGen/Spirv/Instructions.cs:508`). Ours: on AMD's own drivers (`vk_caps.amd` without `mesa`) `vk_pipeline.c` `spirv_demote` turns each `OpKill` that a selection header branches to into `OpDemoteToHelperInvocation` plus a branch to the selection's merge block; `TOTK_DEMOTE` overrides. TotK's cloud shader discards and then takes `OpImageQueryLod`: with `OpKill` AMD's Windows driver lost fog in the fragments sharing a quad with a discarded one (#164). | <https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/EXT/SPV_EXT_demote_to_helper_invocation.asciidoc> |
|
||||
| 3.6 | **Implicit-LOD sampling in divergent control flow** works on Maxwell (TEX unit uses quad neighbours). | Undefined in non-uniform control flow; AMD whole-quad mode usually works. | — | VKSPEC (derivatives) |
|
||||
| 3.7 | **Integer division** does not exist (compiled to `XMAD`/`IMAD` sequences); MUFU.RCP(0) = +Inf, LG2(0) = -Inf. | Same IEEE edge cases through `1/x`, `Log2`. | Low risk. | — |
|
||||
| 3.8 | **FP64** in some TotK cutscene shaders. | No FP64 on some hosts. | yuzu FP64 → FP32 (YZ-2306, PR 10693); ours: `softfloat64` job flag (`tools/xlate/Program.cs` `QueryHostSupportsShaderFloat64`). | — |
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ keeps its textures at a quarter of the size.
|
||||
| On the Mods tab | Why | What to do |
|
||||
|---|---|---|
|
||||
| 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 are made for another game version and are left out. | The mod's files carry another update's version in their names (`.Product.<number>.`). | Download the mod's release for your game update. |
|
||||
| ... 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. |
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Game 1.1.0 patch coverage
|
||||
|
||||
The built-in table is [recomp/patches-v110.txt](../recomp/patches-v110.txt). These sites were located in the local 1.1.0 main and checked against its original instruction words, rather than applying a version-wide address shift. The generator rejects a different word or an invalid spin back-edge.
|
||||
|
||||
## Added coverage
|
||||
|
||||
| Set | Sites added | Runtime control |
|
||||
| --- | ---: | --- |
|
||||
| realtime | 1 | Equipment-switch cooldown: step every positive remainder, including values below FLT_EPSILON. Follows the existing real-time clock switch. |
|
||||
| cursor | 3 | Scale map panning, vertical ability aim and vertical gyro aim by the 30 Hz ratio; follows `TOTK_HIGHFPS_FIX`. |
|
||||
| aspect | 4 | The two camera and two viewport projections read page +56. The resolution code enables it for non-16:9 output. |
|
||||
| fov | 2 | The two camera projections multiply their vertical angle by page +60. The field-of-view setting is live; 100 leaves the original path. |
|
||||
| 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. |
|
||||
|
||||
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 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.
|
||||
|
||||
## Deliberately separate
|
||||
|
||||
- Direct mouse: 1.1.0 continues to use stick emulation. Porting the complete camera hook set also needs the runtime layout and load-site table; matching an individual store or one camera mode is not sufficient. No partial set is enabled here.
|
||||
- Fade: the four 1.4.3 sites are not presumed to exist in 1.1.0. An equivalent zero-increment path has not been established.
|
||||
- Native Zstandard: the existing host bridge calls back to hard-coded 1.4.3 decoder entry points on fallback. Adding only the BL patches to 1.1.0 would be incorrect.
|
||||
- Live DLSS scene sizing and game-menu mouse input retain their existing version restrictions. They are not patch-table parity work.
|
||||
|
||||
## Validation
|
||||
|
||||
Run with Python's numpy, lz4, capstone and unicorn dependencies and a runtime-supported Clang:
|
||||
|
||||
```sh
|
||||
# CC selects the Clang used by the differential harness.
|
||||
python tests/patches_v110_check.py
|
||||
python tests/patches_v110_check.py --cflags=-march=x86-64-v2
|
||||
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.
|
||||
@@ -75,7 +75,7 @@ A PR touching these needs stronger proof.
|
||||
| #519, #582 amiibo | rewritten by us | took the data-format fixes; left out the features and the Linux event rework |
|
||||
| #483 vs #585 | #585's mapping kept | #483's stick glyph mapping was rewritten unasked while #585 already had it right |
|
||||
| #528 rain | taken after a check | code review fine, merged only after a run on a rain save |
|
||||
| #767 | taken with our fix | the default was skipped with `prompts = xbox|pc` when those folders did not exist |
|
||||
| #767 | taken with our fix | the default was skipped with `prompts = xbox\|pc` when those folders did not exist |
|
||||
| #625 frame queue | taken, off by default | a new frame queue, one field run with it on |
|
||||
| #743 UB overlay | waiting | +25% in a Depths fight on an RTX 4080; needs review, fight runs x2 and shots on AMD |
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| --- | --- | --- | --- |
|
||||
| `amiibo_dir` | Folder the Amiibo tab starts in; the tab saves the folder you last browsed here. | Only changes which folder the tab lists first. | Safe |
|
||||
| `exefs` | Folder of the game's ExeFS (with `main.npdm`); a relative path is relative to `totk.exe`'s folder. | Without it, an `exefs` folder next to `totk.exe` is used, else the path set at build time. The game code is compiled into `totk.exe`, and the loader checks the files here by SHA-256, so files from another build or game version stop the start with a message. | Caution |
|
||||
| `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 |
|
||||
@@ -121,6 +122,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `bind_inc` (default `0`) | `1` (or `on`) prepares a draw from what changed since the draw before (the bind ops mark the slots whose bytes they changed) instead of from the whole bound state; `check` prepares every draw as before, takes every decision of `on` beside it, logs each kind of difference once and counts them in a `bind_inc:` line every 300 frames; `0` or `off`: as before. `check` also counts what changed between draws in that line. | Less work per draw on the render thread; a change the marks missed would leave a stale descriptor, a wrong picture or a lost device, which `check` would show first. Off by default: with it on, a GTX 1050 Ti lost the device at one place, after the validation layer reported a descriptor pool reset while a command buffer still used its sets; the cause is not found yet. | Caution |
|
||||
| `block_views_3d` (default `0`) | `1` gives 3D block-compressed images block views too. | On some AMD cards a GPU write past the end of the image's memory loses the Vulkan device, and the game stops. | Risky |
|
||||
| `deswizzle` (default `auto`) | Where block-linear textures are deswizzled: `auto` or `gpu` uses a compute pass where the texture's storage is an imported pool and the CPU elsewhere, `cpu` always uses the CPU, `check` uses the GPU and also deswizzles every upload on the CPU and compares the two. | `cpu` brings back the long frames on entering new areas (the replay thread deswizzles every texture); `check` waits for the GPU at every upload and is for testing only. The log names the mode in use. | Caution |
|
||||
| `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 |
|
||||
@@ -178,6 +180,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 |
|
||||
|
||||
## Scheduling and host
|
||||
|
||||
@@ -207,9 +210,12 @@ These names are code patch sets built into the generated game code (`recomp/patc
|
||||
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `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 |
|
||||
| `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 |
|
||||
| `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 |
|
||||
+1
-1
@@ -619,7 +619,7 @@ class App:
|
||||
# ---- self test ---------------------------------------------------------------------------------------------------
|
||||
|
||||
SAMPLE_START = {'type': 'start', 'release': 'selftest', 'mode': 'install', 'dest': 'Z:/selftest/TotK', 'log': 'D:\\log.txt',
|
||||
'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'dlss', 'cleanup']}
|
||||
'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', 'cleanup']}
|
||||
SAMPLE_RUN = [
|
||||
SAMPLE_START,
|
||||
{'type': 'plan', 'run': ['check', 'fonts', 'extract'], 'skip': {}},
|
||||
|
||||
@@ -27,7 +27,7 @@ TEXT = Path(__file__).resolve().parent / 'text'
|
||||
UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans')
|
||||
# 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', 'dlss', 'cleanup')
|
||||
STEP_ORDER = ('check', '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
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
"""The screen shapes and button prompts this player needs RomFS patch folders for (steps.Shapes).
|
||||
|
||||
A game resolution of another shape than 16:9 takes romfs-patches-<w>x<h>, the UI laid out for that shape
|
||||
(tools/make_romfs_patches.py --aspect), and the prompts' folder of that shape (romfs-patches-<style>-<w>x<h>). The
|
||||
layout depends only on the aspect ratio (tools/ultrawide_layout.py apply), so the setup writes one folder per shape,
|
||||
named after the shape's size in ASPECT_SIZES (shape_size); runtime/romfs.c overlay_init maps the game resolution the
|
||||
same way (cfg.c cfg_shape_size). It writes them only for the shapes of the connected displays and the totk.ini
|
||||
output_res, and the prompts' ones only for the style totk.ini selects (prompts_style).
|
||||
"""
|
||||
import ctypes
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
# The game resolutions of another shape than 16:9 that runtime/ui/menu.cpp row_output_res lists, in the order of
|
||||
# runtime/cfg.c SHAPED: 21:9 and 32:9 monitors, 16:10 screens (the Steam Deck's 1280x800, handhelds and laptops) and 3:2
|
||||
# screens (Surface and Framework laptops and tablets)
|
||||
ASPECT_SIZES = ('2560x1080', '3440x1440', '3840x1600', '5120x2160', '3840x1080', '5120x1440',
|
||||
'1280x800', '1680x1050', '1920x1200', '2560x1600',
|
||||
'1920x1280', '2160x1440', '2256x1504', '2880x1920', '3000x2000')
|
||||
SHAPED = tuple(tuple(int(v) for v in s.split('x')) for s in ASPECT_SIZES)
|
||||
TOLERANCE = 0.01 # cfg.c and resolution.c res_is_16x9: shapes within 1% are the same
|
||||
|
||||
|
||||
def is_16x9(w, h):
|
||||
return abs((w / h) / (16 / 9) - 1) <= TOLERANCE
|
||||
|
||||
|
||||
def shape_size(w, h):
|
||||
"""The folder size of w x h's shape: of ASPECT_SIZES within 1% of its aspect ratio, the closest, the first of equal
|
||||
ones (5120x2160 is 2560x1080's shape). None for 16:9 and for a shape the setup has no layout for. The same rule as
|
||||
runtime/cfg.c cfg_shape_size."""
|
||||
if not w or not h or is_16x9(w, h):
|
||||
return None
|
||||
r, best, err = w / h, None, None
|
||||
for sw, sh in SHAPED:
|
||||
e = abs(sw / sh / r - 1)
|
||||
if e <= TOLERANCE and (err is None or e < err):
|
||||
best, err = f'{sw}x{sh}', e
|
||||
return best
|
||||
|
||||
|
||||
def default_size(w, h):
|
||||
"""The output_res the game picks on a display of w x h while totk.ini sets none (runtime/cfg.c screen_default): of
|
||||
ASPECT_SIZES within 1% of its shape, the smallest at least 1080 high that fits, else the largest that fits."""
|
||||
if not w or not h or is_16x9(w, h):
|
||||
return None
|
||||
r, best, fit = w / h, None, None
|
||||
for sw, sh in SHAPED:
|
||||
if abs(sw / sh / r - 1) > TOLERANCE or sw > w or sh > h:
|
||||
continue
|
||||
if fit is None or sw > fit[0]:
|
||||
fit = (sw, sh)
|
||||
if sh >= 1080 and (best is None or sw < best[0]):
|
||||
best = (sw, sh)
|
||||
best = best or fit
|
||||
return f'{best[0]}x{best[1]}' if best else None
|
||||
|
||||
|
||||
# ---- the connected displays, as (width, height) of their current mode, the long side first (a portrait monitor or
|
||||
# the Steam Deck's panel reports its height first; the game window is landscape)
|
||||
|
||||
class DISPLAY_DEVICEW(ctypes.Structure):
|
||||
_fields_ = [('cb', ctypes.c_uint32), ('DeviceName', ctypes.c_wchar * 32), ('DeviceString', ctypes.c_wchar * 128),
|
||||
('StateFlags', ctypes.c_uint32), ('DeviceID', ctypes.c_wchar * 128), ('DeviceKey', ctypes.c_wchar * 128)]
|
||||
|
||||
|
||||
ATTACHED_TO_DESKTOP = 0x1
|
||||
ENUM_CURRENT_SETTINGS = -1
|
||||
DEVMODEW_SIZE = 220 # DEVMODEW: dmSize at 68, dmPelsWidth at 172, dmPelsHeight at 176
|
||||
DEVMODE_PELS = 172
|
||||
|
||||
|
||||
def windows_displays():
|
||||
"""Every display attached to the desktop: EnumDisplayDevicesW over the adapters, EnumDisplaySettingsW for the
|
||||
current mode, which is in pixels whatever the DPI awareness of this process."""
|
||||
user32 = ctypes.WinDLL('user32')
|
||||
out, i = [], 0
|
||||
while True:
|
||||
dev = DISPLAY_DEVICEW()
|
||||
dev.cb = ctypes.sizeof(dev)
|
||||
if not user32.EnumDisplayDevicesW(None, i, ctypes.byref(dev), 0):
|
||||
break
|
||||
i += 1
|
||||
if not dev.StateFlags & ATTACHED_TO_DESKTOP:
|
||||
continue
|
||||
mode = ctypes.create_string_buffer(DEVMODEW_SIZE)
|
||||
ctypes.c_uint16.from_buffer(mode, 68).value = DEVMODEW_SIZE
|
||||
if user32.EnumDisplaySettingsW(dev.DeviceName, ENUM_CURRENT_SETTINGS, mode):
|
||||
out.append((ctypes.c_uint32.from_buffer(mode, DEVMODE_PELS).value,
|
||||
ctypes.c_uint32.from_buffer(mode, DEVMODE_PELS + 4).value))
|
||||
return out
|
||||
|
||||
|
||||
XRANDR = re.compile(r'\sconnected\s+(?:primary\s+)?(\d+)x(\d+)\+')
|
||||
|
||||
|
||||
def linux_displays():
|
||||
"""xrandr's connected outputs (X11 and XWayland); without xrandr the preferred mode of each connected DRM
|
||||
connector."""
|
||||
if shutil.which('xrandr'):
|
||||
try:
|
||||
text = subprocess.run(['xrandr', '--current'], capture_output=True, text=True, timeout=10).stdout
|
||||
found = [(int(w), int(h)) for w, h in XRANDR.findall(text)]
|
||||
if found:
|
||||
return found
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
pass
|
||||
out = []
|
||||
for conn in sorted(Path('/sys/class/drm').glob('card*-*')):
|
||||
try:
|
||||
if (conn / 'status').read_text().strip() != 'connected':
|
||||
continue
|
||||
m = re.match(r'(\d+)x(\d+)', (conn / 'modes').read_text())
|
||||
except OSError:
|
||||
continue
|
||||
if m:
|
||||
out.append((int(m.group(1)), int(m.group(2))))
|
||||
return out
|
||||
|
||||
|
||||
def displays():
|
||||
try:
|
||||
found = windows_displays() if os.name == 'nt' else linux_displays()
|
||||
except (OSError, AttributeError, ValueError):
|
||||
found = []
|
||||
return sorted({(max(w, h), min(w, h)) for w, h in found if w and h})
|
||||
|
||||
|
||||
# ---- totk.ini (runtime/cfg.c reads the same keys, in any section, with or without the totk_ prefix)
|
||||
|
||||
def ini_value(text, name):
|
||||
value = None
|
||||
for line in text.splitlines():
|
||||
m = re.match(rf'^\s*(?:totk_)?{name}\s*=\s*([^\s#;]*)', line, re.IGNORECASE)
|
||||
if m:
|
||||
value = m.group(1)
|
||||
return value
|
||||
|
||||
|
||||
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':
|
||||
return 'pc'
|
||||
if not (p.lower() == 'xbox' if p else layout == 'xbox_prompts'):
|
||||
return None
|
||||
return 'xbox' if layout in ('nintendo', 'xbox_prompts') else 'xbox-label'
|
||||
|
||||
|
||||
def wanted(dest, screens=None):
|
||||
"""(sizes, style): the shape sizes to write layouts for, sorted, and the prompts style. A shape is wanted for each
|
||||
display's own size and for the output_res the game defaults to there, and for the totk.ini output_res."""
|
||||
screens = displays() if screens is None else screens
|
||||
try:
|
||||
text = (Path(dest) / 'totk.ini').read_text(encoding='utf-8-sig', errors='replace')
|
||||
except OSError:
|
||||
text = ''
|
||||
sizes = set()
|
||||
for w, h in screens:
|
||||
w, h = max(w, h), min(w, h)
|
||||
sizes.add(shape_size(w, h))
|
||||
d = default_size(w, h)
|
||||
if d:
|
||||
sizes.add(shape_size(*(int(v) for v in d.split('x'))))
|
||||
m = re.fullmatch(r'(\d+)x(\d+)', (ini_value(text, 'output_res') or '').lower())
|
||||
if m:
|
||||
sizes.add(shape_size(int(m.group(1)), int(m.group(2))))
|
||||
sizes.discard(None)
|
||||
return sorted(sizes, key=ASPECT_SIZES.index), prompts_style(text)
|
||||
+153
-49
@@ -1,4 +1,5 @@
|
||||
"""The eight setup steps of docs/installer.md: check, fonts, extract, lift, compile, prepare, dlss, cleanup.
|
||||
"""The ten setup steps of docs/installer.md: check, 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
|
||||
@@ -8,14 +9,15 @@ with the bundled clang (hostcheck.c).
|
||||
|
||||
Install folder: exefs/, romfs/ (romfs.bin, index.json), profile/, shared-fonts/ (Chinese and Korean text), totk.exe
|
||||
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-<style>-<w>x<h>/ (each of the three for each shaped size),
|
||||
totk_xlate.exe, the
|
||||
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
|
||||
logs/: the next run lifts into the same gen/, where recomp/gen.py rewrites only the chunks whose C changed, and Ninja
|
||||
in build/ recompiles only those. A change of the mods' code cheats then costs the lift (about a minute) and the chunks
|
||||
it touches, not a full compile.
|
||||
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
|
||||
rebuild.txt, the command that starts this setup in its rebuild mode on the install folder (installer/gui.py --rebuild),
|
||||
@@ -36,7 +38,7 @@ import time
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
from . import ini
|
||||
from . import ini, screens
|
||||
from .layout import EXE, SUPPORTED, version_tag
|
||||
from .runner import InstallError, Step
|
||||
|
||||
@@ -140,6 +142,17 @@ def linux_kernel():
|
||||
return (int(m.group(1)), int(m.group(2))) if m else None
|
||||
|
||||
|
||||
def link_output_locked(log):
|
||||
"""Whether a build failed because another program holds the exe the linker writes: ld.lld cannot write it and clang
|
||||
cannot remove it (Permission denied). A game started from the temp build folder does that, and so does an
|
||||
antivirus that flagged or quarantined the new totk.exe there (#1122)."""
|
||||
try:
|
||||
text = Path(log).read_text(encoding='utf-8', errors='replace')
|
||||
except OSError:
|
||||
return False
|
||||
return 'failed to write output' in text and 'Permission denied' in text
|
||||
|
||||
|
||||
def run_tool(ctx, step, script, args, parse=None, cwd=None):
|
||||
"""Run a tool script with the bundled Python. Its output goes to <temp>/logs/<step>-<script>.log and, line by line,
|
||||
to parse(line). Returns (exit code, log path)."""
|
||||
@@ -888,8 +901,9 @@ class Lift(Step):
|
||||
return (gen / 'layout.json').is_file() and stamp.is_file() and stamp.read_text().strip() == ctx.keys['lift']
|
||||
|
||||
def run(self, ctx):
|
||||
# gen/ of the last run stays: gen.py rewrites only the chunks whose C changed (and removes the ones a smaller
|
||||
# partition no longer has), so Ninja recompiles only those
|
||||
# gen/ of the last run stays: gen.py lifts again only the chunks whose inputs changed
|
||||
# (gen/<mod>/lift_cache.json; TOTK_LIFT_CACHE=0 lifts all), rewrites only those whose C changed (and removes
|
||||
# the ones a smaller partition no longer has), so Ninja recompiles only those
|
||||
layout, rep, gen = ctx.layout, ctx.reporter, ctx.temp / 'gen'
|
||||
(gen / STAMP).unlink(missing_ok=True)
|
||||
rep.progress('lift', 'discover', force=True)
|
||||
@@ -1009,6 +1023,8 @@ class Compile(Step):
|
||||
'--exefs', dest / 'exefs', '--romfs', dest / 'romfs',
|
||||
'--profile', dest / 'profile'], parse)
|
||||
exe = build / ('totk' + EXE)
|
||||
if code and link_output_locked(log):
|
||||
raise InstallError('compile.exe_locked', path=str(exe), log=str(log))
|
||||
if code or not exe.is_file():
|
||||
raise InstallError('compile.failed', code=code, log=str(log))
|
||||
try:
|
||||
@@ -1029,12 +1045,7 @@ TRANSLATED = re.compile(r'gfx_shader: prepare: (\d+) of (\d+) pairs')
|
||||
SKIPPED = re.compile(r'prepare-shaders: (\d+) variants skipped: the graphics driver crashed')
|
||||
|
||||
|
||||
# The game resolutions of another shape than 16:9 that runtime/ui/menu.cpp row_output_res lists: 21:9 and 32:9 monitors,
|
||||
# 16:10 screens (the Steam Deck's 1280x800, handhelds and laptops) and 3:2 screens (Surface and Framework laptops and
|
||||
# tablets)
|
||||
ASPECT_SIZES = ('2560x1080', '3440x1440', '3840x1600', '5120x2160', '3840x1080', '5120x1440',
|
||||
'1280x800', '1680x1050', '1920x1200', '2560x1600',
|
||||
'1920x1280', '2160x1440', '2256x1504', '2880x1920', '3000x2000')
|
||||
ASPECT_SIZES = screens.ASPECT_SIZES
|
||||
|
||||
|
||||
class Prepare(Step):
|
||||
@@ -1084,24 +1095,14 @@ class Prepare(Step):
|
||||
dest / 'romfs-patches'])
|
||||
if code:
|
||||
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
|
||||
# The same overlay with the UI laid out for each game resolution of another shape the settings menu offers
|
||||
# (runtime/romfs.c overlay_init picks the one that matches; the camera's side is the patch set aspect,
|
||||
# recomp/patches-v<ver>.txt).
|
||||
for size in ASPECT_SIZES:
|
||||
remove(dest / f'romfs-patches-{size}')
|
||||
code, log = run_tool(ctx, 'prepare', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version_tag(game_version(ctx)), '--romfs', dest / 'romfs', '--out',
|
||||
dest / f'romfs-patches-{size}', '--aspect', size])
|
||||
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 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. romfs-patches-pc likewise, with keyboard and mouse
|
||||
# prompts for prompts = pc.
|
||||
# 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', 'pc'):
|
||||
for style in ('xbox', 'xbox-label'):
|
||||
out = dest / f'romfs-patches-{style}'
|
||||
remove(out)
|
||||
code, log = run_tool(ctx, f'prepare-{style}', layout.tools / 'make_romfs_patches.py',
|
||||
@@ -1110,25 +1111,6 @@ class Prepare(Step):
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
# Each prompts' folder once more for each shape of ASPECT_SIZES, romfs-patches-<style>-<w>x<h> with that
|
||||
# shape's UI layout (--prompts <style> --aspect), which runtime/romfs.c overlay_init loads in place of
|
||||
# romfs-patches-<w>x<h>: without it a player with Xbox or PC prompts on a screen that is not 16:9 chose between
|
||||
# the prompts and the screen's shape. Only the Common archive differs from romfs-patches-<style>; --reuse links
|
||||
# the fonts, messages and size table from there instead of compressing them again, so each folder takes
|
||||
# seconds and a few MiB. Optional like romfs-patches-<style>, and skipped without it.
|
||||
for style in ('xbox', 'xbox-label', 'pc'):
|
||||
plain = dest / f'romfs-patches-{style}'
|
||||
for size in ASPECT_SIZES:
|
||||
out = dest / f'romfs-patches-{style}-{size}'
|
||||
remove(out)
|
||||
if not (plain / 'manifest.tsv').is_file():
|
||||
continue
|
||||
code, log = run_tool(ctx, f'prepare-{style}-{size}', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version_tag(game_version(ctx)), '--romfs', dest / 'romfs', '--out',
|
||||
out, '--prompts', style, '--aspect', size, '--reuse', plain])
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
if failed:
|
||||
rep.warning('warn.xbox_prompts_failed', code=failed[0], log=str(failed[1]))
|
||||
|
||||
@@ -1167,6 +1149,121 @@ class Prepare(Step):
|
||||
return {'xlate_sha256': file_sha256(xlate)}
|
||||
|
||||
|
||||
# ---- 6b. Keyboard and mouse prompts
|
||||
|
||||
def bind_lines(dest):
|
||||
"""The bind_ lines of the install's totk.ini (the Controls tab writes them), '' without the file."""
|
||||
try:
|
||||
text = (dest / 'totk.ini').read_text(encoding='utf-8', errors='replace')
|
||||
except OSError:
|
||||
return ''
|
||||
return '\n'.join(s for s in (line.split('#')[0].split(';')[0].strip() for line in text.splitlines())
|
||||
if s.lower().startswith('bind_'))
|
||||
|
||||
|
||||
def pc_binds(dest):
|
||||
"""make_romfs_patches.py's --binds argument for the keyboard and mouse prompts: totk.ini when it has bind_ lines."""
|
||||
return ['--binds', dest / 'totk.ini'] if bind_lines(dest) else []
|
||||
|
||||
|
||||
class PcPrompts(Step):
|
||||
"""romfs-patches-pc (16:9), for prompts = pc: the prompts drawn as the keys and mouse buttons of totk.ini's bind_
|
||||
lines (make_romfs_patches.py --prompts pc --binds), the keyboard defaults without them. Its own step, keyed by those
|
||||
lines, so running the setup again after a change of the bindings draws the prompts again and leaves the shaders
|
||||
alone. The shaped romfs-patches-pc-<w>x<h> are the Shapes step's, which follows this key. Optional like the Xbox
|
||||
prompts: a failure warns, and the game keeps the Switch prompts."""
|
||||
id = 'pc_prompts'
|
||||
|
||||
def key(self, ctx):
|
||||
layout = ctx.layout
|
||||
tools = [layout.tools / n for n in ('make_romfs_patches.py', 'ultrawide_layout.py', 'button_icons.py')]
|
||||
return fingerprint('pc-prompts-1', ctx.keys['extract'], *tools, bind_lines(ctx.dest))
|
||||
|
||||
def current(self, ctx, record):
|
||||
return record.get('failed') or (ctx.dest / 'romfs-patches-pc' / 'manifest.tsv').is_file()
|
||||
|
||||
def run(self, ctx):
|
||||
layout, rep, dest = ctx.layout, ctx.reporter, ctx.dest
|
||||
rep.progress('pc_prompts', 'draw', force=True)
|
||||
plain = dest / 'romfs-patches-pc'
|
||||
remove(plain)
|
||||
code, log = run_tool(ctx, 'prepare-pc', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version_tag(game_version(ctx)), '--romfs', dest / 'romfs', '--out', plain,
|
||||
'--prompts', 'pc', *pc_binds(dest)])
|
||||
if code:
|
||||
remove(plain)
|
||||
rep.warning('warn.xbox_prompts_failed', code=code, log=str(log))
|
||||
return {'failed': True}
|
||||
return {}
|
||||
|
||||
|
||||
# ---- 6b. screen shapes
|
||||
|
||||
SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-xbox|-xbox-label|-pc)?-\d+x\d+$')
|
||||
|
||||
|
||||
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
|
||||
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)."""
|
||||
|
||||
id = 'shapes'
|
||||
|
||||
def wanted(self, ctx):
|
||||
if not hasattr(ctx, 'shapes_wanted'):
|
||||
ctx.shapes_wanted = screens.wanted(ctx.dest)
|
||||
return ctx.shapes_wanted
|
||||
|
||||
def key(self, ctx):
|
||||
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)
|
||||
|
||||
def current(self, ctx, record):
|
||||
return 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
|
||||
sizes, style = self.wanted(ctx)
|
||||
rep.log(f'shapes: displays {screens.displays()}, layouts for {sizes or "none"}, prompts {style or "nintendo"}')
|
||||
for old in dest.iterdir() if dest.is_dir() else ():
|
||||
if old.is_dir() and SHAPED_FOLDER.match(old.name):
|
||||
remove(old)
|
||||
version = version_tag(game_version(ctx))
|
||||
plain = dest / f'romfs-patches-{style}' if style else None
|
||||
folders, failed = [], None
|
||||
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:
|
||||
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}
|
||||
|
||||
|
||||
# ---- 7. NVIDIA DLSS
|
||||
|
||||
# NVIDIA's DLSS library, which NGX loads from the folder of totk.exe (runtime/vk_dlaa.c). The setup does not ship it:
|
||||
@@ -1277,8 +1374,15 @@ REBUILD_BOOT = ('import runpy, sys; sys.path.insert(0, sys.argv.pop(1)); '
|
||||
def rebuild_command(ctx):
|
||||
"""The command that starts the setup window in its rebuild mode on this install folder (installer/gui.py
|
||||
--rebuild): pythonw beside the setup's Python on Windows, so no console opens. In a repository that is the Python
|
||||
running this setup: the tools' embeddable Python there has no tkinter."""
|
||||
running this setup: the tools' embeddable Python there has no tkinter.
|
||||
In the Linux AppImage the release folder is the AppImage's mount (/tmp/.mount_*), which goes away when the setup
|
||||
exits, so a path into it would fail to start later and the game would keep its old code. The command starts the
|
||||
AppImage file itself instead ($APPIMAGE, set by the AppImage runtime); its AppRun passes the arguments to
|
||||
installer.gui."""
|
||||
layout = ctx.layout
|
||||
appimage = os.environ.get('APPIMAGE', '')
|
||||
if not layout.dev and appimage and Path(appimage).is_file():
|
||||
return [str(Path(appimage).resolve()), '--rebuild', str(ctx.dest)]
|
||||
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')
|
||||
@@ -1310,4 +1414,4 @@ def romfs_problem(romfs, expected):
|
||||
|
||||
|
||||
def all_steps():
|
||||
return [Check(), Fonts(), Extract(), Lift(), Compile(), Prepare(), Dlss(), Cleanup()]
|
||||
return [Check(), Fonts(), Extract(), Lift(), Compile(), Prepare(), PcPrompts(), Shapes(), Dlss(), Cleanup()]
|
||||
@@ -5,6 +5,8 @@
|
||||
"step.lift": "Translating the game code to C",
|
||||
"step.compile": "Compiling {game_exe}",
|
||||
"step.prepare": "Preparing the shaders",
|
||||
"step.pc_prompts": "Drawing the keyboard and mouse prompts",
|
||||
"step.shapes": "Laying out the game screens for your displays",
|
||||
"step.dlss": "Downloading NVIDIA DLSS",
|
||||
"step.cleanup": "Cleaning up",
|
||||
|
||||
@@ -29,10 +31,12 @@
|
||||
"phase.compile.compile": "Compiling",
|
||||
"phase.compile.link": "Linking {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Writing the 60 fps game data patches",
|
||||
"phase.pc_prompts.draw": "Drawing the keyboard and mouse button prompts from totk.ini's bindings",
|
||||
"phase.prepare.seed": "Reading the shaders from the game data",
|
||||
"phase.prepare.translate": "Translating the shaders",
|
||||
"phase.prepare.libraries": "Building the shaders for the graphics driver",
|
||||
"phase.prepare.pack": "Packing the shader cache into one file",
|
||||
"phase.shapes.layouts": "Writing the screen layouts and button prompts for each display shape",
|
||||
"phase.dlss.download": "Downloading nvngx_dlss.dll from NVIDIA's DLSS SDK",
|
||||
"phase.cleanup.ini": "Writing totk.ini",
|
||||
"phase.cleanup.temp": "Removing temporary files",
|
||||
@@ -91,6 +95,7 @@
|
||||
"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.",
|
||||
"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.",
|
||||
"prepare.romfs_patches_failed": "Writing the game data patches failed (exit code {code}). Details: {log}",
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"step.lift": "Traduzindo o código do jogo para C",
|
||||
"step.compile": "Compilando o {game_exe}",
|
||||
"step.prepare": "Preparando os shaders",
|
||||
"step.pc_prompts": "Desenhando os ícones de teclado e mouse",
|
||||
"step.shapes": "Ajustando as telas do jogo aos seus monitores",
|
||||
"step.dlss": "Baixando o NVIDIA DLSS",
|
||||
"step.cleanup": "Finalizando",
|
||||
|
||||
@@ -29,10 +31,12 @@
|
||||
"phase.compile.compile": "Compilando",
|
||||
"phase.compile.link": "Ligando o {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Gravando os patches de 60 fps nos dados do jogo",
|
||||
"phase.pc_prompts.draw": "Desenhando os ícones de teclas e botões do mouse a partir das atribuições do totk.ini",
|
||||
"phase.prepare.seed": "Lendo os shaders dos dados do jogo",
|
||||
"phase.prepare.translate": "Traduzindo os shaders",
|
||||
"phase.prepare.libraries": "Montando os shaders para o driver de vídeo",
|
||||
"phase.prepare.pack": "Juntando o cache de shaders num único arquivo",
|
||||
"phase.shapes.layouts": "Gravando os layouts de tela e os botões para cada formato de monitor",
|
||||
"phase.dlss.download": "Baixando o nvngx_dlss.dll do DLSS SDK da NVIDIA",
|
||||
"phase.cleanup.ini": "Gravando o totk.ini",
|
||||
"phase.cleanup.temp": "Removendo os arquivos temporários",
|
||||
@@ -91,6 +95,7 @@
|
||||
"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.",
|
||||
"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.",
|
||||
"prepare.romfs_patches_failed": "Falha ao gravar os patches nos dados do jogo (código de saída {code}). Detalhes: {log}",
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"step.lift": "Перевод кода игры в C",
|
||||
"step.compile": "Сборка {game_exe}",
|
||||
"step.prepare": "Подготовка шейдеров",
|
||||
"step.pc_prompts": "Рисование подсказок клавиатуры и мыши",
|
||||
"step.shapes": "Раскладка экранов игры под ваши мониторы",
|
||||
"step.dlss": "Загрузка NVIDIA DLSS",
|
||||
"step.cleanup": "Уборка",
|
||||
|
||||
@@ -29,10 +31,12 @@
|
||||
"phase.compile.compile": "Компиляция",
|
||||
"phase.compile.link": "Компоновка {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Запись патчей данных игры для 60 кадров/с",
|
||||
"phase.pc_prompts.draw": "Рисование подсказок клавиш и кнопок мыши по назначениям из totk.ini",
|
||||
"phase.prepare.seed": "Чтение шейдеров из данных игры",
|
||||
"phase.prepare.translate": "Трансляция шейдеров",
|
||||
"phase.prepare.libraries": "Сборка шейдеров для драйвера видеокарты",
|
||||
"phase.prepare.pack": "Упаковка кэша шейдеров в один файл",
|
||||
"phase.shapes.layouts": "Запись раскладок экрана и кнопок для каждой формы монитора",
|
||||
"phase.dlss.download": "Загрузка nvngx_dlss.dll из DLSS SDK от NVIDIA",
|
||||
"phase.cleanup.ini": "Запись totk.ini",
|
||||
"phase.cleanup.temp": "Удаление временных файлов",
|
||||
@@ -91,6 +95,7 @@
|
||||
"lift.failed": "Не удалось перевести код игры (код выхода {code}). Подробности: {log}",
|
||||
"compile.failed": "Не удалось собрать {game_exe} (код выхода {code}). Подробности: {log}",
|
||||
"compile.exe_in_use": "Файл {path} занят. Закройте игру и запустите установку снова.",
|
||||
"compile.exe_locked": "Файл {path} не удаётся записать: его держит другая программа — игра, запущенная из этой папки, или антивирус, который пометил файл. Закройте игру, добавьте папку установщика и папку установки в исключения антивируса, перезагрузите Windows и запустите установку снова. Подробности: {log}",
|
||||
"prepare.xlate_in_use": "Файл {path} занят. Закройте игру, завершите процесс totk_xlate, оставшийся от прошлого запуска, и запустите установку снова.",
|
||||
"prepare.shader_list_missing": "Нет списка шейдеров.",
|
||||
"prepare.romfs_patches_failed": "Не удалось записать патчи данных игры (код выхода {code}). Подробности: {log}",
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"step.lift": "将游戏代码转换为 C 代码",
|
||||
"step.compile": "编译 {game_exe}",
|
||||
"step.prepare": "准备着色器",
|
||||
"step.pc_prompts": "绘制键盘和鼠标按键提示",
|
||||
"step.shapes": "为你的显示器调整游戏画面布局",
|
||||
"step.dlss": "下载 NVIDIA DLSS",
|
||||
"step.cleanup": "清理",
|
||||
|
||||
@@ -29,10 +31,12 @@
|
||||
"phase.compile.compile": "编译",
|
||||
"phase.compile.link": "链接 {game_exe}",
|
||||
"phase.prepare.romfs_patches": "写入 60 帧游戏数据补丁",
|
||||
"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": "删除临时文件",
|
||||
@@ -91,6 +95,7 @@
|
||||
"lift.failed": "游戏代码转换失败(退出代码 {code})。详情:{log}",
|
||||
"compile.failed": "编译 {game_exe} 失败(退出代码 {code})。详情:{log}",
|
||||
"compile.exe_in_use": "{path} 正在使用中。请关闭游戏后重新运行安装程序。",
|
||||
"compile.exe_locked": "无法写入 {path}:另一个程序正在占用它,可能是从该文件夹启动的游戏,或标记了该文件的杀毒软件。请关闭游戏,将安装程序文件夹和安装文件夹加入杀毒软件的排除项,重启 Windows,然后重新运行安装程序。详情:{log}",
|
||||
"prepare.xlate_in_use": "{path} 正在被占用。请关闭游戏,结束上次残留的 totk_xlate 进程,再重新运行安装程序。",
|
||||
"prepare.shader_list_missing": "缺少着色器列表。",
|
||||
"prepare.romfs_patches_failed": "写入游戏数据补丁失败(退出代码 {code})。详情:{log}",
|
||||
|
||||
+225
-23
@@ -2,13 +2,15 @@
|
||||
"""Generate C for the ExeFS modules: function discovery, then parallel emission into chunked C files.
|
||||
|
||||
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]
|
||||
[--limit N] [--chunk-fns N] [--chunk-bytes B] [--big-fn B] [--patches FILE] [--v-locals K [--v-trust]]
|
||||
[--no-cache] [--fn-enter-all]
|
||||
|
||||
Output, under --out:
|
||||
layout.h, layout.json module bases (recomp/layout.py)
|
||||
<mod>/<mod>_NNNN.c one `void f_<addr>(Cpu *c)` per guest function, about --chunk-bytes of C per file
|
||||
<mod>/<mod>_table.c sorted <mod>_fn_addrs[] / <mod>_fn_ptrs[] / <mod>_fn_count for rt_dispatch
|
||||
<mod>/manifest.json chunk list, function count, statistics and timings
|
||||
<mod>/lift_cache.json per chunk: the key of its inputs, its file's SHA-256, size and mtime, and its results
|
||||
<mod>/folded.txt the module's bytes the generated code took as constants: what the jump tables read at
|
||||
lift time, as module offsets [start, end); tools/exefs_patches.py keeps a mod's data
|
||||
writes off them
|
||||
@@ -24,8 +26,20 @@ Emission runs in worker processes, one chunk per task. Each worker loads the mod
|
||||
time and resolves its jump tables (recomp/jumptables.py), so memory per worker does not grow with the module.
|
||||
Chunks are sized from a per-instruction estimate of the C they produce, so their names and contents only depend on
|
||||
the input; a chunk whose text did not change is not rewritten and keeps its mtime.
|
||||
|
||||
A chunk is not lifted again when its inputs did not change. Its text depends only on the generator (recomp/*.py,
|
||||
GENERATED_MARKER, the Emitter options), the module (its file, its base, and the function starts discovered from it),
|
||||
the chunk's number and functions, and the patch sites, spin waits and function hooks inside the chunk's address
|
||||
range (and whether the patch table has hooks at all): the per-module caches of recomp/jumptables.py are derived from
|
||||
the module's bytes and base, and its per-function state is reset for each function. The SHA-256 of all of these is the chunk's key. <mod>/lift_cache.json records the key of each chunk
|
||||
with the SHA-256, size and mtime of the file it wrote and the results the manifest and folded.txt need, under a
|
||||
digest of the entry. A chunk whose entry is intact, whose key matches and whose file still has that size, mtime and
|
||||
hash is reused as it is; any other chunk is lifted. So a rebuild after a change to one cheat lifts only the chunks
|
||||
holding its sites. --no-cache, or TOTK_LIFT_CACHE=0 in the environment, lifts every chunk.
|
||||
"""
|
||||
import argparse
|
||||
import bisect
|
||||
import hashlib
|
||||
import json
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
@@ -33,6 +47,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
from collections import Counter
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
@@ -46,6 +61,7 @@ import hostmem # noqa: E402
|
||||
import jumptables # noqa: E402
|
||||
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
|
||||
@@ -61,7 +77,7 @@ MUSTTAIL = '__attribute__((musttail)) return'
|
||||
EST_INT = 62
|
||||
EST_SIMD = 75
|
||||
EST_SIMD_LDST = 48
|
||||
EST_FN = 38 # per function: signature, FN_ENTER, closing brace
|
||||
EST_FN = 38 # per function: signature, FN_ENTER (recomp/patches.py `hook`), closing brace
|
||||
EST_BR_LABELS = 10 # per instruction of a function with a `br`: switch cases, or labels if it falls back
|
||||
|
||||
|
||||
@@ -209,15 +225,21 @@ def partition(est, max_fns, max_bytes, big_fn):
|
||||
# ------------------------------------------------------------------------------------------------ emission
|
||||
|
||||
class Emitter:
|
||||
"""C for the functions of one module. starts is the set of every function start of the module."""
|
||||
"""C for the functions of one module. starts is the set of every function start of the module. A new input of
|
||||
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):
|
||||
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):
|
||||
self.mod = mod
|
||||
self.starts = starts
|
||||
self.patched = patched or {} # {address: [(set index, [replacement words])]} (recomp/patches.py)
|
||||
self.spins = spins or {} # {spin wait back-edge: its head} (recomp/patches.py `spin`)
|
||||
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)
|
||||
self.v_trust = v_trust # with v_locals: V8-V15 are not reloaded after a call
|
||||
# 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.stats = Counter()
|
||||
self.unsupported = Counter()
|
||||
@@ -387,6 +409,7 @@ class Emitter:
|
||||
self.stats['external_branches'] += 1
|
||||
return f'{publish(i)}{spill}c->pc = {hx(t)}; {MUSTTAIL} rt_dispatch(c);'
|
||||
|
||||
enter = [f' FN_ENTER({hx(entry)});'] if self.hooks is None or entry in self.hooks else []
|
||||
if all_labels:
|
||||
# An unresolved computed br re-enters the function through fb_<entry>, which switches on c->pc to any
|
||||
# instruction. A goto to a shared dispatch block inside the body instead turns every instruction into
|
||||
@@ -395,13 +418,13 @@ class Emitter:
|
||||
cases = ' '.join(f'case {hx(t)}: goto L_{t:x};' for t in range(entry, end, 4))
|
||||
redispatch = f'{MUSTTAIL} {fb}(c);'
|
||||
out = [f'static void {fb}(Cpu *c);',
|
||||
f'void {fname(entry)}(Cpu *c) {{', f' FN_ENTER({hx(entry)});', f' c->pc = {hx(entry)};',
|
||||
f'void {fname(entry)}(Cpu *c) {{', *enter, f' c->pc = {hx(entry)};',
|
||||
f' {redispatch}', '}',
|
||||
f'static void {fb}(Cpu *c) {{', f' switch (c->pc) {{ {cases} default: break; }}',
|
||||
f' {MUSTTAIL} rt_dispatch(c);']
|
||||
else:
|
||||
redispatch = f'{MUSTTAIL} rt_dispatch(c);'
|
||||
out = [f'void {fname(entry)}(Cpu *c) {{', f' FN_ENTER({hx(entry)});']
|
||||
out = [f'void {fname(entry)}(Cpu *c) {{', *enter]
|
||||
if fp.used:
|
||||
out.append(' ' + fp.decl())
|
||||
|
||||
@@ -504,6 +527,8 @@ class Emitter:
|
||||
else:
|
||||
out += [line for _, line in body]
|
||||
out.append('}')
|
||||
if self.v_locals:
|
||||
out = vlocals.rewrite('\n'.join(out), self.v_locals, self.v_trust, self.stats).split('\n')
|
||||
self.stats['functions'] += 1
|
||||
self.stats['instructions'] += len(insns)
|
||||
return out, refs
|
||||
@@ -521,13 +546,15 @@ def chunk_text(name, number, emitter, fns):
|
||||
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'
|
||||
return (header(f'{name} chunk {number:04d}') + '#include "cpu.h"\n#include "simd.h"\n\n' + protos + '\n'
|
||||
+ '\n\n'.join(body) + '\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')
|
||||
|
||||
|
||||
def write_if_changed(path, text):
|
||||
def write_if_changed(path, text, wait=True):
|
||||
"""Returns True if the file was written. An unchanged file keeps its mtime, so the build skips it. A changed one
|
||||
is written under a temporary name and renamed into place, so a reader never sees it half written."""
|
||||
is written under a temporary name and renamed into place, so a reader never sees it half written. wait: retry
|
||||
the rename while another process holds the file (_retry); without it the first failure raises."""
|
||||
data = text.encode()
|
||||
try:
|
||||
if path.stat().st_size == len(data) and path.read_bytes() == data:
|
||||
@@ -537,7 +564,10 @@ def write_if_changed(path, text):
|
||||
tmp = path.with_name(f'.{path.name}.{os.getpid()}.tmp')
|
||||
tmp.write_bytes(data)
|
||||
try:
|
||||
_retry(os.replace, tmp, path)
|
||||
if wait:
|
||||
_retry(os.replace, tmp, path)
|
||||
else:
|
||||
os.replace(tmp, path)
|
||||
except OSError:
|
||||
tmp.unlink(missing_ok=True)
|
||||
raise
|
||||
@@ -587,7 +617,8 @@ def _emitter(name):
|
||||
mod.read = recorded
|
||||
e = _W['emitters'][name] = Emitter(mod, set(_W['starts'][name].tolist()),
|
||||
_W['patches'].for_module(name, base),
|
||||
spins=_W['patches'].spins_for(name, base), **_W['opts'])
|
||||
spins=_W['patches'].spins_for(name, base),
|
||||
hooks=_W['patches'].hooks_for(name, base), **_W['opts'])
|
||||
return e
|
||||
|
||||
|
||||
@@ -603,8 +634,8 @@ def merge_ranges(ranges):
|
||||
|
||||
|
||||
def _emit_chunk(task):
|
||||
"""Worker: write one chunk. Returns its statistics."""
|
||||
name, number, path, fns = task
|
||||
"""Worker: write one chunk. Returns its statistics, and the SHA-256, size and mtime of its file for the cache."""
|
||||
name, number, path, fns, key = task
|
||||
t0 = time.perf_counter()
|
||||
# Test hook: a pool wider than this raises the MemoryError a busy machine does, so the retry can be exercised.
|
||||
limit = os.environ.get('TOTK_LIFT_TEST_OOM_ABOVE')
|
||||
@@ -614,17 +645,20 @@ def _emit_chunk(task):
|
||||
e.stats.clear()
|
||||
e.unsupported.clear()
|
||||
text = chunk_text(name, number, e, fns)
|
||||
error = None
|
||||
error, st = None, None
|
||||
try:
|
||||
written = write_if_changed(Path(path), text)
|
||||
st = os.stat(path)
|
||||
except OSError as ex:
|
||||
written, error = False, f'{path}: {ex}'
|
||||
reads = _W['reads'].get(name, [])
|
||||
folded = merge_ranges(reads)
|
||||
reads.clear()
|
||||
return {'module': name, 'number': number, 'file': Path(path).name, 'functions': len(fns), 'bytes': len(text),
|
||||
'written': written, 'error': error, 'seconds': time.perf_counter() - t0, 'stats': dict(e.stats),
|
||||
'unsupported': dict(e.unsupported), 'folded': folded}
|
||||
'written': written, 'reused': False, 'error': error, 'seconds': time.perf_counter() - t0,
|
||||
'stats': dict(e.stats), 'unsupported': dict(e.unsupported), 'folded': folded, 'key': key,
|
||||
'sha256': _sha256(text.encode()), 'size': st.st_size if st else None,
|
||||
'mtime_ns': st.st_mtime_ns if st else None}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------ driver
|
||||
@@ -663,6 +697,122 @@ def remove_stale(moddir, name, nchunks, errors):
|
||||
return removed
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------ lift cache
|
||||
|
||||
CACHE_FILE = 'lift_cache.json'
|
||||
CACHE_VERSION = 1 # raise when the cache's format or the meaning of its key changes
|
||||
# Per-chunk results the cache keeps beside the key: what the manifest, folded.txt and the reuse check need.
|
||||
CACHED = ('functions', 'bytes', 'stats', 'unsupported', 'folded', 'sha256', 'size', 'mtime_ns')
|
||||
|
||||
|
||||
def _sha256(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def _key(*parts):
|
||||
"""SHA-256 of JSON-encodable parts."""
|
||||
return _sha256(json.dumps(parts, separators=(',', ':')).encode())
|
||||
|
||||
|
||||
def generator_key(opts):
|
||||
"""Key of everything the chunk text depends on besides the module and the patches: the generator's sources
|
||||
(recomp/*.py, not the patch tables beside them), the marker in each header, the Emitter options, the Python
|
||||
version that runs them."""
|
||||
srcs = [[p.name, _sha256(p.read_bytes())] for p in sorted((ROOT / 'recomp').glob('*.py'))]
|
||||
return _key('gen', CACHE_VERSION, list(sys.version_info[:2]), GENERATED_MARKER, sorted(opts.items()), srcs)
|
||||
|
||||
|
||||
def module_key(gen_key, name, path, base, abs_starts):
|
||||
"""Key of one module's inputs: the generator, the module's file and base, and the function starts discovered
|
||||
from them (they decide which branches become direct calls)."""
|
||||
return _key(gen_key, name, _sha256(Path(path).read_bytes()), base, _sha256(abs_starts.tobytes()))
|
||||
|
||||
|
||||
def in_span(addrs, lo, hi):
|
||||
"""The addresses of the sorted list addrs in [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):
|
||||
"""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."""
|
||||
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)]
|
||||
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)
|
||||
|
||||
|
||||
def _entry_check(file, entry):
|
||||
"""Digest of a cache entry: its chunk file name, key and results. The results go into the manifest and folded.txt
|
||||
as they are, so a changed value in the cache file must not be taken (tools/exefs_patches.py --folded keeps a
|
||||
mod's data writes off the folded bytes)."""
|
||||
return _key(file, entry['key'], [entry[k] for k in CACHED])
|
||||
|
||||
|
||||
def load_cache(moddir):
|
||||
"""{chunk file name: entry} from <mod>/lift_cache.json: the entries whose digest matches; empty when the file is
|
||||
missing or unreadable."""
|
||||
try:
|
||||
data = json.loads((moddir / CACHE_FILE).read_text())
|
||||
if data.get('version') != CACHE_VERSION or not isinstance(data.get('chunks'), dict):
|
||||
return {}
|
||||
out = {}
|
||||
for file, e in data['chunks'].items():
|
||||
try:
|
||||
if e['check'] == _entry_check(file, e):
|
||||
out[file] = e
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
return out
|
||||
except (OSError, ValueError, AttributeError):
|
||||
return {}
|
||||
|
||||
|
||||
def _intact(path, entry):
|
||||
"""True when the file at path still is the one the entry recorded: same size and mtime, then same SHA-256 (a bit
|
||||
flipped in a kept file would otherwise stay forever, as tools/build_game.py check_objects says of objects)."""
|
||||
try:
|
||||
st = path.stat()
|
||||
if st.st_size != entry['size'] or st.st_mtime_ns != entry['mtime_ns']:
|
||||
return False
|
||||
return _sha256(path.read_bytes()) == entry['sha256']
|
||||
except (OSError, KeyError, TypeError):
|
||||
return False
|
||||
|
||||
|
||||
def reuse(tasks, caches):
|
||||
"""The results of the tasks whose chunk can be reused: its recorded key equals the task's and its file is intact.
|
||||
The files are hashed on threads (hashlib releases the GIL), about 1 GB in all for the three modules."""
|
||||
cands = []
|
||||
for name, number, path, fns, key in tasks:
|
||||
e = caches.get(name, {}).get(Path(path).name)
|
||||
if e is not None and e['key'] == key:
|
||||
cands.append((name, number, Path(path), key, e))
|
||||
with ThreadPoolExecutor(min(16, os.cpu_count() or 4)) as ex:
|
||||
ok = list(ex.map(lambda c: _intact(c[2], c[4]), cands))
|
||||
out = []
|
||||
for (name, number, path, key, e), good in zip(cands, ok):
|
||||
if good:
|
||||
out.append({'module': name, 'number': number, 'file': path.name, 'written': False, 'reused': True,
|
||||
'error': None, 'seconds': 0.0, 'key': key, **{k: e[k] for k in CACHED}})
|
||||
return out
|
||||
|
||||
|
||||
def cache_text(name, results):
|
||||
"""<mod>/lift_cache.json for this run's chunks; a chunk that could not be written gets no entry. Keys keep their
|
||||
order (no sort_keys), so a reused chunk's `unsupported` merges into the census as it did when it was lifted."""
|
||||
chunks = {}
|
||||
for r in results:
|
||||
if not r['error'] and r['size'] is not None:
|
||||
e = {'key': r['key'], **{k: r[k] for k in CACHED}}
|
||||
chunks[r['file']] = {**e, 'check': _entry_check(r['file'], e)}
|
||||
return json.dumps({'module': name, 'marker': GENERATED_MARKER, 'version': CACHE_VERSION, 'chunks': chunks},
|
||||
separators=(',', ':')) + '\n'
|
||||
|
||||
|
||||
# Peak memory of one emit worker on 1.4.3 is 1.3 GiB (1.5 GiB with margin); the parent holds about 0.7 GiB.
|
||||
WORKER_MEM = 1536 << 20
|
||||
MEM_SHARE = 0.8 # of the free memory the workers may take, the rest is for the system and other programs
|
||||
@@ -705,8 +855,25 @@ def main():
|
||||
ap.add_argument('--no-callee-saved-trust', action='store_true',
|
||||
help='reload X19-X29 and SP after every call too, instead of trusting AAPCS64 (slower; for '
|
||||
'telling a broken callee from a generator bug)')
|
||||
ap.add_argument('--v-locals', type=int, default=vlocals.LOCALS,
|
||||
help='V registers per function kept in C locals that clang holds in XMM registers, the most used '
|
||||
f'ones (recomp/vlocals.py; default {vlocals.LOCALS}, 0: all in the Cpu)')
|
||||
ap.add_argument('--v-trust', action='store_true',
|
||||
help='with --v-locals: do not reload V8-V15 after a call (AAPCS64: the callee preserves their low '
|
||||
'64 bits)')
|
||||
ap.add_argument('--fn-enter-all', action='store_true',
|
||||
help='FN_ENTER (runtime/cpu.h) in every function, also with hook lines in the patch table '
|
||||
'(recomp/patches.py `hook`): a whole-game function-entry profile')
|
||||
ap.add_argument('--no-cache', action='store_true',
|
||||
help=f'lift every chunk, also those whose inputs match <mod>/{CACHE_FILE} (it is written anew); '
|
||||
'so does the environment variable TOTK_LIFT_CACHE=0')
|
||||
args = ap.parse_args()
|
||||
opts = {'reg_locals': args.reg_locals, 'callee_saved': not args.no_callee_saved_trust}
|
||||
# The installer's lift step passes no --no-cache; the environment reaches it, as TOTK_LIFT_JOBS does (pick_jobs)
|
||||
no_cache = ('--no-cache' if args.no_cache else
|
||||
'TOTK_LIFT_CACHE=0' if os.environ.get('TOTK_LIFT_CACHE', '').strip() == '0' else None)
|
||||
opts = {'reg_locals': args.reg_locals, 'callee_saved': not args.no_callee_saved_trust, 'v_locals': args.v_locals,
|
||||
'v_trust': args.v_trust, 'fn_enter_all': args.fn_enter_all}
|
||||
gen_key = generator_key(opts)
|
||||
|
||||
t0 = time.perf_counter()
|
||||
mods = layout(args.exefs)
|
||||
@@ -734,9 +901,19 @@ 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)
|
||||
mkey = module_key(gen_key, name, path, base, abs_starts)
|
||||
patched, spins = table.for_module(name, base), table.spins_for(name, base)
|
||||
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()))
|
||||
if stray:
|
||||
raise SystemExit(f'{args.patches}: hook {", ".join(f"{name}+{a - base:#x}" for a in stray)} is no function '
|
||||
f'start of {name}')
|
||||
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()))
|
||||
tasks.append((int(est[i0:i1].sum()), (name, number, str(moddir / f'{name}_{number:04d}.c'), fns)))
|
||||
key = chunk_key(mkey, number, fns, patched, site_addrs, spins, spin_addrs, hook_addrs)
|
||||
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(),
|
||||
@@ -755,9 +932,23 @@ def main():
|
||||
ctx = mp.get_context('spawn')
|
||||
jobs, why = pick_jobs(args.jobs)
|
||||
pending = [t for _, t in tasks]
|
||||
emitted = 0
|
||||
while True:
|
||||
print(f'emitting with {jobs} workers ({why})', file=sys.stderr, flush=True)
|
||||
reused = [] if no_cache else reuse(pending, {name: load_cache(d['moddir']) for name, d in info.items()})
|
||||
for r in reused:
|
||||
results[r['module']].append(r)
|
||||
folded[r['module']] += r['folded']
|
||||
skip = {(r['module'], r['number']) for r in reused}
|
||||
pending = [t for t in pending if (t[0], t[1]) not in skip]
|
||||
emitted = len(reused)
|
||||
print(f'reusing {len(reused)} of {len(tasks)} chunks (inputs unchanged), {time.perf_counter() - t_emit:.1f}s'
|
||||
if not no_cache else f'lifting every chunk ({no_cache})', file=sys.stderr, flush=True)
|
||||
if reused or not pending:
|
||||
# installer/steps.py EMITTED reads these lines for its progress bar: the reused chunks count as done, and a
|
||||
# run with nothing to lift still reaches M/M
|
||||
print(f'emitted {emitted}/{len(tasks)} chunks, 0s', file=sys.stderr, flush=True)
|
||||
if len(pending) < jobs:
|
||||
jobs, why = max(1, len(pending)), f'{len(pending)} chunk{"s" if len(pending) != 1 else ""} to lift'
|
||||
while pending:
|
||||
print(f'emitting with {jobs} worker{"s" if jobs != 1 else ""} ({why})', file=sys.stderr, flush=True)
|
||||
try:
|
||||
# Chunk writes are atomic and idempotent, so a chunk lost with a failed pool is simply emitted again.
|
||||
# Its folded bytes come with its result: a chunk emitted again reads them again in its new worker.
|
||||
@@ -827,7 +1018,9 @@ def main():
|
||||
'c_bytes': sum(r['bytes'] for r in rs),
|
||||
'largest_chunk_bytes': max((r['bytes'] for r in rs), default=0),
|
||||
'chunks_written': sum(r['written'] for r in rs) + table_written,
|
||||
'chunks_reused': sum(r['reused'] for r in rs),
|
||||
'stale_chunks_removed': removed,
|
||||
**{k: v for k, v in sorted(stats.items()) if k.startswith('v_')}, # --v-locals only
|
||||
},
|
||||
'unsupported_census': dict(unsupported.most_common(50)),
|
||||
'timings': {
|
||||
@@ -838,8 +1031,17 @@ def main():
|
||||
},
|
||||
}
|
||||
write_if_changed(moddir / 'manifest.json', json.dumps(manifest, indent=1) + '\n')
|
||||
# The cache goes last, after every output it describes. It only saves time, so a failed write warns and the
|
||||
# lift still succeeds, without waiting for a holder of the file: the previous cache stays, and its entries
|
||||
# for the chunks this run rewrote no longer match their files' size, mtime and hash. A run stopped before
|
||||
# here leaves it the same way.
|
||||
try:
|
||||
write_if_changed(moddir / CACHE_FILE, cache_text(name, rs), wait=False)
|
||||
except OSError as ex:
|
||||
print(f'{name}: {CACHE_FILE} not written, the next lift reuses less: {ex}', file=sys.stderr, flush=True)
|
||||
s = manifest['stats']
|
||||
print(f'{name}: {s["emitted_functions"]} functions, {len(rs)} chunks, {s["c_bytes"] / 1e6:.0f} MB of C, '
|
||||
print(f'{name}: {s["emitted_functions"]} functions, {len(rs)} chunks ({s["chunks_reused"]} reused), '
|
||||
f'{s["c_bytes"] / 1e6:.0f} MB of C, '
|
||||
f'{s["jump_tables"]} jump tables, {s["all_label_fallbacks"]} all-label fallbacks, '
|
||||
f'{s["br_dispatch"]} br via dispatch, {s["traps"]} traps ({s["unsupported"]} unsupported)',
|
||||
file=sys.stderr)
|
||||
|
||||
+2
-1
@@ -352,7 +352,8 @@ class Lifter:
|
||||
dst = {
|
||||
(3, 3, 13, 0, 2): 'c->tpidr = {v};',
|
||||
(3, 3, 4, 2, 0): 'c->nzcv = {v} & 0xf0000000ull;',
|
||||
(3, 3, 4, 4, 0): 'c->fpcr = {v} & 0x7c00000ull; rt_fpcr_sync(c);' if self.sc else 'rt_set_fpcr({v});',
|
||||
(3, 3, 4, 4, 0): ('c->fpcr = {v} & 0x7c00000ull; rt_fpcr_sync(c); RT_FPCR_NOTE(c, c->x[30]);' if self.sc
|
||||
else 'rt_set_fpcr({v});'),
|
||||
(3, 3, 4, 4, 1): 'c->fpsr = {v} & 0xf800009full;' if self.sc else 'rt_set_fpsr({v});',
|
||||
}.get(key)
|
||||
if dst is None:
|
||||
|
||||
@@ -10,6 +10,10 @@ set cloth TOTK_CLOTH_REALTIME 1
|
||||
set bounce TOTK_HIGHFPS_FIX 1
|
||||
set output TOTK_PATCH_OUTPUT 0
|
||||
set scene TOTK_PATCH_SCENE 0
|
||||
set shadow TOTK_PATCH_SHADOW 0
|
||||
set cascade TOTK_PATCH_CASCADE 0
|
||||
# Load-dependent quality (patches-v121.txt explains it): no sites found in this version yet, so the setting does nothing.
|
||||
set steady TOTK_LOD_STEADY 0
|
||||
|
||||
# 60 fps: the adaptive present-interval controller (main+0x8f26c8, 1.0.0 0x8f6bec) gets the minimum interval 1.
|
||||
site fps60 main 90e978 6b08015f 7100055f # clamp: cmp w10, #1 (was cmp w10, w8 = minimum)
|
||||
@@ -66,6 +70,50 @@ site scene main cea5e0 5e21d900 @page:x9 # scvtf s0, s8 -> adrp x9, page
|
||||
site scene main cea5e8 bd0cc660 2d420520 # str s0, [x19, #0xcc4] -> ldp s0, s1, [x9, #16]
|
||||
site scene main cea5ec 5e21d921 bd0cc660 # scvtf s1, s9 -> str s0, [x19, #0xcc4]
|
||||
|
||||
# Equipment-switch cooldown (issue #18): the player update tests state +0x109c against FLT_EPSILON,
|
||||
# while the equipment gate (main+0x7f0134) blocks changes above zero. Step every positive remainder through
|
||||
# main+0xa26bb0, including (0, FLT_EPSILON], so a measured frame ratio cannot leave equipment locked.
|
||||
site realtime main a20518 1e270101 1e2703e1 # fmov s1, w8 (FLT_EPSILON) -> fmov s1, wzr
|
||||
|
||||
# Cursor and aim steps (MacNativeGames game_patches.c patch_cursor_speed, 363a6eb): use the same 30 Hz ratio
|
||||
# already read by these updates for smoothing. x9 / s16 are scratch at the map site; x20 holds the aim clock.
|
||||
set cursor TOTK_HIGHFPS_FIX 1
|
||||
site cursor main f31e80 bd400361 f94002e9 bd400930 1e300800 bd400361 # map pan s0 *= [[x23] + 8]
|
||||
site cursor main 1d55f24 1e2a198c 1e2a198c bd400a90 1e30098c # vertical ability aim s12 *= [x20 + 8]
|
||||
site cursor main 1d556a4 1e200923 1e200923 bd400a90 1e300863 # vertical gyro aim s3 *= [x20 + 8]
|
||||
|
||||
# Camera aspect (Hor+): two camera projection updates and the two copies of the viewport projection routine.
|
||||
# The camera sites were matched against 1.0.0 by instruction windows; both viewport copies match the same
|
||||
# 193-word normalized window. Page +56 is set by runtime/resolution.c. Save x10 instead of assuming it dead.
|
||||
set aspect TOTK_ASPECT_PATCH 0
|
||||
site aspect main cdbf30 bd414260 f81f0fea @page:x10 bd403940 f84107ea
|
||||
site aspect main 1261a64 bd414260 f81f0fea @page:x10 bd403940 f84107ea
|
||||
site aspect main 19c2260 1e211800 f81f0fea @page:x10 bd403940 f84107ea
|
||||
site aspect main 1ed8fa4 1e211800 f81f0fea @page:x10 bd403940 f84107ea
|
||||
|
||||
# Field of view: load the camera's vertical angle as before and multiply by page +60. The following projection
|
||||
# setup overwrites s8 before reading it; s1 (the half-angle multiplier) stays intact. x10 is saved on the stack.
|
||||
set fov TOTK_FOV_PATCH 0
|
||||
site fov main cdbef8 bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea
|
||||
site fov main 1261a2c bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea
|
||||
|
||||
# Texture pool offsets above 2 GiB (MacNativeGames game_patches.c patch_pool_offset, ca311e2d): the loader
|
||||
# passes w25 to SetStorage and SetPackagedTextureData. Widen unsigned to cover the complete 32-bit pool offset.
|
||||
set pooloff TOTK_POOL_OFFSET_PATCH 1
|
||||
site pooloff main 9b93a8 93407f22 2a1903e2
|
||||
site pooloff main 9b93c4 8b39c101 8b394101
|
||||
|
||||
# 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
|
||||
|
||||
# Sun shadow cascade parameter defaults: depth_shadow_near_0_1..3 and depth_shadow_far_0. The constructor
|
||||
# stores 20, 40, 80 and 160 metres; runtime/resolution.c res_shadow_range supplies page +64..+76.
|
||||
site cascade main 1157fb8 52a83408 @page:x8 b9404108
|
||||
site cascade main 1158040 52a84408 @page:x8 b9404508
|
||||
site cascade main 11580c8 52a85408 @page:x8 b9404908
|
||||
site cascade main 115814c 52a86408 @page:x8 b9404d08
|
||||
|
||||
# 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.
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ set bounce TOTK_HIGHFPS_FIX 1
|
||||
set output TOTK_PATCH_OUTPUT 0
|
||||
set scene TOTK_PATCH_SCENE 0
|
||||
set shadow TOTK_PATCH_SHADOW 0
|
||||
set grass TOTK_PATCH_GRASS 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)
|
||||
@@ -142,6 +143,17 @@ set pooloff TOTK_POOL_OFFSET_PATCH 1
|
||||
site pooloff main ad43f0 93407f22 2a1903e2 # sxtw x2, w25 -> mov w2, w25 (SetStorage offset)
|
||||
site pooloff main ad440c 8b39c101 8b394101 # add x1, x8, w25, sxtw -> add x1, x8, w25, uxtw (packaged data source)
|
||||
|
||||
# Load-dependent quality, after the emulator mod "Disable LOD Quality Reduction" (main-1.2.1.pchtxt), which turns a
|
||||
# conditional branch into an unconditional one; the generator patches only plain instructions (recomp/gen.py, the
|
||||
# emitter's patch), so the site feeds the branch instead. The graphics settings setup (main+0xc7e9xx, it also reads the
|
||||
# FSR and FXAA switches) walks a
|
||||
# list at its +0x120 and passes three floats of each entry to virtual setters, which the mod describes as the drop of
|
||||
# model and texture detail when the frame rate falls; it skips all of it, to the epilogue, when the value it reads at
|
||||
# main+0xc7eb24 is above 8. Reading 9 there skips it as the mod does; w21 is not read again on that path (the epilogue
|
||||
# restores it).
|
||||
set steady TOTK_LOD_STEADY 0
|
||||
site steady main c7eb24 b9400815 52800135 # ldr w21, [x0, #8] -> mov w21, #9 (b.gt 0xc7ee4c taken)
|
||||
|
||||
# Direct mouse camera (runtime/mouse_direct.c; the same hooks as patches-v143.txt, mapped by enclosing function to the
|
||||
# 1.2.1 main, each original word checked). The camera input update (main+0xd18088, 1.4.3 0x874c1c) after its dead zone,
|
||||
# clamp and StickExponent keeps x in s11 (1.4.3 s9); the host callback performs the displaced store and adds raw mouse
|
||||
@@ -1115,3 +1127,27 @@ spin sdk 3d3250 3d3270 # 9 instructions; loads
|
||||
# goes in just before the rounding, as the community's shadow resolution mods do (1.1.0: mov w11, #1024 over the
|
||||
# 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
|
||||
|
||||
# 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.
|
||||
site grass main fe58b4 52a84f48 @page:x8 b9408108 # mov w8, #62.5 -> ldr w8, [page+128]
|
||||
site grass main fe58c0 52a80f48 @page:x8 b9408508 # mov w8, #3.90625 -> ldr w8, [page+132]
|
||||
site grass main fe58ec 52802002 @page:x2 b9408842 # mov w2, #0x100 -> ldr w2, [page+136]
|
||||
site grass main fe5950 52801002 @page:x2 b9408c42 # mov w2, #0x80 -> ldr w2, [page+140]
|
||||
site grass main 1a30a8c 52a84f48 @page:x8 b9408108 # mov w8, #62.5 -> ldr w8, [page+128]
|
||||
site grass main 1a30a98 52a83f48 @page:x8 b9409108 # mov w8, #31.25 -> ldr w8, [page+144]
|
||||
|
||||
|
||||
# Optional reference with an invalid value (#1005). The same guard as set optref in patches-v143.txt (main+0x1bd01c0),
|
||||
# here for 1.2.1's main+0x1622bec: ldr x8, [x19, #0x6b0]; cbz x8; ldr x21, [x8]. A negative value counts as absent.
|
||||
# x8 and x9 are dead at the branch target 0x1622c1c, which loads x8 again.
|
||||
set optref TOTK_OPTREF_GUARD 1
|
||||
site optref main 1622bec b4000188 937ffd09 8a290108 b4000188 # cbz x8 -> asr x9, x8, #63; bic x8, x8, x9; cbz x8
|
||||
|
||||
# Recall and Ultrahand target that is stale memory: set ability in patches-v143.txt, here for 1.2.1's main+0x1622bf0
|
||||
# (function main+0x1622b60; the callees main+0x809ecc, 0x842aa4 and 0x842d10 read the same actor offsets). The model
|
||||
# scene report-row guard (set report there) has no 1.2.1 site: this version does not have that loop's code shape.
|
||||
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)
|
||||
@@ -12,6 +12,14 @@ set output TOTK_PATCH_OUTPUT 0
|
||||
set scene TOTK_PATCH_SCENE 0
|
||||
set shadow TOTK_PATCH_SHADOW 0
|
||||
set cascade TOTK_PATCH_CASCADE 0
|
||||
set grass TOTK_PATCH_GRASS 0
|
||||
# Load-dependent quality (patches-v121.txt, set steady). The graphics settings setup (main+0x5868c4) inlines the
|
||||
# three getters 1.2.1 calls: the value 1.2.1 reads at
|
||||
# main+0xc7eb24 is the ldr w10, [x10, #0x38] at main+0x58692c, and the getters' slow paths (main+0x586bc8, 0x586c18,
|
||||
# 0x586f44) come back before the compare. So the site is the compare, which every path reaches: w10 = 9 skips the
|
||||
# list walk to the epilogue (main+0x58729c), which does not read w10.
|
||||
set steady TOTK_LOD_STEADY 0
|
||||
site steady main 586954 7100215f 5280012a 7100215f # cmp w10, #8 -> mov w10, #9; cmp w10, #8 (b.gt 0x58729c taken)
|
||||
|
||||
# 60 fps: the adaptive present-interval controller (main+0x2db174, 1.2.1 0x8f26c8) gets the minimum interval 1.
|
||||
site fps60 main 2db204 6b08015f 7100055f # clamp: cmp w10, #1 (was cmp w10, w8 = minimum)
|
||||
@@ -41,6 +49,16 @@ site realtime main 2daa78 1e210800 d503201f # fmul s0, s0, s1 -> nop
|
||||
# keeps equipment locked until a load. Stepping while above 0 takes the remainder below 0 like any other last step.
|
||||
site realtime main 2b036c 0f016681 0f000401 # movi v1.2s, #0x34, lsl #24 (FLT_EPSILON) -> movi v1.2s, #0
|
||||
|
||||
# Attack hit processing (main+0x2906a24) builds a list of this frame's hit records on its stack (count at [sp], slots
|
||||
# at [sp+8] -> an inline array that is never cleared). The record insert (main+0x86e1d8) returns null when the
|
||||
# attacker's record map (+0x190) is full, so a full map leaves the list empty. After its two loops the function
|
||||
# passes slot 0 to the hit handler (main+0x870158, which dereferences it) unconditionally at main+0x2906de0 and only
|
||||
# then checks count == 0 at main+0x2906df0; with an empty list slot 0 is stale stack data and the handler faults.
|
||||
# Charged spear hits above 60 fps fill the map. Both count == 0 branches go to the check instead, which reloads the
|
||||
# count and leaves through main+0x2906ce8; x19 and x20 are the only registers read there. A non-empty list is unchanged.
|
||||
site realtime main 2906d98 34000248 340002c8 # cbz w8, 0x2906de0 -> 0x2906df0 (first loop's empty check)
|
||||
site realtime main 2906dc0 34000108 34000188 # cbz w8, 0x2906de0 -> 0x2906df0 (second loop's empty check)
|
||||
|
||||
# Hair and cloth: the actor animation update builds a second clock {seconds = factor / 30, ratio = factor} per
|
||||
# rendered frame. 1.4.3 inlines it in two actor paths, where the factor was just stored to the ratio slot: the
|
||||
# replacement stores measured ratio * factor there and computes measured seconds * factor. Two other callers share the
|
||||
@@ -1102,3 +1120,60 @@ site cascade main 6fad4c 52a86408 @page:x8 b9404d08 # mov w8, #160.0 -> ldr w8
|
||||
# switches the set off without the real-time step, where the page is not written.
|
||||
set climb TOTK_CLIMB_FIX 1
|
||||
site climb main 1f497f4 1e201001 @page:x8 bd400104 1e286884 52946dc8 72a7e528 1e270102 1e241842 52828248 72a7dfe8 1e270103 1e232842 529573e8 72a7b5a8 1e270103 1f040862 1e2a3883 2f00e404 1e246863 1e261004 1f048862 1e241004 1e247842 1e226800 1e201001 1e226821 # fmov s1, #2.0 -> s2 = g(u); s0 = max(s0, s2); s1 = max(2.0, s2)
|
||||
|
||||
|
||||
# Grass range (runtime/resolution.c res_grass_range switches the set on). Grass blades grow from the near grass map, a
|
||||
# square texture the game draws around the camera (GrassShader.sharcb). Its constructor (main+0xa38e58) gives it a
|
||||
# 62.5 m extent, a 3.90625 m step (1/16 of it) and 256x256 and 128x128 textures; main+0x206340c later sets the extent
|
||||
# to 62.5 or 31.25 m. With the set on all of them come from page +128..+144, scaled together so the map keeps its
|
||||
# texels per metre; resolution.c grows the grass heap of the HeapDef for the larger textures.
|
||||
site grass main a38e58 52a84f48 @page:x8 b9408108 # mov w8, #62.5 -> ldr w8, [page+128]
|
||||
site grass main a38e64 52a80f48 @page:x8 b9408508 # mov w8, #3.90625 -> ldr w8, [page+132]
|
||||
site grass main a38e94 52802002 @page:x2 b9408842 # mov w2, #0x100 -> ldr w2, [page+136]
|
||||
site grass main a38ef4 52801002 @page:x2 b9408c42 # mov w2, #0x80 -> ldr w2, [page+140]
|
||||
site grass main 2063454 52a84f48 @page:x8 b9408108 # mov w8, #62.5 -> ldr w8, [page+128]
|
||||
site grass main 2063460 52a83f48 @page:x8 b9409108 # mov w8, #31.25 -> ldr w8, [page+144]
|
||||
|
||||
|
||||
# Optional reference with an invalid value (#1005). main+0x1bd0138 reads an optional reference at object +0x6b0 (null or
|
||||
# a holder whose first word is the target, bit 0 a tag) and checks it only for null: ldr x8, [x19, #0x6b0]; cbz x8;
|
||||
# ldr x21, [x8]. Players' crash reports show the field holding 0xffffffffffffffff after minutes to hours of play, and
|
||||
# the load of the holder faults. MacNativeGames (games/totk/runtime/loader.c, crash) met the same field holding
|
||||
# 0xffff0000ffffffff during a save load and treats the reference as absent there. Every valid holder is a heap address
|
||||
# below 2^63, so the cbz becomes a test for null or negative: x9 = x8 >> 63 (arithmetic, all ones when negative),
|
||||
# x8 &= ~x9, cbz x8. Both x8 and x9 are dead at the branch target 0x1bd01f0, which loads x8 again and writes x9 before
|
||||
# any read; on the fall-through path x8 is unchanged.
|
||||
set optref TOTK_OPTREF_GUARD 1
|
||||
site optref main 1bd01c0 b4000188 937ffd09 8a290108 b4000188 # cbz x8 -> asr x9, x8, #63; bic x8, x8, x9; cbz x8
|
||||
|
||||
# Recall and Ultrahand target that is stale memory. The same function reads the target actor from the holder
|
||||
# (ldr x21, [x8]) and follows it into main+0x155ec, main+0x9a89d4 and main+0x2b8464 (an atomic write at +0x90). The
|
||||
# holder can be reused memory by then, so the actor points into .rodata, outside the address space or at other heap
|
||||
# data, and the game crashes reading 0xffffffffffffffff. UltraTears (kuraeow/ultratears, ability target guard) found
|
||||
# the class. The load becomes a call to runtime/ov_ability.c host_ability_target (page+0xf60): x21 is the holder's
|
||||
# first word, or 0 where the game's own code would fault on the target (holder, actor or component unreadable, the
|
||||
# reference word not writable), which the game's cbz x21 skips for this frame. Every other target goes on unchanged.
|
||||
# The answer comes back in x9 and the cbz site moves it to x21: the lifted code keeps x21 (callee-saved) in a C local
|
||||
# across the call. x9 is dead after 0x1bd01c8 on every path (written or clobbered by a bl before any read); x30 is saved by the
|
||||
# prologue and clobbered by the next bl anyway.
|
||||
set ability TOTK_ABILITY_GUARD 1
|
||||
site ability main 1bd01c4 f9400115 947c3f67 # ldr x21, [x8] -> bl page+0xf60
|
||||
site ability main 1bd01c8 b4000155 aa0903f5 b4000155 # cbz x21 -> mov x21, x9; cbz x21
|
||||
|
||||
# Model scene report rows (WoE, daniel-madrid-07/weeping-of-the-empire, MIT, games/totk/patches/sites_v143.py
|
||||
# reportguard; their #52 and #73: crashes while using Ultrahand and aiming). gsys::ModelScene::calcGPU_ is inlined in
|
||||
# main+0xa1f84; its per-object loop (0xa22bc..0xa234c) takes the object's report handle h (int16 at obj+0x98 + 2 * side),
|
||||
# exits for -1 only, reads row 2h+1 and then u32 n from row 2h, and follows n to row 2n with no bound (WoE's crash had
|
||||
# n = the float 0.05, a read 32 GB past the rows). n indexes a row pair as h does, so a valid one is below 0x8000.
|
||||
# A negative h (other than -1) or n >= 0x8000 goes to 0xa2340, where the game resets the handle to -1 after every use:
|
||||
# the object has coverage 0 this frame (stored at 0xa22cc) and the game asks for a new report, as after a normal read.
|
||||
# WoE's veneers exit at 0xa2344 instead, which keeps the bad handle for the next frames. No flags change; w4 is never
|
||||
# used in main+0xa1f84; x1, x16, x15 and w13, which 0xa2340 reads, hold what they hold on the game's own path there.
|
||||
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
|
||||
|
||||
# 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
|
||||
+25
-5
@@ -1,13 +1,15 @@
|
||||
"""Code patch table for the generator: guest instructions replaced in the lifted C, switchable at run time.
|
||||
|
||||
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 two kinds of lines; `#` starts a comment, fields are separated by whitespace:
|
||||
(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
|
||||
site <set> <module> <address> <original> <replacement> [<replacement> ...]
|
||||
|
||||
spin <module> <head> <back-edge> [<back-edge> ...]
|
||||
|
||||
hook <module> <function> [<function> ...]
|
||||
|
||||
<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
|
||||
@@ -29,6 +31,11 @@ A `spin` line names a spin wait found by tools/spin_waits.py: a loop with head <
|
||||
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).
|
||||
|
||||
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
|
||||
without any keeps it in every function, as does gen.py --fn-enter-all (a whole-game function-entry profile).
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
@@ -49,13 +56,22 @@ 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."""
|
||||
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."""
|
||||
|
||||
def __init__(self, sets=(), sites=None, page=0, spins=None):
|
||||
def __init__(self, sets=(), sites=None, page=0, spins=None, hooks=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
|
||||
|
||||
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
|
||||
(FN_ENTER in every function)."""
|
||||
if not self.hooks:
|
||||
return None
|
||||
return {base + o for o in self.hooks.get(name, ())}
|
||||
|
||||
def spins_for(self, name, base):
|
||||
"""{absolute back-edge address: absolute head address}."""
|
||||
@@ -73,7 +89,7 @@ class Table:
|
||||
|
||||
def load(path, mods):
|
||||
"""Table from a patch file; mods is layout() output [(name, base, size)]."""
|
||||
sets, index, sites, spins = [], {}, {}, {}
|
||||
sets, index, sites, spins, hooks = [], {}, {}, {}, {}
|
||||
bases = {n: (b, s) for n, b, s in mods}
|
||||
for no, raw in enumerate(Path(path).read_text().splitlines(), 1):
|
||||
f = raw.split('#', 1)[0].split()
|
||||
@@ -112,6 +128,10 @@ 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] == 'hook' and len(f) >= 3:
|
||||
if f[1] not in bases:
|
||||
raise PatchError(f'{where}: module {f[1]} not in the layout')
|
||||
hooks.setdefault(f[1], set()).update(int(o, 16) for o in f[2:])
|
||||
else:
|
||||
raise PatchError(f'{where}: cannot parse {raw!r}')
|
||||
base, size = bases['main'][0], bases['main'][1]
|
||||
@@ -119,7 +139,7 @@ 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)
|
||||
return Table(sets, sites, page, spins, hooks)
|
||||
|
||||
|
||||
def check(table, mod, name):
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
"""V registers in C locals (gen.py --v-locals K): a rewrite of one emitted function's C.
|
||||
|
||||
The lifter writes V registers as `c->v[n]`, lane forms `((T *)&c->v[n])[i]`, the register macros of runtime/simd.h
|
||||
(VREG, VQ, VW, VS32, ...) and helper calls that name registers by number (fp_op_s(c, op, d, n, m), ...). A chunk
|
||||
generated with K > 0 defines RT_VLOCALS, under which those macros and helpers reach a register through a local array
|
||||
`u128 vr[32]` when its bit in the function's VMASK is set, else through c->v; every access is a whole-vector load or
|
||||
store, so clang's SROA keeps each local register in an XMM register. This module
|
||||
|
||||
- turns the direct forms into the accessors (c->v[n] = e -> VSET, c->v[n] -> VGET, lane forms -> VLANE/VLSET),
|
||||
- picks the K registers the function names most often (VMASK),
|
||||
- loads them at entry; before every call, rt_dispatch, rt_svc/rt_udf/rt_brk, rt_spin_gate and exit stores the ones
|
||||
the function writes (VSYNC_OUT_D: only if the dirty mask may have the bit; the mask folds to a constant on most
|
||||
paths); after a call reloads them, except V8-V15 with trust (AAPCS64: a callee preserves their low 64 bits, and a
|
||||
conforming caller does not read their upper halves after the call).
|
||||
|
||||
Why the cap: 32 guest registers on 16 XMM registers spill (all 32 cost +20% instructions, the stack traffic tripled),
|
||||
while K = 6..8 removed a quarter of the c->v traffic and kept dependent FP chains in registers; build/v143-vloc
|
||||
NOTES.md has the measurements.
|
||||
"""
|
||||
import re
|
||||
from collections import Counter
|
||||
|
||||
# Default K: 8 cut guest time 3.9-6.2% in the town on a 7900X against K = 0 (build/v143-vloc NOTES.md, series s1 and g1).
|
||||
LOCALS = 8
|
||||
|
||||
# runtime/simd.h helpers that take VCTX, with their parameters after c. Register-number parameters are d (written,
|
||||
# also read by some), n, m, a (read) and t (the first of up to 4 consecutive registers; written by the sl_ld* loads).
|
||||
HELPERS = {
|
||||
'fp_op_s': ['op', 'd', 'n', 'm'],
|
||||
'fp_op_d': ['op', 'd', 'n', 'm'],
|
||||
'fp_fma_s': ['na', 'nn', 'd', 'n', 'm', 'a'],
|
||||
'fp_fma_d': ['na', 'nn', 'd', 'n', 'm', 'a'],
|
||||
'sl_gen': ['op', 'sz', 'ne', 'd', 'szd', 'offd', 'keep', 'n', 'szn', 'offn', 'm', 'szm', 'offm', 'bidx', 'bimm'],
|
||||
'sl_addlp': ['u', 'acc', 'Q', 'sz', 'd', 'n'],
|
||||
'sl_across': ['op', 'u', 'Q', 'sz', 'd', 'n'],
|
||||
'sl_pmull64': ['part', 'd', 'n', 'm'],
|
||||
'sv_fred_s': ['op', 'd', 'n'],
|
||||
'sv_fcvtl': ['sz', 'part', 'd', 'n'],
|
||||
'sv_fcvtn': ['sz', 'part', 'odd', 'd', 'n'],
|
||||
'sv_tbl': ['Q', 'len', 'tbx', 'd', 'n', 'm'],
|
||||
'sv_aes': ['op', 'd', 'n'],
|
||||
'sv_sha1hash': ['op', 'd', 'n', 'm'],
|
||||
'sv_sha256hash': ['part1', 'd', 'n', 'm'],
|
||||
'sv_sha_misc': ['op', 'd', 'n', 'm'],
|
||||
'sl_ldm': ['Q', 'sz', 'selem', 'rpt', 't', 'ea'],
|
||||
'sl_stm': ['Q', 'sz', 'selem', 'rpt', 't', 'ea'],
|
||||
'sl_lds': ['sz', 'selem', 'idx', 't', 'ea'],
|
||||
'sl_sts': ['sz', 'selem', 'idx', 't', 'ea'],
|
||||
'sl_ldr': ['Q', 'sz', 'selem', 't', 'ea'],
|
||||
}
|
||||
REG_PARAMS = ('d', 'n', 'm', 'a', 't')
|
||||
LANE_T = {'sa16': 'vu16', 'sa32': 'vu32', 'sa64': 'vu64', 'saf32': 'vf32', 'saf64': 'vf64', 'uint8_t': 'vu8',
|
||||
'uint16_t': 'vu16', 'uint32_t': 'vu32', 'uint64_t': 'vu64', 'float': 'vf32', 'double': 'vf64'}
|
||||
CALLEE_SAVED = frozenset(range(8, 16))
|
||||
PLAIN = '\n const unsigned VMASK = 0; u128 *const vr = c->v; unsigned vd_ = 0, *const vdp = &vd_; (void)vr; (void)vdp;'
|
||||
|
||||
FN = re.compile(r'^(?:static )?void (?:f|fb)_[0-9a-f]+\(Cpu \*c\) \{$', re.M)
|
||||
CALL = re.compile(r'\b(?:f|fb)_[0-9a-f]+\(c\);|\brt_dispatch\(c\);|\brt_(?:svc|udf|brk|spin_gate)\(c,[^;]*;')
|
||||
RET = re.compile(r'(?:__attribute__\(\(musttail\)\)\s*)?\breturn\b[^;]*;')
|
||||
RET_BLOCK = re.compile(r'(\{ [^{}]*?(?:__attribute__\(\(musttail\)\) )?return\b[^;]*; \})')
|
||||
LANE = re.compile(r'\(\((\w+) \*\)&c->v\[')
|
||||
WHOLE = re.compile(r'c->v\[')
|
||||
USES = re.compile(r'\b(' + '|'.join(['VSET', 'VLSET', 'VGET', 'VLANE', 'VS8', 'VS16', 'VS32', 'VS64', 'VSF32', 'VSF64',
|
||||
'VHI64', 'VREG', 'VQ', 'VW', 'FP_SETS', 'FP_SETD', 'SV_FOP_S', 'SV_FOP_D']
|
||||
+ sorted(HELPERS)) + r')\(')
|
||||
|
||||
|
||||
class Unsupported(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def _close(s, i):
|
||||
"""s[i-1] opens a bracket; the index after its match"""
|
||||
d = 1
|
||||
while d:
|
||||
d += {'[': 1, ']': -1}.get(s[i], 0)
|
||||
i += 1
|
||||
return i
|
||||
|
||||
|
||||
def _stmt_end(s, i):
|
||||
"""index of the ';' that ends the expression starting at s[i]"""
|
||||
d = 0
|
||||
while True:
|
||||
ch = s[i]
|
||||
if ch in '([{':
|
||||
d += 1
|
||||
elif ch in ')]}':
|
||||
d -= 1
|
||||
elif ch == ';' and d == 0:
|
||||
return i
|
||||
i += 1
|
||||
|
||||
|
||||
def _args(s, i):
|
||||
"""arguments of the call whose '(' is s[i]"""
|
||||
d, cur, out = 0, '', []
|
||||
while True:
|
||||
ch = s[i]
|
||||
if ch == '(':
|
||||
d += 1
|
||||
if d == 1:
|
||||
i += 1
|
||||
continue
|
||||
elif ch == ')':
|
||||
d -= 1
|
||||
if d == 0:
|
||||
out.append(cur.strip())
|
||||
return out
|
||||
elif ch == ',' and d == 1:
|
||||
out.append(cur.strip())
|
||||
cur = ''
|
||||
i += 1
|
||||
continue
|
||||
cur += ch
|
||||
i += 1
|
||||
|
||||
|
||||
def accessors(t):
|
||||
"""c->v forms of emitted C -> the RT_VLOCALS accessors of runtime/simd.h"""
|
||||
out, i = [], 0
|
||||
while True:
|
||||
m1, m2 = LANE.search(t, i), WHOLE.search(t, i)
|
||||
m = min((x for x in (m1, m2) if x), key=lambda x: x.start(), default=None)
|
||||
if not m:
|
||||
out.append(t[i:])
|
||||
return ''.join(out)
|
||||
out.append(t[i:m.start()])
|
||||
if m is m1:
|
||||
e = _close(t, m.end())
|
||||
if m.group(1) not in LANE_T or t[e:e + 2] != ')[':
|
||||
raise Unsupported(f'V register pointer form {t[m.start():e + 10]!r}')
|
||||
je = _close(t, e + 2)
|
||||
reg, lane, vt = accessors(t[m.end():e - 1]), t[e + 2:je - 1], LANE_T[m.group(1)]
|
||||
a = re.match(r'\s*=(?!=)', t[je:])
|
||||
if a:
|
||||
se = _stmt_end(t, je + a.end())
|
||||
out.append(f'VLSET({reg}, {vt}, {lane}, {accessors(t[je + a.end():se]).strip()})')
|
||||
i = se
|
||||
else:
|
||||
out.append(f'VLANE({reg}, {vt}, {lane})')
|
||||
i = je
|
||||
continue
|
||||
if t[m.start() - 1:m.start()] == '&':
|
||||
raise Unsupported(f'V register address {t[m.start() - 1:m.start() + 20]!r}')
|
||||
e = _close(t, m.end())
|
||||
reg = accessors(t[m.end():e - 1])
|
||||
a = re.match(r'\s*=(?!=)', t[e:])
|
||||
if a:
|
||||
se = _stmt_end(t, e + a.end())
|
||||
out.append(f'VSET({reg}, {accessors(t[e + a.end():se]).strip()})')
|
||||
i = se
|
||||
else:
|
||||
out.append(f'VGET({reg})')
|
||||
i = e
|
||||
|
||||
|
||||
def _lit(a):
|
||||
a = a.strip().rstrip('uUlL')
|
||||
if re.fullmatch(r'-\d+', a):
|
||||
return -1
|
||||
return int(a, 0) if re.fullmatch(r'0x[0-9a-fA-F]+|\d+', a) else None
|
||||
|
||||
|
||||
def registers(body):
|
||||
"""(Counter of register uses, set of written registers) of a body in accessor form"""
|
||||
used, wr = Counter(), set()
|
||||
for m in USES.finditer(body):
|
||||
name = m.group(1)
|
||||
args = _args(body, m.end() - 1)
|
||||
if name in HELPERS:
|
||||
for p, a in zip(['c'] + HELPERS[name], args):
|
||||
if p not in REG_PARAMS:
|
||||
continue
|
||||
v = _lit(a)
|
||||
if v == -1:
|
||||
continue
|
||||
if v is None:
|
||||
raise Unsupported(f'register argument {a!r} of {name}')
|
||||
span = 4 if p == 't' or (name == 'sv_tbl' and p == 'n') else 1
|
||||
rs = [(v + k) & 31 for k in range(span)]
|
||||
used.update(rs)
|
||||
if p == 'd' or (p == 't' and name.startswith('sl_ld')):
|
||||
wr.update(rs)
|
||||
continue
|
||||
pos, write = {'VREG': (1, False), 'VQ': (2, False), 'VW': (2, True), 'SV_FOP_S': (2, True),
|
||||
'SV_FOP_D': (2, True), 'VSET': (0, True), 'VLSET': (0, True), 'FP_SETS': (0, True),
|
||||
'FP_SETD': (0, True)}.get(name, (0, False))
|
||||
v = _lit(args[pos])
|
||||
if v is None or v < 0:
|
||||
raise Unsupported(f'register {args[pos]!r} of {name}')
|
||||
used[v] += 1
|
||||
if write:
|
||||
wr.add(v)
|
||||
return used, wr
|
||||
|
||||
|
||||
def rewrite_one(body, k, trust, stats):
|
||||
"""Body of one C function (text between its braces)."""
|
||||
try:
|
||||
new = accessors(body)
|
||||
cnt, written = registers(new)
|
||||
except Unsupported:
|
||||
# a form this rewrite does not know: every register stays in c->v (VMASK 0)
|
||||
stats['v_unsupported_functions'] += 1
|
||||
return PLAIN + body
|
||||
body = new
|
||||
if not cnt:
|
||||
return body
|
||||
local = {r for r, _ in sorted(cnt.items(), key=lambda x: (-x[1], x[0]))[:k]}
|
||||
written &= local
|
||||
load = ''.join(f'VSYNC_IN({r}); ' for r in sorted(local))
|
||||
reload = ''.join(f'VSYNC_IN({r}); ' for r in sorted(local - (CALLEE_SAVED if trust else set())))
|
||||
store = ''.join(f'VSYNC_OUT_D({r}); ' for r in sorted(written))
|
||||
stats['v_local_functions'] += 1
|
||||
stats['v_local_registers'] += len(local)
|
||||
|
||||
def at_ret(m):
|
||||
stats['v_exit_syncs'] += 1
|
||||
return '{ ' + store + m.group(0) + ' }'
|
||||
|
||||
def at_call(m):
|
||||
stats['v_call_syncs'] += 1
|
||||
return '{ ' + store + m.group(0) + ' ' + reload + 'vd_ = 0; }'
|
||||
|
||||
body = RET.sub(at_ret, body)
|
||||
parts = RET_BLOCK.split(body)
|
||||
body = ''.join(p if i % 2 else CALL.sub(at_call, p) for i, p in enumerate(parts))
|
||||
mask = sum(1 << r for r in local)
|
||||
return (f'\n const unsigned VMASK = {mask:#x}u; u128 vr[32]; unsigned vd_ = 0, *const vdp = &vd_; {load.rstrip()}'
|
||||
+ body + ('\n ' + store.rstrip() if store else ''))
|
||||
|
||||
|
||||
def rewrite(text, k, trust, stats):
|
||||
"""C text of one emitted guest function (an f_ and, for a computed branch, its fb_) with K registers local."""
|
||||
out, pos = [], 0
|
||||
for m in FN.finditer(text):
|
||||
d, i = 1, m.end()
|
||||
while d:
|
||||
d += {'{': 1, '}': -1}.get(text[i], 0)
|
||||
i += 1
|
||||
out.append(text[pos:m.end()])
|
||||
out.append(rewrite_one(text[m.end():i - 1], k, trust, stats) + text[i - 1])
|
||||
pos = i
|
||||
out.append(text[pos:])
|
||||
return ''.join(out)
|
||||
@@ -0,0 +1,289 @@
|
||||
// Sound categories (music, effects, voices) for the volume_music / volume_sfx / volume_voice settings.
|
||||
//
|
||||
// The audio renderer only sees sample memory, so the category is learned where the game loads its sounds:
|
||||
// - RomFS opens and reads of Sound/Resource/ files (romfs.c romfs_open / romfs_read): the file name gives the
|
||||
// category (BGM_* music, NV_* and *_Vo_* / *Voice* voices, the rest effects);
|
||||
// - zstd decodes of BARS banks (ov_zstd.c decode): each bank entry's AMTA name refines the bank's category;
|
||||
// - Opus decodes (ov_media.c ov_decode): the decoded PCM inherits the category of the packet it came from.
|
||||
// Two tables answer the mixer (audio_mixer.c voice_category):
|
||||
// - DSP-ADPCM coefficient tables, by a hash of their 32 bytes, read from each BWAV channel header. The game copies
|
||||
// these coefficients next to the voice, so a voice's own table names its sound wherever its samples live;
|
||||
// - guest address ranges of loaded or decoded audio, newest first, for PCM voices (Opus output).
|
||||
// Everything here runs only while one of the three settings is below 100 (audio_cat_active): at the defaults no table
|
||||
// is written or read. A setting moved during play classifies what loads from then on; sounds loaded before (an area's
|
||||
// effect banks, a stream opened earlier) are found when their next stream read lands, otherwise they count as effects.
|
||||
#include "audio_cat.h"
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#include <stdatomic.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#define RANGE_CAP 4096 // address ranges, a ring: the oldest go first. Lookups scan it, so it stays small
|
||||
#define COEF_CAP 65536 // coefficient tables, open addressing; a full probe run drops the new table (it counts as SFX)
|
||||
#define COEF_PROBES 64
|
||||
|
||||
typedef struct {
|
||||
uint64_t start, end;
|
||||
uint8_t cat;
|
||||
} Range;
|
||||
|
||||
static Range ranges[RANGE_CAP];
|
||||
static uint32_t range_head; // ranges written so far; under range_lock
|
||||
static PlatMutex range_lock = PLAT_MUTEX_INIT;
|
||||
|
||||
typedef struct {
|
||||
_Atomic uint64_t hash; // 0 = free; a slot is claimed once and never freed
|
||||
_Atomic uint8_t cat;
|
||||
} Coef;
|
||||
|
||||
static Coef coefs[COEF_CAP];
|
||||
|
||||
typedef struct {
|
||||
uint64_t guest;
|
||||
uint8_t cat;
|
||||
} Decoder;
|
||||
|
||||
static Decoder decoders[64]; // the category each Opus decoder produced last; under decoder_lock
|
||||
static unsigned decoder_next;
|
||||
static PlatMutex decoder_lock = PLAT_MUTEX_INIT;
|
||||
|
||||
static _Atomic uint64_t coef_count[4], range_count, bars_count;
|
||||
|
||||
int audio_cat_active(void) {
|
||||
static _Atomic unsigned seen = ~0u;
|
||||
static _Atomic int on;
|
||||
unsigned ver = cfg_version();
|
||||
if (atomic_load_explicit(&seen, memory_order_acquire) != ver) {
|
||||
int a = cfg_double("TOTK_VOLUME_MUSIC") < 100 || cfg_double("TOTK_VOLUME_SFX") < 100 ||
|
||||
cfg_double("TOTK_VOLUME_VOICE") < 100;
|
||||
atomic_store_explicit(&on, a, memory_order_relaxed);
|
||||
atomic_store_explicit(&seen, ver, memory_order_release);
|
||||
}
|
||||
return atomic_load_explicit(&on, memory_order_relaxed);
|
||||
}
|
||||
|
||||
static int ci_str_has(const char *haystack, const char *needle) {
|
||||
size_t nlen = strlen(needle);
|
||||
for (; *haystack; haystack++)
|
||||
if (strncasecmp(haystack, needle, nlen) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int all_zero32(const uint8_t *p) {
|
||||
for (int i = 0; i < 32; i++)
|
||||
if (p[i]) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint64_t fnv1a32(const uint8_t *p) {
|
||||
uint64_t h = 14695981039346656037ULL;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
h ^= p[i];
|
||||
h *= 1099511628211ULL;
|
||||
}
|
||||
return h ? h : 1;
|
||||
}
|
||||
|
||||
// A table seen under several categories keeps music or voice over effects: one sample shared by a voice line and an
|
||||
// effect bank follows the voice setting.
|
||||
static void register_coef32(const uint8_t *coef, int cat) {
|
||||
if (cat <= AUDIO_CAT_UNKNOWN || cat > AUDIO_CAT_VOICE || all_zero32(coef)) return;
|
||||
uint64_t h = fnv1a32(coef);
|
||||
for (uint32_t step = 0; step < COEF_PROBES; step++) {
|
||||
Coef *e = &coefs[((uint32_t)h + step) & (COEF_CAP - 1)];
|
||||
uint64_t cur = atomic_load_explicit(&e->hash, memory_order_acquire);
|
||||
if (cur == 0 && atomic_compare_exchange_strong_explicit(&e->hash, &cur, h, memory_order_acq_rel,
|
||||
memory_order_acquire)) {
|
||||
atomic_store_explicit(&e->cat, (uint8_t)cat, memory_order_release);
|
||||
atomic_fetch_add_explicit(&coef_count[cat], 1, memory_order_relaxed);
|
||||
return;
|
||||
}
|
||||
if (cur == h) {
|
||||
if (cat != AUDIO_CAT_SFX) atomic_store_explicit(&e->cat, (uint8_t)cat, memory_order_release);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int audio_cat_lookup_coef(uint64_t extra_addr, uint64_t extra_size) {
|
||||
if (!extra_addr || extra_size < 32 || extra_addr >= RT_ADDRESS_LIMIT || !mem_guest_readable(extra_addr, 32))
|
||||
return AUDIO_CAT_UNKNOWN;
|
||||
const uint8_t *p = (const uint8_t *)(uintptr_t)extra_addr;
|
||||
if (all_zero32(p)) return AUDIO_CAT_UNKNOWN;
|
||||
uint64_t h = fnv1a32(p);
|
||||
for (uint32_t step = 0; step < COEF_PROBES; step++) {
|
||||
Coef *e = &coefs[((uint32_t)h + step) & (COEF_CAP - 1)];
|
||||
uint64_t cur = atomic_load_explicit(&e->hash, memory_order_acquire);
|
||||
if (cur == h) return atomic_load_explicit(&e->cat, memory_order_acquire); // 0 while the writer is midway
|
||||
if (cur == 0) break;
|
||||
}
|
||||
return AUDIO_CAT_UNKNOWN;
|
||||
}
|
||||
|
||||
// BWAV: "BWAV", channel count at 0x0E, then 0x4C-byte channel infos from 0x10: codec u16 (1 = DSP-ADPCM) and the 16
|
||||
// ADPCM coefficients at +0x10.
|
||||
void audio_cat_scan_bwav(const void *data, uint64_t size, int cat) {
|
||||
if (!data || size < 0x40 || cat <= AUDIO_CAT_UNKNOWN) return;
|
||||
const uint8_t *b = data;
|
||||
uint32_t magic;
|
||||
uint16_t nch;
|
||||
memcpy(&magic, b, 4);
|
||||
memcpy(&nch, b + 0x0E, 2);
|
||||
if (magic != 0x56415742u || nch == 0 || nch > 16) return;
|
||||
for (uint16_t ch = 0; ch < nch; ch++) {
|
||||
uint64_t at = 0x10ull + ch * 0x4Cull;
|
||||
if (at + 0x30 > size) break;
|
||||
uint16_t codec;
|
||||
memcpy(&codec, b + at, 2);
|
||||
if (codec == 1) register_coef32(b + at + 0x10, cat);
|
||||
}
|
||||
}
|
||||
|
||||
// Every sound bank and stream of the game is under Sound/Resource/ (Sound/Resource/*.bars.zs, Sound/Resource/Stream/
|
||||
// *.bwav); everything else is not audio. Creature and player vocal banks (Bokoblin_Voice0, Player_Voice, *_Vo_*)
|
||||
// count as voices, as do the NV_* character voice lines.
|
||||
int audio_cat_from_path(const char *path) {
|
||||
if (!path || strncmp(path, "Sound/Resource/", 15)) return AUDIO_CAT_UNKNOWN;
|
||||
const char *name = strrchr(path, '/') + 1;
|
||||
if (!strncasecmp(name, "nv_", 3) || !strncasecmp(name, "vo_", 3)) return AUDIO_CAT_VOICE;
|
||||
if (ci_str_has(name, "bgm_")) return AUDIO_CAT_MUSIC;
|
||||
if (ci_str_has(name, "_voice") || ci_str_has(name, "voice_") || ci_str_has(name, "_vo_") ||
|
||||
ci_str_has(name, "shoutvoice") || ci_str_has(name, "shoutmsg"))
|
||||
return AUDIO_CAT_VOICE;
|
||||
return AUDIO_CAT_SFX;
|
||||
}
|
||||
|
||||
void audio_cat_tag_range(uint64_t addr, uint64_t size, int cat) {
|
||||
if (!addr || !size || cat <= AUDIO_CAT_UNKNOWN || cat > AUDIO_CAT_VOICE) return;
|
||||
plat_mutex_lock(&range_lock);
|
||||
// A stream refills the same buffers: the same range read again only changes its category.
|
||||
uint32_t depth = range_head < 64 ? range_head : 64;
|
||||
for (uint32_t k = 0; k < depth; k++) {
|
||||
Range *r = &ranges[(range_head - 1 - k) & (RANGE_CAP - 1)];
|
||||
if (r->start == addr && r->end == addr + size) {
|
||||
r->cat = (uint8_t)cat;
|
||||
plat_mutex_unlock(&range_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Range *r = &ranges[range_head & (RANGE_CAP - 1)];
|
||||
r->start = addr;
|
||||
r->end = addr + size;
|
||||
r->cat = (uint8_t)cat;
|
||||
range_head++;
|
||||
plat_mutex_unlock(&range_lock);
|
||||
atomic_fetch_add_explicit(&range_count, 1, memory_order_relaxed);
|
||||
}
|
||||
|
||||
// The newest range holding addr; newer loads into reused memory win over older ones.
|
||||
int audio_cat_lookup(uint64_t addr) {
|
||||
if (!addr) return AUDIO_CAT_UNKNOWN;
|
||||
int cat = AUDIO_CAT_UNKNOWN;
|
||||
plat_mutex_lock_shared(&range_lock);
|
||||
uint32_t n = range_head < RANGE_CAP ? range_head : RANGE_CAP;
|
||||
for (uint32_t k = 0; k < n; k++) {
|
||||
const Range *r = &ranges[(range_head - 1 - k) & (RANGE_CAP - 1)];
|
||||
if (addr >= r->start && addr < r->end) {
|
||||
cat = r->cat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
plat_mutex_unlock_shared(&range_lock);
|
||||
return cat;
|
||||
}
|
||||
|
||||
// BARS: "BARS", entry count at 0x0C, then count CRC32 name hashes and count (AMTA offset, BWAV offset) pairs. The AMTA
|
||||
// block holds the entry's name; music and voice names inside an effects bank (a boss bank with its BGM) get their own
|
||||
// category. ADPCM entries register their coefficients; other entries tag their bytes.
|
||||
void audio_cat_scan_bars(uint64_t dst, uint64_t size, int fallback_cat) {
|
||||
if (!dst || size < 16) return;
|
||||
atomic_fetch_add_explicit(&bars_count, 1, memory_order_relaxed);
|
||||
if (fallback_cat != AUDIO_CAT_UNKNOWN) audio_cat_tag_range(dst, size, fallback_cat);
|
||||
const uint8_t *base = (const uint8_t *)(uintptr_t)dst;
|
||||
uint32_t count;
|
||||
memcpy(&count, base + 0x0C, 4);
|
||||
if (count > 16384 || 0x10ull + (uint64_t)count * 12ull > size) return;
|
||||
const uint8_t *pairs = base + 0x10 + (uint64_t)count * 4;
|
||||
for (uint32_t k = 0; k < count; k++) {
|
||||
uint32_t amta_off, bwav_off;
|
||||
memcpy(&amta_off, pairs + k * 8ull, 4);
|
||||
memcpy(&bwav_off, pairs + k * 8ull + 4, 4);
|
||||
if (bwav_off >= size) continue;
|
||||
int cat = fallback_cat != AUDIO_CAT_UNKNOWN ? fallback_cat : AUDIO_CAT_SFX;
|
||||
if (amta_off < size) {
|
||||
uint64_t limit = size - amta_off < 512 ? size - amta_off : 512;
|
||||
const char *a = (const char *)(base + amta_off);
|
||||
for (uint64_t s = 0; s + 4 <= limit; s++) {
|
||||
if (!memcmp(a + s, "BGM_", 4)) { cat = AUDIO_CAT_MUSIC; break; }
|
||||
if (!memcmp(a + s, "Vo_", 3) || !memcmp(a + s, "NV_", 3)) { cat = AUDIO_CAT_VOICE; break; }
|
||||
if (s + 5 <= limit && !memcmp(a + s, "Voice", 5)) { cat = AUDIO_CAT_VOICE; break; }
|
||||
}
|
||||
}
|
||||
const uint8_t *w = base + bwav_off;
|
||||
uint32_t magic = 0;
|
||||
uint16_t codec = 0;
|
||||
if (bwav_off + 0x40 <= size) {
|
||||
memcpy(&magic, w, 4);
|
||||
memcpy(&codec, w + 0x10, 2);
|
||||
}
|
||||
if (magic == 0x56415742u) audio_cat_scan_bwav(w, size - bwav_off, cat);
|
||||
if (cat == fallback_cat || (magic == 0x56415742u && codec == 1)) continue;
|
||||
// The entry ends where the next BWAV starts: one pass over the offsets, only for the few entries tagged here.
|
||||
uint64_t next = size;
|
||||
for (uint32_t j = 0; j < count; j++) {
|
||||
uint32_t o;
|
||||
memcpy(&o, pairs + j * 8ull + 4, 4);
|
||||
if (o > bwav_off && o < next) next = o;
|
||||
}
|
||||
audio_cat_tag_range(dst + bwav_off, next - bwav_off, cat);
|
||||
}
|
||||
}
|
||||
|
||||
// The PCM out of one Opus packet takes the packet's category, else the decoder's last one, else effects. Consecutive
|
||||
// packets of one decoder fill one buffer, so the output grows the newest matching range instead of adding one each.
|
||||
void audio_cat_on_opus_decode(uint64_t decoder_guest, uint64_t in_addr, uint64_t out_addr, uint64_t out_size) {
|
||||
if (!out_addr || !out_size) return;
|
||||
int cat = audio_cat_lookup(in_addr);
|
||||
plat_mutex_lock(&decoder_lock);
|
||||
int slot = -1;
|
||||
for (int i = 0; i < 64 && decoder_guest; i++)
|
||||
if (decoders[i].guest == decoder_guest) slot = i;
|
||||
if (cat == AUDIO_CAT_UNKNOWN && slot >= 0) cat = decoders[slot].cat;
|
||||
if (cat == AUDIO_CAT_UNKNOWN) cat = AUDIO_CAT_SFX;
|
||||
if (decoder_guest) {
|
||||
if (slot < 0) {
|
||||
slot = (int)(decoder_next++ & 63);
|
||||
decoders[slot].guest = decoder_guest;
|
||||
}
|
||||
decoders[slot].cat = (uint8_t)cat;
|
||||
}
|
||||
plat_mutex_unlock(&decoder_lock);
|
||||
|
||||
plat_mutex_lock(&range_lock);
|
||||
uint32_t depth = range_head < 32 ? range_head : 32;
|
||||
for (uint32_t k = 0; k < depth; k++) {
|
||||
Range *r = &ranges[(range_head - 1 - k) & (RANGE_CAP - 1)];
|
||||
if (r->cat != (uint8_t)cat) continue;
|
||||
uint64_t lo = r->start > 65536 ? r->start - 65536 : 0, hi = r->end + 65536;
|
||||
if (out_addr >= lo && out_addr + out_size <= hi) {
|
||||
if (out_addr < r->start) r->start = out_addr;
|
||||
if (out_addr + out_size > r->end) r->end = out_addr + out_size;
|
||||
plat_mutex_unlock(&range_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
plat_mutex_unlock(&range_lock);
|
||||
audio_cat_tag_range(out_addr, out_size, cat);
|
||||
}
|
||||
|
||||
void audio_cat_log_tables(void) {
|
||||
rt_log("audio: categories known: coefficient tables music %llu, sfx %llu, voice %llu; address ranges %llu "
|
||||
"(ring %d); BARS banks scanned %llu",
|
||||
(unsigned long long)atomic_load(&coef_count[AUDIO_CAT_MUSIC]),
|
||||
(unsigned long long)atomic_load(&coef_count[AUDIO_CAT_SFX]),
|
||||
(unsigned long long)atomic_load(&coef_count[AUDIO_CAT_VOICE]), (unsigned long long)atomic_load(&range_count),
|
||||
RANGE_CAP, (unsigned long long)atomic_load(&bars_count));
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Sound categories for the music / effects / voice volume settings (audio_cat.c).
|
||||
#ifndef TOTK_AUDIO_CAT_H
|
||||
#define TOTK_AUDIO_CAT_H
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
AUDIO_CAT_UNKNOWN = 0,
|
||||
AUDIO_CAT_MUSIC = 1,
|
||||
AUDIO_CAT_SFX = 2,
|
||||
AUDIO_CAT_VOICE = 3,
|
||||
};
|
||||
|
||||
int audio_cat_active(void); // one of volume_music / volume_sfx / volume_voice is below 100
|
||||
int audio_cat_from_path(const char *path); // a RomFS-relative path; UNKNOWN outside Sound/Resource/
|
||||
void audio_cat_tag_range(uint64_t addr, uint64_t size, int cat);
|
||||
void audio_cat_scan_bars(uint64_t dst, uint64_t size, int fallback_cat);
|
||||
void audio_cat_scan_bwav(const void *data, uint64_t size, int cat);
|
||||
void audio_cat_on_opus_decode(uint64_t decoder_guest, uint64_t in_addr, uint64_t out_addr, uint64_t out_size);
|
||||
int audio_cat_lookup(uint64_t addr);
|
||||
int audio_cat_lookup_coef(uint64_t extra_addr, uint64_t extra_size);
|
||||
void audio_cat_log_tables(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+212
-23
@@ -28,6 +28,7 @@
|
||||
#include "cfg.h"
|
||||
#include "audio_effects.h"
|
||||
#include "audio_reverb.h"
|
||||
#include "audio_cat.h"
|
||||
#include "audren.h"
|
||||
#include "host.h"
|
||||
#include "ipc.h"
|
||||
@@ -52,7 +53,10 @@ typedef struct Mixer {
|
||||
float *buf; int nbuf, frame;
|
||||
int *offset; // first mix buffer of each mix id
|
||||
SplitInfo *split; int nsplit; SplitDest *dest; int ndest;
|
||||
SDL_AudioStream *stream; int device_ok, rate;
|
||||
SDL_AudioStream *stream; int device_ok, rate; // stream: output_open's, then the output worker's alone
|
||||
SDL_AudioDeviceID open_id, failed_id; // the device the stream plays on; the last one that failed to open
|
||||
PlatThread *worker; PlatEvent wake; // output_worker, NULL until a device is chosen; wake: a cfg change
|
||||
_Atomic int worker_quit; unsigned watch_ver; // watch_ver: the render thread's last cfg_version (output_watch)
|
||||
int channels; // output channels, 2 or 6 (output_channels)
|
||||
float ring[RING_FRAMES * OUT_MAX];
|
||||
_Atomic uint64_t wr, rd, underruns, overruns, missing_frames, callback_frames, callback_nonzero, skipped_frames;
|
||||
@@ -83,6 +87,64 @@ static float host_volume(void) {
|
||||
v = (float)((pct < 0 ? 0 : pct > 100 ? 100 : pct) / 100);
|
||||
return v;
|
||||
}
|
||||
|
||||
// TOTK_VOLUME_MUSIC / _SFX / _VOICE: per-category volumes in percent on top of TOTK_VOLUME, live like it. Render thread
|
||||
// only.
|
||||
static float category_volume(int cat) {
|
||||
static const char *const names[4] = {NULL, "TOTK_VOLUME_MUSIC", "TOTK_VOLUME_SFX", "TOTK_VOLUME_VOICE"};
|
||||
static float v[4] = {1, 1, 1, 1};
|
||||
static unsigned seen = ~0u;
|
||||
unsigned ver = cfg_version();
|
||||
if (ver != seen) {
|
||||
seen = ver;
|
||||
for (int k = 1; k < 4; k++) {
|
||||
double pct = cfg_double(names[k]);
|
||||
v[k] = (float)((pct < 0 ? 0 : pct > 100 ? 100 : pct) / 100);
|
||||
}
|
||||
}
|
||||
return v[cat >= AUDIO_CAT_MUSIC && cat <= AUDIO_CAT_VOICE ? cat : AUDIO_CAT_SFX];
|
||||
}
|
||||
|
||||
// What the voice plays (audio_cat.c): an ADPCM voice by its coefficient table, any voice by the newest loaded or decoded
|
||||
// range holding its current wave buffer, else effects. Kept per voice until it moves to another buffer or table, so a
|
||||
// table lookup runs once per wave buffer, not once per frame. The counts feed category_report.
|
||||
static uint64_t cat_counts[4], cat_by_coef, cat_by_range, cat_ns;
|
||||
static int voice_category(ServerVoice *v) {
|
||||
uint64_t addr = v->buffers[v->index].address, extra = v->in.extra_address;
|
||||
if (v->cat && v->cat_address == addr && v->cat_extra == extra) return v->cat;
|
||||
uint64_t t0 = kern_now_ns();
|
||||
int cat = AUDIO_CAT_UNKNOWN;
|
||||
if (v->in.sample_format == FMT_ADPCM) cat = audio_cat_lookup_coef(extra, v->in.extra_size);
|
||||
if (cat != AUDIO_CAT_UNKNOWN) cat_by_coef++;
|
||||
else if ((cat = audio_cat_lookup(addr)) != AUDIO_CAT_UNKNOWN) cat_by_range++;
|
||||
else cat = AUDIO_CAT_SFX;
|
||||
cat_counts[cat]++;
|
||||
v->cat = (uint8_t)cat;
|
||||
v->cat_address = addr;
|
||||
v->cat_extra = extra;
|
||||
cat_ns += kern_now_ns() - t0;
|
||||
return cat;
|
||||
}
|
||||
|
||||
// While a category volume is set, once a minute: how the wave buffers played were classified and what it cost.
|
||||
static void category_report(void) {
|
||||
static uint64_t next;
|
||||
uint64_t now = kern_now_ns();
|
||||
if (!next) next = now + 60000000000ull;
|
||||
if (now < next) return;
|
||||
next = now + 60000000000ull;
|
||||
uint64_t n = cat_counts[AUDIO_CAT_MUSIC] + cat_counts[AUDIO_CAT_SFX] + cat_counts[AUDIO_CAT_VOICE];
|
||||
rt_log("audio: categories over the last minute: %llu wave buffers, music %llu, sfx %llu, voice %llu; by coefficients "
|
||||
"%llu, by address %llu, unmatched (played as sfx) %llu; %.1f us classifying",
|
||||
(unsigned long long)n, (unsigned long long)cat_counts[AUDIO_CAT_MUSIC],
|
||||
(unsigned long long)cat_counts[AUDIO_CAT_SFX], (unsigned long long)cat_counts[AUDIO_CAT_VOICE],
|
||||
(unsigned long long)cat_by_coef, (unsigned long long)cat_by_range,
|
||||
(unsigned long long)(n - cat_by_coef - cat_by_range), cat_ns / 1000.0);
|
||||
audio_cat_log_tables();
|
||||
memset(cat_counts, 0, sizeof cat_counts);
|
||||
cat_by_coef = cat_by_range = cat_ns = 0;
|
||||
}
|
||||
|
||||
static unsigned audio_revision(const AudioRenderer *r) { unsigned byte = r->revision >> 24; return byte >= '0' ? byte - '0' : 0; }
|
||||
static void report_once(Mixer *m, unsigned bit, const char *msg, int value) {
|
||||
if (m->reported & (1u << bit)) return;
|
||||
@@ -108,8 +170,41 @@ static int prefill_blocks_for(const char *e) {
|
||||
return (int)ceil(ms / 5.0);
|
||||
}
|
||||
|
||||
// TOTK_AUDIO_DEVICE: the playback device by the name SDL reports (SDL_GetAudioDeviceName), since SDL's device ids
|
||||
// change between runs. Unset, empty or "default": the system default, which SDL follows when Windows changes it.
|
||||
static int device_is_default(const char *want) { return !want || !*want || !strcmp(want, "default"); }
|
||||
|
||||
// The device for `want`: the first playback device of that name, *found 1; else the system default, *found 0 for a name
|
||||
// SDL does not list (unplugged). The default asks SDL nothing.
|
||||
static SDL_AudioDeviceID device_pick(const char *want, int *found) {
|
||||
*found = 1;
|
||||
if (device_is_default(want)) return SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK;
|
||||
int n = 0;
|
||||
SDL_AudioDeviceID *ids = SDL_GetAudioPlaybackDevices(&n), id = 0;
|
||||
for (int i = 0; ids && i < n && !id; i++) {
|
||||
const char *name = SDL_GetAudioDeviceName(ids[i]);
|
||||
if (name && !strcmp(name, want)) id = ids[i];
|
||||
}
|
||||
SDL_free(ids);
|
||||
*found = id != 0;
|
||||
return id ? id : SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK;
|
||||
}
|
||||
|
||||
int audio_output_devices(char (*names)[AUDIO_DEVICE_NAME_MAX], int max) {
|
||||
if (!SDL_WasInit(SDL_INIT_AUDIO)) return 0; // TOTK_AUDIO=none or no output: nothing to pick
|
||||
int n = 0, k = 0;
|
||||
SDL_AudioDeviceID *ids = SDL_GetAudioPlaybackDevices(&n);
|
||||
for (int i = 0; ids && i < n && k < max; i++) {
|
||||
const char *name = SDL_GetAudioDeviceName(ids[i]);
|
||||
if (name && *name && strlen(name) < AUDIO_DEVICE_NAME_MAX) snprintf(names[k++], AUDIO_DEVICE_NAME_MAX, "%s", name);
|
||||
}
|
||||
SDL_free(ids);
|
||||
return k;
|
||||
}
|
||||
|
||||
// TOTK_AUDIO_CHANNELS: the output channels of this run, decided once. stereo gives 2; 5.1 gives 6 (FL FR C LFE RL RR,
|
||||
// the device sink's order and SDL's); auto gives 6 when the default playback device has at least six channels (a 5.1
|
||||
// the device sink's order and SDL's); auto gives 6 when the chosen playback device (TOTK_AUDIO_DEVICE at start, the
|
||||
// system default without one) has at least six channels (a 5.1
|
||||
// or 7.1 speaker setup in Windows; SDL places 5.1 on 7.1) and 2 otherwise. IAudioDevice reports the same count to the
|
||||
// game (GetActiveChannelCount), which picks its sink layout from it. TOTK_AUDIO=none: 2, without touching SDL.
|
||||
static int output_channels(void) {
|
||||
@@ -122,10 +217,12 @@ static int output_channels(void) {
|
||||
else if (!strcmp(want, "stereo")) n = 2;
|
||||
else {
|
||||
SDL_AudioSpec dev = {0};
|
||||
n = SDL_InitSubSystem(SDL_INIT_AUDIO) && SDL_GetAudioDeviceFormat(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &dev, NULL) &&
|
||||
dev.channels >= 6 ? 6 : 2;
|
||||
rt_log("audio: TOTK_AUDIO_CHANNELS=auto: the default device has %d channels, output %s", dev.channels,
|
||||
n == 6 ? "5.1" : "stereo");
|
||||
int found, ok = SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||
SDL_AudioDeviceID id = ok ? device_pick(cfg_get("TOTK_AUDIO_DEVICE"), &found) : 0;
|
||||
n = ok && SDL_GetAudioDeviceFormat(id, &dev, NULL) && dev.channels >= 6 ? 6 : 2;
|
||||
const char *name = ok ? SDL_GetAudioDeviceName(id) : NULL;
|
||||
rt_log("audio: TOTK_AUDIO_CHANNELS=auto: device '%s' has %d channels, output %s", name ? name : "?",
|
||||
dev.channels, n == 6 ? "5.1" : "stereo");
|
||||
}
|
||||
int expected = 0;
|
||||
return atomic_compare_exchange_strong(&decided, &expected, n) ? n : expected;
|
||||
@@ -207,6 +304,28 @@ static void SDLCALL sdl_pull(void *user, SDL_AudioStream *stream, int additional
|
||||
}
|
||||
}
|
||||
|
||||
// The pacing figures of the stream's device: its period, the output target and the stall time. Set before the stream
|
||||
// is resumed; the render thread reads target and stall_ns while a switch sets them (audio_mixer_pace_ns).
|
||||
static void output_timing(Mixer *m, SDL_AudioSpec *dev) {
|
||||
int period = 0;
|
||||
if (!SDL_GetAudioDeviceFormat(SDL_GetAudioStreamDevice(m->stream), dev, &period) || period <= 0) period = m->frame;
|
||||
m->period = period;
|
||||
int target = m->frame * m->prefill > 2 * period ? m->frame * m->prefill : 2 * period;
|
||||
__atomic_store_n(&m->target, target > RING_FRAMES / 2 ? RING_FRAMES / 2 : target, __ATOMIC_RELAXED);
|
||||
uint64_t period_ns = (uint64_t)period * 1000000000ull / (uint64_t)m->rate;
|
||||
__atomic_store_n(&m->stall_ns, 4 * period_ns > STALL_MS * 1000000ull ? 4 * period_ns : STALL_MS * 1000000ull,
|
||||
__ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
static void output_log(Mixer *m, const char *what, const SDL_AudioSpec *dev) {
|
||||
const char *name = SDL_GetAudioDeviceName(SDL_GetAudioStreamDevice(m->stream));
|
||||
rt_log("audio: SDL device '%s' %s, %d Hz %s float (device %d channels), prefill %d ms, device period %d frames; "
|
||||
"the device paces rendering at %.1f ms queued", name ? name : "?", what, m->rate,
|
||||
m->channels == 6 ? "5.1" : "stereo", dev->channels, m->prefill * 5, m->period, m->target * 1000.0 / m->rate);
|
||||
}
|
||||
|
||||
static void output_worker_start(Mixer *m);
|
||||
|
||||
static void output_open(Mixer *m, int rate) {
|
||||
const char *mode = cfg_get("TOTK_AUDIO");
|
||||
if ((mode && !strcmp(mode, "none")) || cfg_get("TOTK_AUDIO_OFF")) {
|
||||
@@ -217,12 +336,18 @@ static void output_open(Mixer *m, int rate) {
|
||||
rt_log("audio: SDL audio init failed (%s): mixing without sound", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
const char *want = cfg_get("TOTK_AUDIO_DEVICE");
|
||||
int found;
|
||||
m->open_id = device_pick(want, &found);
|
||||
if (!found) rt_log("audio: TOTK_AUDIO_DEVICE '%s' is not connected: the system default plays", want);
|
||||
SDL_AudioSpec spec = {SDL_AUDIO_F32, m->channels, rate};
|
||||
m->stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, sdl_pull, m);
|
||||
m->stream = SDL_OpenAudioDeviceStream(m->open_id, &spec, sdl_pull, m);
|
||||
if (!m->stream) {
|
||||
rt_log("audio: no output device (%s): mixing without sound", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
SDL_AudioSpec dev = {0};
|
||||
output_timing(m, &dev);
|
||||
if (!SDL_ResumeAudioStreamDevice(m->stream)) {
|
||||
rt_log("audio: starting the output failed (%s): mixing without sound", SDL_GetError());
|
||||
SDL_DestroyAudioStream(m->stream);
|
||||
@@ -230,28 +355,84 @@ static void output_open(Mixer *m, int rate) {
|
||||
return;
|
||||
}
|
||||
m->device_ok = 1;
|
||||
output_log(m, "opened", &dev);
|
||||
m->watch_ver = cfg_version();
|
||||
if (!device_is_default(want)) output_worker_start(m); // watches the chosen device from the start
|
||||
}
|
||||
|
||||
// ---- switching the output device while the game plays (TOTK_AUDIO_DEVICE is live)
|
||||
// One worker thread per mixer, started when a device is first chosen, owns the stream from then on: it opens the new
|
||||
// device (tens of ms) off the render thread, so the game's audio never waits for it. Once a second, and at once when
|
||||
// cfg changes, it resolves the setting again: a chosen device that disappears falls back to the system default, and the
|
||||
// output returns to it within a second of it being plugged in again. SDL's device events are not used: on Windows
|
||||
// nothing pumps SDL's event queue (the window is Win32, gfx_window_win.c), while SDL's device list stays current.
|
||||
|
||||
// Moves the output to device `id` with the same spec; SDL converts to the device's own format and channels.
|
||||
static void output_switch(Mixer *m, SDL_AudioDeviceID id) {
|
||||
SDL_AudioSpec spec = {SDL_AUDIO_F32, m->channels, m->rate};
|
||||
SDL_AudioStream *s = SDL_OpenAudioDeviceStream(id, &spec, sdl_pull, m); // opens paused: no callback yet
|
||||
if (!s) {
|
||||
const char *name = SDL_GetAudioDeviceName(id);
|
||||
rt_log("audio: opening device '%s' failed (%s): the output stays where it was", name ? name : "?",
|
||||
SDL_GetError());
|
||||
m->failed_id = id; // not tried again until the setting or the device list leads elsewhere
|
||||
return;
|
||||
}
|
||||
SDL_DestroyAudioStream(m->stream); // closes the old device; returns once its callback has finished
|
||||
m->stream = s;
|
||||
m->open_id = id;
|
||||
m->failed_id = 0;
|
||||
// No callback runs until the resume: its prefill starts over, and the render thread paces by its timer (pulled_ns
|
||||
// 0) until the new device asks for audio. The ring and the game go on; ring_pull trims what piled up meanwhile.
|
||||
m->ready = 0;
|
||||
atomic_store_explicit(&m->pulled_ns, 0, memory_order_release);
|
||||
SDL_AudioSpec dev = {0};
|
||||
int period = 0;
|
||||
if (!SDL_GetAudioDeviceFormat(SDL_GetAudioStreamDevice(m->stream), &dev, &period) || period <= 0) period = m->frame;
|
||||
m->period = period;
|
||||
m->target = m->frame * m->prefill > 2 * period ? m->frame * m->prefill : 2 * period;
|
||||
if (m->target > RING_FRAMES / 2) m->target = RING_FRAMES / 2;
|
||||
uint64_t period_ns = (uint64_t)period * 1000000000ull / (uint64_t)rate;
|
||||
m->stall_ns = 4 * period_ns > STALL_MS * 1000000ull ? 4 * period_ns : STALL_MS * 1000000ull;
|
||||
const char *name = SDL_GetAudioDeviceName(SDL_GetAudioStreamDevice(m->stream));
|
||||
rt_log("audio: SDL device '%s' opened, %d Hz %s float (device %d channels), prefill %d ms, device period %d frames; "
|
||||
"the device paces rendering at %.1f ms queued", name ? name : "?", rate, m->channels == 6 ? "5.1" : "stereo",
|
||||
dev.channels, m->prefill * 5, period, m->target * 1000.0 / rate);
|
||||
output_timing(m, &dev);
|
||||
if (!SDL_ResumeAudioStreamDevice(s)) rt_log("audio: starting the output failed (%s)", SDL_GetError());
|
||||
output_log(m, "switched to", &dev);
|
||||
}
|
||||
|
||||
static void output_worker(void *p) {
|
||||
Mixer *m = p;
|
||||
while (!atomic_load(&m->worker_quit)) {
|
||||
const char *want = cfg_get("TOTK_AUDIO_DEVICE");
|
||||
int found;
|
||||
SDL_AudioDeviceID id = device_pick(want, &found);
|
||||
if (id != m->open_id && id != m->failed_id) {
|
||||
if (!found) rt_log("audio: TOTK_AUDIO_DEVICE '%s' is not connected: switching to the system default", want);
|
||||
output_switch(m, id);
|
||||
}
|
||||
if (id == m->open_id) m->failed_id = 0;
|
||||
plat_event_wait_ns(&m->wake, 1000000000ull);
|
||||
}
|
||||
}
|
||||
|
||||
static void output_worker_start(Mixer *m) {
|
||||
plat_event_init(&m->wake, 0, 0);
|
||||
m->worker = plat_thread_new(output_worker, m, "audio-out");
|
||||
if (!m->worker) rt_log("audio: no output worker thread: the device stays as it is until the next start");
|
||||
}
|
||||
|
||||
// Render thread: wakes the worker when cfg changed, or starts it when a device is chosen for the first time. Until the
|
||||
// worker runs the stream plays on the system default (output_open), so an unset setting costs this check alone.
|
||||
static void output_watch(Mixer *m) {
|
||||
unsigned ver = cfg_version();
|
||||
if (ver == m->watch_ver) return;
|
||||
m->watch_ver = ver;
|
||||
if (m->worker) plat_event_set(&m->wake);
|
||||
else if (!device_is_default(cfg_get("TOTK_AUDIO_DEVICE"))) output_worker_start(m);
|
||||
}
|
||||
|
||||
int64_t audio_mixer_pace_ns(AudioRenderer *r, uint64_t now) {
|
||||
Mixer *m = r->mixer;
|
||||
if (m && m->device_ok) output_watch(m);
|
||||
if (!m || !m->device_ok || !atomic_load_explicit(&m->playing, memory_order_acquire)) return -1;
|
||||
uint64_t pulled = atomic_load_explicit(&m->pulled_ns, memory_order_acquire);
|
||||
if (!pulled || (now > pulled && now - pulled > m->stall_ns)) return -1;
|
||||
if (!pulled || (now > pulled && now - pulled > __atomic_load_n(&m->stall_ns, __ATOMIC_RELAXED))) return -1;
|
||||
uint64_t have = atomic_load(&m->wr) - atomic_load_explicit(&m->rd, memory_order_acquire);
|
||||
if (have < (uint64_t)m->target) return 0;
|
||||
int64_t ns = (int64_t)((have - (uint64_t)m->target + 1) * 1000000000ull / (uint64_t)m->rate);
|
||||
uint64_t target = (uint64_t)__atomic_load_n(&m->target, __ATOMIC_RELAXED);
|
||||
if (have < target) return 0;
|
||||
int64_t ns = (int64_t)((have - target + 1) * 1000000000ull / (uint64_t)m->rate);
|
||||
return ns < 500000 ? 500000 : ns; // until the device has taken it below the target
|
||||
}
|
||||
|
||||
@@ -379,6 +560,11 @@ void audio_mixer_set_running(AudioRenderer *r, int running) {
|
||||
void audio_mixer_close(AudioRenderer *r) {
|
||||
Mixer *m = r->mixer;
|
||||
if (!m) return;
|
||||
if (m->worker) { // the render thread is joined: nothing wakes or starts the worker any more
|
||||
atomic_store(&m->worker_quit, 1);
|
||||
plat_event_set(&m->wake);
|
||||
plat_thread_join(m->worker);
|
||||
}
|
||||
if (m->stream) { // destroying the stream closes the device and waits for the callback to finish
|
||||
SDL_DestroyAudioStream(m->stream);
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
@@ -812,10 +998,13 @@ void audio_mixer_render(AudioRenderer *r, double seconds) {
|
||||
if (at > m->nbuf) { rt_log("audio: mixes use %d buffers, renderer has %d", at, m->nbuf); rt_fatal("audio mix buffer layout"); }
|
||||
|
||||
float (*vs)[MAX_FRAME]=m->voice_scratch,*filtered=m->filter_scratch;
|
||||
const int by_category = audio_cat_active(); // the defaults (all 100) skip the category lookups
|
||||
if (by_category) category_report();
|
||||
for (int i = 0; i < r->param.voice_count; i++) {
|
||||
ServerVoice *v = &r->voices[i];
|
||||
if (!v->in.in_use || v->state != SV_STARTED || !v->in.sample_rate || !v->valid[v->index]) continue;
|
||||
int cc = (int)v->in.channel_count; if (cc < 1 || cc > 6) { report_once(m, 2, "voice channel count unsupported", cc); continue; }
|
||||
const float vvol = by_category ? v->in.volume * category_volume(voice_category(v)) : v->in.volume;
|
||||
voice_render(r, v, vs, frames);
|
||||
for (int f = 0; f < 2; f++) if (v->in.biquads[f].enable) {
|
||||
const AudrenBiquad *b = &v->in.biquads[f];
|
||||
@@ -841,13 +1030,13 @@ void audio_mixer_render(AudioRenderer *r, double seconds) {
|
||||
SplitDest *d = &m->dest[s->ids[k]];
|
||||
if (!d->used || !mix_valid(r, d->dest)) continue;
|
||||
const float *source=splitter_filter(d,vs[c],filtered,frames);
|
||||
for (int b = 0; b < r->mixes[d->dest].buffer_count && b < 24; b++) accumulate(m, m->offset[d->dest] + b, source, d->vol[b] * v->in.volume, frames);
|
||||
for (int b = 0; b < r->mixes[d->dest].buffer_count && b < 24; b++) accumulate(m, m->offset[d->dest] + b, source, d->vol[b] * vvol, frames);
|
||||
}
|
||||
} else if (mix_valid(r, v->in.mix_id)) {
|
||||
for (int c = 0; c < cc; c++) {
|
||||
int32_t id = v->in.channel_ids[c]; if (id < 0 || id >= r->param.voice_count * 6) continue;
|
||||
const AudrenChannelIn *ch = &r->channels[id];
|
||||
for (int b = 0; b < r->mixes[v->in.mix_id].buffer_count && b < 24; b++) accumulate(m, m->offset[v->in.mix_id] + b, vs[c], ch->mix[b] * v->in.volume, frames);
|
||||
for (int b = 0; b < r->mixes[v->in.mix_id].buffer_count && b < 24; b++) accumulate(m, m->offset[v->in.mix_id] + b, vs[c], ch->mix[b] * vvol, frames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ static void voice_reset(ServerVoice *v) {
|
||||
v->loops_done = 0;
|
||||
memset(&v->adpcm, 0, sizeof v->adpcm);
|
||||
memset(v->biquad_state, 0, sizeof v->biquad_state);
|
||||
v->cat = 0;
|
||||
}
|
||||
|
||||
static void update_voice(AudioRenderer *r, const AudrenVoiceIn *in) {
|
||||
|
||||
@@ -145,6 +145,8 @@ typedef struct {
|
||||
uint32_t consumed, drops;
|
||||
struct { int16_t history[2]; int32_t buffer; uint64_t at; } adpcm; // DSP-ADPCM decode cursor (buffer slot, next sample) and history
|
||||
float biquad_state[2][6][2]; // filter, channel: transposed direct-form II delays
|
||||
uint64_t cat_address, cat_extra; // the wave buffer and coefficients voice_category (audio_mixer.c) last classified
|
||||
uint8_t cat; // their AUDIO_CAT_*, 0 until classified; voice_reset clears it
|
||||
} ServerVoice;
|
||||
enum { SV_STOPPED, SV_STARTED, SV_PAUSED, SV_STOPPING };
|
||||
|
||||
@@ -184,6 +186,10 @@ void audio_mixer_render(AudioRenderer *r, double seconds); // after audio_voic
|
||||
// many ns (the ring is at its target), -1 leaves the pace to the render thread's timer (no device, renderer stopped,
|
||||
// device stalled).
|
||||
int64_t audio_mixer_pace_ns(AudioRenderer *r, uint64_t now);
|
||||
// The playback devices SDL lists now, by name (TOTK_AUDIO_DEVICE takes one), at most max; 0 while SDL audio is not up
|
||||
// (TOTK_AUDIO=none). Any thread; the Sound tab of the menu lists them.
|
||||
enum { AUDIO_DEVICE_NAME_MAX = 256 };
|
||||
int audio_output_devices(char (*names)[AUDIO_DEVICE_NAME_MAX], int max);
|
||||
uint64_t audio_voice_consumed(const AudioRenderer *r, ServerVoice *v, int frames); // source samples over one frame; advances v->fraction
|
||||
int audio_buffer_empty(const AudrenWaveBuffer *b); // no samples to decode: played as soon as it is reached
|
||||
void audio_device_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs); // IAudioDevice
|
||||
+7
-3
@@ -22,7 +22,7 @@
|
||||
#include "nvn_api.h"
|
||||
#include "platform/platform.h"
|
||||
#include "vk.h"
|
||||
#include "platform/platform.h"
|
||||
#include "gameplay_tweaks.h"
|
||||
|
||||
#define SYM_INIT_START "_ZN2nn4init5StartEmmPFvvES2_S2_"
|
||||
// main: return addresses of nnMain's SetFocusHandlingMode call (1.1.0 and 1.2.1 from this port's analysis of main;
|
||||
@@ -101,8 +101,11 @@ static void cb_module_finis(Cpu *c) {
|
||||
// ---- checkpoints (host.h)
|
||||
static void stats_line(void) {
|
||||
RtStats s = rt_stats();
|
||||
rt_logf("boot: passed (%llu SVCs, %llu threads, %llu host calls)\n", (unsigned long long)s.svcs,
|
||||
(unsigned long long)s.threads, (unsigned long long)s.host_calls);
|
||||
if (rt_trace & (RT_TRACE_HOSTCALL | RT_TRACE_HOSTCOUNT)) // counted only then (hostfn.c hostfn_entry)
|
||||
rt_logf("boot: passed (%llu SVCs, %llu threads, %llu host calls)\n", (unsigned long long)s.svcs,
|
||||
(unsigned long long)s.threads, (unsigned long long)s.host_calls);
|
||||
else
|
||||
rt_logf("boot: passed (%llu SVCs, %llu threads)\n", (unsigned long long)s.svcs, (unsigned long long)s.threads);
|
||||
}
|
||||
|
||||
void rt_boot_event(const char *what, Cpu *c, const char *detail) {
|
||||
@@ -347,6 +350,7 @@ void rt_boot(void) {
|
||||
rt_patches_init();
|
||||
mods_exefs_switch(); // after the patch sets' settings: an enabled mod's ExeFS patches on
|
||||
frame_step_init();
|
||||
gameplay_tweaks_init();
|
||||
res_init();
|
||||
cheats_init(); // after the patch sets: a cheat's set follows its setting
|
||||
cb_addr[0] = hostfn_register("<rtld loader_ready>", cb_loader_ready);
|
||||
|
||||
+87
-28
@@ -32,35 +32,41 @@ 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", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"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",
|
||||
"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_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y",
|
||||
"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",
|
||||
"COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT",
|
||||
"DESC_TEMPLATE", "DESWIZZLE", "DEVICE_PROFILE", "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",
|
||||
"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",
|
||||
"FULLSCREEN", "FXAA", "GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "HDR", "HDR_GAME_NITS", "HDR_HUE",
|
||||
"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",
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MENU_LANG", "MENU_TEST",
|
||||
"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",
|
||||
"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", "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",
|
||||
"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",
|
||||
"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",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "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", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",
|
||||
"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_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR",
|
||||
"SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR",
|
||||
"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", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS",
|
||||
"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",
|
||||
"ZSTD_CHECK", "ZSTD_NATIVE",
|
||||
};
|
||||
@@ -73,23 +79,25 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
{"COLOR_PRESET", "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"}, {"FXAA", "display"},
|
||||
{"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"DLSS_CHAR_MASK", "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"}, {"CONTACT_SHADOWS", "display"},
|
||||
{"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"},
|
||||
{"TEX_HEAP_EXTRA_MB", "mods"},
|
||||
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
|
||||
{"VOLUME", "audio"}, {"AUDIO_CHANNELS", "audio"},
|
||||
{"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
|
||||
{"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"},
|
||||
{"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"}, {"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"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "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"},
|
||||
@@ -101,12 +109,20 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"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"}, {"TEX_MEMO", "performance"}, {"VB_USED", "performance"}, {"DESC_TEMPLATE", "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"},
|
||||
{"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"},
|
||||
{"GAMEPLAY_MAP_ZOOM", "gameplay tweaks"}, {"GAMEPLAY_MAP_ZOOM_SENSITIVITY", "gameplay tweaks"},
|
||||
{"GAMEPLAY_ROTATION_SENSITIVITY", "gameplay tweaks"}, {"GAMEPLAY_DISTANCE_SENSITIVITY", "gameplay tweaks"},
|
||||
{"GAMEPLAY_ITEM_SENSITIVITY", "gameplay tweaks"},
|
||||
{"GAMEPLAY_WEAPON_WHEEL", "gameplay tweaks"}, {"GAMEPLAY_WEAPON_SENSITIVITY", "gameplay tweaks"},
|
||||
};
|
||||
|
||||
// The settings the menu shows: the value in effect when the key is unset, and what the key accepts. The only place a
|
||||
@@ -124,7 +140,8 @@ static const CfgMeta metas[] = {
|
||||
{"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},
|
||||
{"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"FXAA", "1", "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},
|
||||
{"ANISO", "game", "game|2|4|8|16", RESTART}, // vk_texture.c sampler_features
|
||||
// colour adjustment (vk_color.c); the preset is the menu's, the four values are what the present uses
|
||||
@@ -133,11 +150,11 @@ static const CfgMeta metas[] = {
|
||||
{"COLOR_GAMMA", "1", "0.8..1.2", LIVE},
|
||||
// HDR output (vk_hdr.c): on at start (the tonemap shader is swapped as shaders load); the nits apply at once
|
||||
{"HDR", "0", "0|1", RESTART}, {"HDR_PEAK_NITS", "1000", "400..10000", LIVE}, {"HDR_GAME_NITS", "203", "80..500", LIVE},
|
||||
{"HDR_UI_NITS", "203", "80..500", LIVE}, {"HDR_HUE", "80", "0..100", LIVE},
|
||||
{"HDR_UI_NITS", "203", "80..500", LIVE}, {"HDR_HUE", "70", "0..100", LIVE},
|
||||
{"DEVICE_PROFILE", "auto", "auto|desktop|deck", RESTART},
|
||||
{"SHADOW_RES", "game", "game|256|512|768|1024|1536|2048", RESTART},
|
||||
{"SHADOW_SCALE", "1", "1..4", RESTART},
|
||||
{"SHADOW_RANGE", "100", "50..400", RESTART}, {"CONTACT_SHADOWS", "0", "0..100", RESTART},
|
||||
{"SHADOW_RANGE", "100", "50..400", RESTART}, {"GRASS_RANGE", "100", "50..400", RESTART}, {"CONTACT_SHADOWS", "0", "0..100", RESTART},
|
||||
{"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},
|
||||
@@ -148,16 +165,36 @@ static const CfgMeta metas[] = {
|
||||
{"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}, {"AUDIO_CHANNELS", "stereo", "auto|stereo|5.1", RESTART},
|
||||
{"MOTION", "1", "0|1", LIVE}, {"RUMBLE_STRENGTH", "130", "0..300", LIVE}, {"RUMBLE_CURVE", "0.6", "0.2..1.5", LIVE},
|
||||
{"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},
|
||||
{"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},
|
||||
{"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},
|
||||
{"MOUSE_SENS", "1", "0..10", LIVE}, {"MOUSE_AIM_SCALE", "1", "0.1..3", LIVE}, {"MENU_CURSOR", "1", "0|1", LIVE},
|
||||
{"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)
|
||||
{"WALK_KEY", "none", NULL, LIVE}, {"WALK_SCALE", "0.51", "0.2..0.9", 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},
|
||||
{"GAMEPLAY_ULTRAHAND_DISTANCE", "1", "0|1", LIVE}, {"GAMEPLAY_ITEM_WHEEL", "1", "0|1", LIVE},
|
||||
{"GAMEPLAY_ITEM_AD", "1", "0|1", LIVE}, {"GAMEPLAY_MAP_ZOOM", "1", "0|1", LIVE},
|
||||
{"GAMEPLAY_MAP_ZOOM_SENSITIVITY", "1", "0.25..4", LIVE}, {"GAMEPLAY_ROTATION_SENSITIVITY", "1", "0.25..4", LIVE},
|
||||
{"GAMEPLAY_DISTANCE_SENSITIVITY", "1", "0.25..4", LIVE}, {"GAMEPLAY_ITEM_SENSITIVITY", "1", "0.25..4", LIVE},
|
||||
{"GAMEPLAY_WEAPON_WHEEL", "1", "0|1", LIVE}, {"GAMEPLAY_WEAPON_SENSITIVITY", "1", "0.25..4", LIVE},
|
||||
{"MENU_LANG", "", "en|ru|pt-BR|zh-Hans", LIVE},
|
||||
// plat_font_path on Linux: 1 asks fontconfig which file draws the language, 0 keeps the fixed distribution
|
||||
// paths. A rebuild of the atlas reads it, so a change shows on the next window size or language switch.
|
||||
{"MENU_FONT_FONTCONFIG", "1", "0|1", LIVE},
|
||||
{"AMIIBO_DIR", "", NULL, LIVE},
|
||||
// Discord Rich Presence (discord_rpc.c): off by default, the Menu tab of the settings menu switches it.
|
||||
{"DISCORD_RPC", "0", "0|1", LIVE},
|
||||
@@ -178,9 +215,11 @@ static const CfgMeta metas[] = {
|
||||
{"ASTC", "auto", "auto|gpu|native|cpu", RESTART}, {"MEMORY", "auto", "auto|import|mirror|verify", RESTART},
|
||||
{"TEX_ALIAS", "1", "0|1", RESTART}, {"TEX_VRAM_PRESSURE", "90", "0..100", RESTART},
|
||||
{"TEX_RELEASED_MIB", "256", "0..65536", RESTART}, {"TEX_BLOCK_MIB", "64", "0..1024", RESTART}, {"VMA_BLOCK_MIB", "64", "0..1024", RESTART}, {"ASTC_BC", "", "0|1", RESTART}, {"ZSTD_NATIVE", "1", "0|1", RESTART}, {"ZSTD_CHECK", "0", "0|1", RESTART},
|
||||
// crash guards: code patch sets (recomp/patches-v*.txt) over game reads that crash on stale data
|
||||
{"OPTREF_GUARD", "1", "0|1", RESTART}, {"ABILITY_GUARD", "1", "0|1", RESTART}, {"REPORT_GUARD", "1", "0|1", RESTART},
|
||||
// render fixes
|
||||
{"LOD_GUARD", "1", "0|1", RESTART}, {"FIX_C0", "1", "0|1", RESTART}, {"FIX_ZERO", "1", "0|1", RESTART},
|
||||
{"BIND_SKIP", "1", "0|1", RESTART}, {"SHADER_MEMO", "1", "0|1", RESTART}, {"PIPE_MEMO", "1", "0|1", RESTART}, {"TEX_MEMO", "1", "0|1", RESTART},
|
||||
{"BIND_SKIP", "1", "0|1", RESTART}, {"SHADER_MEMO", "1", "0|1", RESTART}, {"PIPE_MEMO", "1", "0|1", RESTART}, {"MEMX", "1", "0|1|check", RESTART}, {"BIND_INC", "0", "0|1|check", RESTART}, {"TEX_MEMO", "1", "0|1", RESTART},
|
||||
{"VB_USED", "1", "0|1", RESTART},
|
||||
{"DESC_TEMPLATE", "1", "0|1", RESTART},
|
||||
{"PUSH_SKIP", "1", "0|1", RESTART}, {"SPLIT_DRAWS", "64", "0..1000", RESTART},
|
||||
@@ -344,16 +383,36 @@ 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 have a folder for each of these sizes (romfs-patches-xbox-<w>x<h>, -xbox-label-<w>x<h>,
|
||||
// -pc-<w>x<h>, installer/steps.py Prepare): they keep 1920x1080 only when the one for the display's size is missing,
|
||||
// as in a source build without make_romfs_patches.py --prompts <style> --aspect or an install by an older setup,
|
||||
// where a default of another shape would trade the prompts the player chose for the Switch ones.
|
||||
// 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
|
||||
// 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.
|
||||
static const unsigned SHAPED[][2] = {
|
||||
{2560, 1080}, {3440, 1440}, {3840, 1600}, {5120, 2160}, // 21:9
|
||||
{3840, 1080}, {5120, 1440}, // 32:9
|
||||
{1280, 800}, {1680, 1050}, {1920, 1200}, {2560, 1600}, // 16:10
|
||||
{1920, 1280}, {2160, 1440}, {2256, 1504}, {2880, 1920}, {3000, 2000}, // 3:2
|
||||
};
|
||||
|
||||
// The folder size of w x h's shape: of SHAPED within 1% of its aspect ratio, the closest, the first of equal ones
|
||||
// (5120x2160 takes 2560x1080). The UI layout depends on the aspect ratio alone (tools/ultrawide_layout.py apply), so
|
||||
// the setup writes one romfs-patches-<w>x<h> per shape, named after this size (installer/screens.py shape_size, the
|
||||
// same rule), and romfs.c overlay_init looks for it. 0 for 16:9 and for a shape without a layout.
|
||||
int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]) {
|
||||
if (!w || !h) return 0;
|
||||
double r = (double)w / h, err = 0;
|
||||
if (fabs(r / (16.0 / 9.0) - 1) <= 0.01) return 0;
|
||||
int best = -1;
|
||||
for (int i = 0; i < (int)(sizeof SHAPED / sizeof *SHAPED); i++) {
|
||||
double e = fabs((double)SHAPED[i][0] / SHAPED[i][1] / r - 1);
|
||||
if (e <= 0.01 && (best < 0 || e < err)) best = i, err = e;
|
||||
}
|
||||
if (best < 0) return 0;
|
||||
out[0] = SHAPED[best][0], out[1] = SHAPED[best][1];
|
||||
return 1;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -23,6 +23,9 @@ unsigned cfg_version(void);
|
||||
int cfg_from_env(const char *name);
|
||||
// 1 when the player set name (the environment or totk.ini), 0 when cfg_get gives a device profile's default or NULL.
|
||||
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 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).
|
||||
|
||||
@@ -339,6 +339,38 @@ int probe_cfg(void) {
|
||||
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");
|
||||
}
|
||||
// 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.
|
||||
unsigned sz[2] = {0, 0};
|
||||
CHECK(cfg_shape_size(5120, 2160, sz) && sz[0] == 2560 && sz[1] == 1080, "shape: 5120x2160 takes 2560x1080's folder");
|
||||
CHECK(cfg_shape_size(3440, 1440, sz) && sz[0] == 3440 && sz[1] == 1440, "shape: 3440x1440 keeps its own (0.8% off 2560x1080)");
|
||||
CHECK(cfg_shape_size(1920, 800, sz) && sz[0] == 3840 && sz[1] == 1600, "shape: 1920x800 takes 3840x1600's folder");
|
||||
CHECK(cfg_shape_size(2560, 1600, sz) && sz[0] == 1280 && sz[1] == 800 && cfg_shape_size(3000, 2000, sz) &&
|
||||
sz[0] == 1920 && sz[1] == 1280 && cfg_shape_size(5120, 1440, sz) && sz[0] == 3840 && sz[1] == 1080,
|
||||
"shape: 16:10, 3:2 and 32:9 take their first size");
|
||||
CHECK(!cfg_shape_size(1920, 1080, sz) && !cfg_shape_size(2560, 1440, sz) && !cfg_shape_size(1024, 768, sz),
|
||||
"shape: none for 16:9 and 4:3");
|
||||
// romfs.c shaped_name: the exact size's folder (an older setup wrote every size) wins, else the shape's
|
||||
{
|
||||
char dir[1100], f[1200];
|
||||
snprintf(dir, sizeof dir, "%.*scfg-probe-shapes", (int)(cut + 1 - path), path);
|
||||
static const char *const made[] = {"romfs-patches-2560x1080", "romfs-patches-xbox-5120x2160"};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s", dir, made[i]);
|
||||
plat_file_mkdir_p(f);
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, made[i]);
|
||||
plat_file_write(f, "#\n", 2);
|
||||
}
|
||||
snprintf(f, sizeof f, "%s/romfs-index.bin", dir);
|
||||
plat_setenv("TOTK_ROMFS_INDEX", f);
|
||||
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");
|
||||
plat_setenv("TOTK_ROMFS_INDEX", NULL);
|
||||
}
|
||||
uint8_t pd[PAD_COUNT] = {0};
|
||||
pd[PAD_SOUTH] = pd[PAD_NORTH] = 1;
|
||||
CHECK(input_map_pad_buttons(pd, PAD_LAYOUT_NINTENDO) == (1ull << B_B | 1ull << B_X) &&
|
||||
@@ -360,6 +392,14 @@ int probe_cfg(void) {
|
||||
input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_ZL] = 1}, PAD_LAYOUT_NINTENDO) == 1ull << B_ZL,
|
||||
"bind: pad:rpaddle1 adds a back paddle, pad:default keeps the trigger");
|
||||
input_map_reset();
|
||||
CHECK(input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_TOUCHPAD] = 1}, PAD_LAYOUT_NINTENDO) == 0 &&
|
||||
input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_TOUCHPAD] = 1}, PAD_LAYOUT_XBOX) == 0,
|
||||
"pad layout: the touchpad click is unbound by default");
|
||||
CHECK(input_map_bind("MINUS", "pad:default, pad:touchpad") &&
|
||||
input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_TOUCHPAD] = 1}, PAD_LAYOUT_XBOX) == 1ull << B_MINUS &&
|
||||
input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_BACK] = 1}, PAD_LAYOUT_XBOX) == 1ull << B_MINUS,
|
||||
"bind: pad:touchpad adds the touchpad click, pad:default keeps the button");
|
||||
input_map_reset();
|
||||
// Bind lines for stick directions and default parts; the remapping rows' edits (input_map.c)
|
||||
memset(dn, 0, sizeof dn);
|
||||
dn[KEY_I] = 1;
|
||||
|
||||
+4
-1
@@ -575,7 +575,10 @@ static void rebuild_if_needed(const char *dir) {
|
||||
int ok = plat_spawn(argv, dir);
|
||||
free(cmd);
|
||||
if (!ok) {
|
||||
rt_log("cheats: the rebuild did not start; the game starts with the code it has");
|
||||
// The skip key is for a rebuild that ran and failed or was cancelled. One that never started (a command whose
|
||||
// program is gone) leaves no key, so the next start and "Rebuild the game now" try it again.
|
||||
plat_fs_unlink(skip_path);
|
||||
rt_log("cheats: the rebuild did not start (%s); the game starts with the code it has", cmd_path);
|
||||
return;
|
||||
}
|
||||
prof_write(); // plat_exit runs no atexit handlers
|
||||
|
||||
+247
-148
@@ -1,156 +1,255 @@
|
||||
// Generated by tools/build_shaders.py from runtime/shaders/contact_shadow.comp; do not edit.
|
||||
// source sha256 b452a1920e59c4d83b2c994b0c6573cc1e479f7032a1310a7432d11c5c2e9908
|
||||
// source sha256 88275d28f96ea19281dbcd08a440ff79821716210894596ffb05ba7bc572dc9a
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
static const uint32_t contact_shadow_spv[] = {
|
||||
0x07230203, 0x00010300, 0x000d000b, 0x000001b1, 0x00000000, 0x00020011, 0x00000001, 0x00020011,
|
||||
0x07230203, 0x00010300, 0x000d000b, 0x000003e4, 0x00000000, 0x00020011, 0x00000001, 0x00020011,
|
||||
0x00000031, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
||||
0x00000000, 0x00000001, 0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x00000069,
|
||||
0x00060010, 0x00000004, 0x00000011, 0x00000008, 0x00000008, 0x00000001, 0x00030047, 0x00000027,
|
||||
0x00000002, 0x00050048, 0x00000027, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000027,
|
||||
0x00000001, 0x00000023, 0x00000010, 0x00050048, 0x00000027, 0x00000002, 0x00000023, 0x00000020,
|
||||
0x00050048, 0x00000027, 0x00000003, 0x00000023, 0x00000030, 0x00040047, 0x00000069, 0x0000000b,
|
||||
0x0000001c, 0x00040047, 0x00000088, 0x00000021, 0x00000000, 0x00040047, 0x00000088, 0x00000022,
|
||||
0x00000000, 0x00040047, 0x0000013f, 0x00000021, 0x00000001, 0x00040047, 0x0000013f, 0x00000022,
|
||||
0x00000000, 0x00040047, 0x0000015c, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021,
|
||||
0x00000000, 0x00000001, 0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x0000011f,
|
||||
0x00060010, 0x00000004, 0x00000011, 0x00000008, 0x00000008, 0x00000001, 0x00030047, 0x00000033,
|
||||
0x00000002, 0x00050048, 0x00000033, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000033,
|
||||
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,
|
||||
0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006,
|
||||
0x00000002, 0x00040017, 0x0000000a, 0x00000006, 0x00000003, 0x0004002b, 0x00000006, 0x0000001b,
|
||||
0x40000000, 0x0004002b, 0x00000006, 0x0000001d, 0x3f800000, 0x00040015, 0x00000020, 0x00000020,
|
||||
0x00000000, 0x0004002b, 0x00000020, 0x00000021, 0x00000000, 0x00040017, 0x00000026, 0x00000006,
|
||||
0x00000004, 0x0006001e, 0x00000027, 0x00000026, 0x00000026, 0x00000026, 0x00000026, 0x00040020,
|
||||
0x00000028, 0x00000009, 0x00000027, 0x0004003b, 0x00000028, 0x00000029, 0x00000009, 0x00040015,
|
||||
0x0000002a, 0x00000020, 0x00000001, 0x0004002b, 0x0000002a, 0x0000002b, 0x00000000, 0x00040020,
|
||||
0x0000002c, 0x00000009, 0x00000006, 0x0004002b, 0x00000020, 0x00000030, 0x00000001, 0x0004002b,
|
||||
0x00000020, 0x0000003f, 0x00000002, 0x0004002b, 0x00000006, 0x00000043, 0x3f000000, 0x0004002b,
|
||||
0x00000006, 0x00000059, 0x4253ee82, 0x0004002b, 0x00000006, 0x0000005b, 0x3d897143, 0x0004002b,
|
||||
0x00000006, 0x0000005c, 0x3bbf4590, 0x0005002c, 0x00000007, 0x0000005d, 0x0000005b, 0x0000005c,
|
||||
0x00040017, 0x00000064, 0x0000002a, 0x00000002, 0x00040017, 0x00000067, 0x00000020, 0x00000003,
|
||||
0x00040020, 0x00000068, 0x00000001, 0x00000067, 0x0004003b, 0x00000068, 0x00000069, 0x00000001,
|
||||
0x00040017, 0x0000006a, 0x00000020, 0x00000002, 0x00020014, 0x0000006e, 0x0004002b, 0x0000002a,
|
||||
0x00000072, 0x00000002, 0x00090019, 0x00000085, 0x00000006, 0x00000001, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000001, 0x00000000, 0x0003001b, 0x00000086, 0x00000085, 0x00040020, 0x00000087,
|
||||
0x00000000, 0x00000086, 0x0004003b, 0x00000087, 0x00000088, 0x00000000, 0x0004002b, 0x00000006,
|
||||
0x0000008f, 0x00000000, 0x0004002b, 0x00000006, 0x00000092, 0x3f7fbe77, 0x0004002b, 0x00000006,
|
||||
0x0000009e, 0x42a00000, 0x00040020, 0x000000a8, 0x00000009, 0x00000026, 0x0004002b, 0x0000002a,
|
||||
0x000000b4, 0x00000001, 0x0004002b, 0x00000020, 0x000000b5, 0x00000003, 0x0004002b, 0x00000006,
|
||||
0x000000bb, 0x3ecccccd, 0x0004002b, 0x00000006, 0x000000bc, 0x40400000, 0x0004002b, 0x00000006,
|
||||
0x000000c0, 0x3e19999a, 0x0004002b, 0x00000006, 0x000000c2, 0x3c23d70a, 0x0004002b, 0x00000006,
|
||||
0x000000cb, 0x3e800000, 0x0004002b, 0x0000002a, 0x000000da, 0x00000010, 0x0004002b, 0x00000006,
|
||||
0x000000e6, 0xbd4ccccd, 0x0005002c, 0x00000007, 0x000000f0, 0x0000008f, 0x0000008f, 0x00040017,
|
||||
0x000000f1, 0x0000006e, 0x00000002, 0x0005002c, 0x00000007, 0x000000f8, 0x0000001d, 0x0000001d,
|
||||
0x0004002b, 0x00000006, 0x00000114, 0x3ca3d70a, 0x0004002b, 0x00000006, 0x00000116, 0x3b03126f,
|
||||
0x0004002b, 0x00000006, 0x0000012b, 0x42200000, 0x0004002b, 0x0000002a, 0x00000137, 0x00000003,
|
||||
0x00090019, 0x0000013d, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
|
||||
0x00000008, 0x00040020, 0x0000013e, 0x00000000, 0x0000013d, 0x0004003b, 0x0000013e, 0x0000013f,
|
||||
0x00000000, 0x0004002b, 0x00000020, 0x0000015b, 0x00000008, 0x0006002c, 0x00000067, 0x0000015c,
|
||||
0x0000015b, 0x0000015b, 0x00000030, 0x0005002c, 0x00000007, 0x000001ad, 0x00000043, 0x00000043,
|
||||
0x0004002b, 0x00000006, 0x000001af, 0x3dcccccd, 0x0004002b, 0x00000006, 0x000001b0, 0x3d800000,
|
||||
0x00000002, 0x00040017, 0x0000000a, 0x00000006, 0x00000003, 0x00040015, 0x00000019, 0x00000020,
|
||||
0x00000001, 0x00040017, 0x0000001a, 0x00000019, 0x00000002, 0x0004002b, 0x00000006, 0x00000027,
|
||||
0x40000000, 0x0004002b, 0x00000006, 0x00000029, 0x3f800000, 0x00040015, 0x0000002c, 0x00000020,
|
||||
0x00000000, 0x0004002b, 0x0000002c, 0x0000002d, 0x00000000, 0x00040017, 0x00000032, 0x00000006,
|
||||
0x00000004, 0x0006001e, 0x00000033, 0x00000032, 0x00000032, 0x00000032, 0x00000032, 0x00040020,
|
||||
0x00000034, 0x00000009, 0x00000033, 0x0004003b, 0x00000034, 0x00000035, 0x00000009, 0x0004002b,
|
||||
0x00000019, 0x00000036, 0x00000000, 0x00040020, 0x00000037, 0x00000009, 0x00000006, 0x0004002b,
|
||||
0x0000002c, 0x0000003b, 0x00000001, 0x0004002b, 0x0000002c, 0x0000004a, 0x00000002, 0x0004002b,
|
||||
0x00000006, 0x0000004e, 0x3f000000, 0x0004002b, 0x00000006, 0x00000064, 0x4253ee82, 0x0004002b,
|
||||
0x00000006, 0x00000066, 0x3d897143, 0x0004002b, 0x00000006, 0x00000067, 0x3bbf4590, 0x0005002c,
|
||||
0x00000007, 0x00000068, 0x00000066, 0x00000067, 0x0005002c, 0x0000001a, 0x00000070, 0x00000036,
|
||||
0x00000036, 0x0004002b, 0x00000019, 0x00000071, 0x00000002, 0x00040020, 0x00000072, 0x00000009,
|
||||
0x00000032, 0x0004002b, 0x00000019, 0x00000077, 0x00000001, 0x00090019, 0x00000083, 0x00000006,
|
||||
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x0003001b, 0x00000084,
|
||||
0x00000083, 0x00040020, 0x00000085, 0x00000000, 0x00000084, 0x0004003b, 0x00000085, 0x00000086,
|
||||
0x00000000, 0x0005002c, 0x0000001a, 0x0000009d, 0x00000077, 0x00000036, 0x0005002c, 0x0000001a,
|
||||
0x000000a8, 0x00000036, 0x00000077, 0x00020014, 0x000000b1, 0x0004002b, 0x00000006, 0x00000110,
|
||||
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,
|
||||
0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x000300f7,
|
||||
0x0000015d, 0x00000000, 0x000300fb, 0x00000021, 0x0000015e, 0x000200f8, 0x0000015e, 0x0004003d,
|
||||
0x00000067, 0x0000006b, 0x00000069, 0x0007004f, 0x0000006a, 0x0000006c, 0x0000006b, 0x0000006b,
|
||||
0x00000000, 0x00000001, 0x0004007c, 0x00000064, 0x0000006d, 0x0000006c, 0x00050051, 0x0000002a,
|
||||
0x00000071, 0x0000006d, 0x00000000, 0x00060041, 0x0000002c, 0x00000073, 0x00000029, 0x00000072,
|
||||
0x00000021, 0x0004003d, 0x00000006, 0x00000074, 0x00000073, 0x0004006e, 0x0000002a, 0x00000075,
|
||||
0x00000074, 0x000500af, 0x0000006e, 0x00000076, 0x00000071, 0x00000075, 0x000400a8, 0x0000006e,
|
||||
0x00000077, 0x00000076, 0x000300f7, 0x00000079, 0x00000000, 0x000400fa, 0x00000077, 0x00000078,
|
||||
0x00000079, 0x000200f8, 0x00000078, 0x00050051, 0x0000002a, 0x0000007b, 0x0000006d, 0x00000001,
|
||||
0x00060041, 0x0000002c, 0x0000007c, 0x00000029, 0x00000072, 0x00000030, 0x0004003d, 0x00000006,
|
||||
0x0000007d, 0x0000007c, 0x0004006e, 0x0000002a, 0x0000007e, 0x0000007d, 0x000500af, 0x0000006e,
|
||||
0x0000007f, 0x0000007b, 0x0000007e, 0x000200f9, 0x00000079, 0x000200f8, 0x00000079, 0x000700f5,
|
||||
0x0000006e, 0x00000080, 0x00000076, 0x0000015e, 0x0000007f, 0x00000078, 0x000300f7, 0x00000082,
|
||||
0x00000000, 0x000400fa, 0x00000080, 0x00000081, 0x00000082, 0x000200f8, 0x00000081, 0x000200f9,
|
||||
0x0000015d, 0x000200f8, 0x00000082, 0x0004003d, 0x00000086, 0x00000089, 0x00000088, 0x00040064,
|
||||
0x00000085, 0x0000008b, 0x00000089, 0x0007005f, 0x00000026, 0x0000008c, 0x0000008b, 0x0000006d,
|
||||
0x00000002, 0x0000002b, 0x00050051, 0x00000006, 0x0000008d, 0x0000008c, 0x00000000, 0x000500bc,
|
||||
0x0000006e, 0x00000090, 0x0000008d, 0x0000008f, 0x000500be, 0x0000006e, 0x00000093, 0x0000008d,
|
||||
0x00000092, 0x000500a6, 0x0000006e, 0x00000094, 0x00000090, 0x00000093, 0x000300f7, 0x00000096,
|
||||
0x00000000, 0x000400fa, 0x00000094, 0x00000095, 0x00000096, 0x000200f8, 0x00000095, 0x000200f9,
|
||||
0x0000015d, 0x000200f8, 0x00000096, 0x00060041, 0x0000002c, 0x0000009a, 0x00000029, 0x0000002b,
|
||||
0x0000003f, 0x0004003d, 0x00000006, 0x0000009b, 0x0000009a, 0x00050085, 0x00000006, 0x0000009c,
|
||||
0x0000008d, 0x0000009b, 0x000500ba, 0x0000006e, 0x0000009f, 0x0000009c, 0x0000009e, 0x000300f7,
|
||||
0x000000a1, 0x00000000, 0x000400fa, 0x0000009f, 0x000000a0, 0x000000a1, 0x000200f8, 0x000000a0,
|
||||
0x000200f9, 0x0000015d, 0x000200f8, 0x000000a1, 0x0004006f, 0x00000007, 0x000000a5, 0x0000006d,
|
||||
0x00050081, 0x00000007, 0x000000a7, 0x000000a5, 0x000001ad, 0x00050041, 0x000000a8, 0x000000a9,
|
||||
0x00000029, 0x00000072, 0x0004003d, 0x00000026, 0x000000aa, 0x000000a9, 0x0007004f, 0x00000007,
|
||||
0x000000ab, 0x000000aa, 0x000000aa, 0x00000002, 0x00000003, 0x00050085, 0x00000007, 0x000000ac,
|
||||
0x000000a7, 0x000000ab, 0x0005008e, 0x00000007, 0x00000167, 0x000000ac, 0x0000001b, 0x00050083,
|
||||
0x00000007, 0x00000169, 0x00000167, 0x000000f8, 0x00050051, 0x00000006, 0x0000016b, 0x00000169,
|
||||
0x00000000, 0x00050085, 0x00000006, 0x0000016d, 0x0000016b, 0x0000009c, 0x00060041, 0x0000002c,
|
||||
0x0000016e, 0x00000029, 0x0000002b, 0x00000021, 0x0004003d, 0x00000006, 0x0000016f, 0x0000016e,
|
||||
0x00050088, 0x00000006, 0x00000170, 0x0000016d, 0x0000016f, 0x00050051, 0x00000006, 0x00000172,
|
||||
0x00000169, 0x00000001, 0x0004007f, 0x00000006, 0x00000173, 0x00000172, 0x00050085, 0x00000006,
|
||||
0x00000175, 0x00000173, 0x0000009c, 0x00060041, 0x0000002c, 0x00000176, 0x00000029, 0x0000002b,
|
||||
0x00000030, 0x0004003d, 0x00000006, 0x00000177, 0x00000176, 0x00050088, 0x00000006, 0x00000178,
|
||||
0x00000175, 0x00000177, 0x0004007f, 0x00000006, 0x0000017a, 0x0000009c, 0x00060050, 0x0000000a,
|
||||
0x0000017b, 0x00000170, 0x00000178, 0x0000017a, 0x00060041, 0x0000002c, 0x000000b6, 0x00000029,
|
||||
0x000000b4, 0x000000b5, 0x0004003d, 0x00000006, 0x000000b7, 0x000000b6, 0x00050085, 0x00000006,
|
||||
0x000000ba, 0x0000009c, 0x000001af, 0x0008000c, 0x00000006, 0x000000bd, 0x00000001, 0x0000002b,
|
||||
0x000000ba, 0x000000bb, 0x000000bc, 0x00050085, 0x00000006, 0x000000be, 0x000000b7, 0x000000bd,
|
||||
0x00050085, 0x00000006, 0x000000c3, 0x0000009c, 0x000000c2, 0x00050081, 0x00000006, 0x000000c4,
|
||||
0x000000c0, 0x000000c3, 0x00050085, 0x00000006, 0x000000c8, 0x000000be, 0x000001b0, 0x00050094,
|
||||
0x00000006, 0x0000017f, 0x000000a5, 0x0000005d, 0x0006000c, 0x00000006, 0x00000180, 0x00000001,
|
||||
0x0000000a, 0x0000017f, 0x00050085, 0x00000006, 0x00000181, 0x00000059, 0x00000180, 0x0006000c,
|
||||
0x00000006, 0x00000182, 0x00000001, 0x0000000a, 0x00000181, 0x00050081, 0x00000006, 0x000000d0,
|
||||
0x000000cb, 0x00000182, 0x00050085, 0x00000006, 0x000000d1, 0x000000c8, 0x000000d0, 0x000200f9,
|
||||
0x000000d4, 0x000200f8, 0x000000d4, 0x000700f5, 0x00000006, 0x000001a7, 0x000000d1, 0x000000a1,
|
||||
0x00000129, 0x000000d7, 0x000700f5, 0x0000002a, 0x000001a6, 0x0000002b, 0x000000a1, 0x00000126,
|
||||
0x000000d7, 0x000500b1, 0x0000006e, 0x000000db, 0x000001a6, 0x000000da, 0x000400f6, 0x000000d6,
|
||||
0x000000d7, 0x00000000, 0x000400fa, 0x000000db, 0x000000d5, 0x000000d6, 0x000200f8, 0x000000d5,
|
||||
0x00050041, 0x000000a8, 0x000000de, 0x00000029, 0x000000b4, 0x0004003d, 0x00000026, 0x000000df,
|
||||
0x000000de, 0x0008004f, 0x0000000a, 0x000000e0, 0x000000df, 0x000000df, 0x00000000, 0x00000001,
|
||||
0x00000002, 0x0005008e, 0x0000000a, 0x000000e2, 0x000000e0, 0x000001a7, 0x00050081, 0x0000000a,
|
||||
0x000000e3, 0x0000017b, 0x000000e2, 0x00050051, 0x00000006, 0x000000e5, 0x000000e3, 0x00000002,
|
||||
0x000500be, 0x0000006e, 0x000000e7, 0x000000e5, 0x000000e6, 0x000300f7, 0x000000e9, 0x00000000,
|
||||
0x000400fa, 0x000000e7, 0x000000e8, 0x000000e9, 0x000200f8, 0x000000e8, 0x000200f9, 0x000000d6,
|
||||
0x000200f8, 0x000000e9, 0x0004007f, 0x00000006, 0x00000188, 0x000000e5, 0x00050051, 0x00000006,
|
||||
0x0000018a, 0x000000e3, 0x00000000, 0x00050085, 0x00000006, 0x0000018b, 0x00000043, 0x0000018a,
|
||||
0x00050085, 0x00000006, 0x0000018e, 0x0000018b, 0x0000016f, 0x00050088, 0x00000006, 0x00000190,
|
||||
0x0000018e, 0x00000188, 0x00050081, 0x00000006, 0x00000191, 0x00000043, 0x00000190, 0x00050051,
|
||||
0x00000006, 0x00000193, 0x000000e3, 0x00000001, 0x00050085, 0x00000006, 0x00000194, 0x00000043,
|
||||
0x00000193, 0x00050085, 0x00000006, 0x00000197, 0x00000194, 0x00000177, 0x00050088, 0x00000006,
|
||||
0x00000199, 0x00000197, 0x00000188, 0x00050083, 0x00000006, 0x0000019a, 0x00000043, 0x00000199,
|
||||
0x00050050, 0x00000007, 0x0000019b, 0x00000191, 0x0000019a, 0x000500b8, 0x000000f1, 0x000000f2,
|
||||
0x0000019b, 0x000000f0, 0x0004009a, 0x0000006e, 0x000000f3, 0x000000f2, 0x000400a8, 0x0000006e,
|
||||
0x000000f4, 0x000000f3, 0x000300f7, 0x000000f6, 0x00000000, 0x000400fa, 0x000000f4, 0x000000f5,
|
||||
0x000000f6, 0x000200f8, 0x000000f5, 0x000500ba, 0x000000f1, 0x000000f9, 0x0000019b, 0x000000f8,
|
||||
0x0004009a, 0x0000006e, 0x000000fa, 0x000000f9, 0x000200f9, 0x000000f6, 0x000200f8, 0x000000f6,
|
||||
0x000700f5, 0x0000006e, 0x000000fb, 0x000000f3, 0x000000e9, 0x000000fa, 0x000000f5, 0x000300f7,
|
||||
0x000000fd, 0x00000000, 0x000400fa, 0x000000fb, 0x000000fc, 0x000000fd, 0x000200f8, 0x000000fc,
|
||||
0x000200f9, 0x000000d6, 0x000200f8, 0x000000fd, 0x0004003d, 0x00000086, 0x00000100, 0x00000088,
|
||||
0x0007004f, 0x00000007, 0x00000104, 0x000000aa, 0x000000aa, 0x00000000, 0x00000001, 0x00050085,
|
||||
0x00000007, 0x00000105, 0x0000019b, 0x00000104, 0x0004006e, 0x00000064, 0x00000106, 0x00000105,
|
||||
0x00040064, 0x00000085, 0x00000107, 0x00000100, 0x0007005f, 0x00000026, 0x00000108, 0x00000107,
|
||||
0x00000106, 0x00000002, 0x0000002b, 0x00050051, 0x00000006, 0x00000109, 0x00000108, 0x00000000,
|
||||
0x00050085, 0x00000006, 0x0000010c, 0x00000109, 0x0000009b, 0x00050083, 0x00000006, 0x00000112,
|
||||
0x00000188, 0x0000010c, 0x00050085, 0x00000006, 0x00000117, 0x0000009c, 0x00000116, 0x00050081,
|
||||
0x00000006, 0x00000118, 0x00000114, 0x00000117, 0x000500ba, 0x0000006e, 0x00000119, 0x00000112,
|
||||
0x00000118, 0x000500b8, 0x0000006e, 0x0000011c, 0x00000112, 0x000000c4, 0x000500a7, 0x0000006e,
|
||||
0x0000011d, 0x00000119, 0x0000011c, 0x000300f7, 0x0000011f, 0x00000000, 0x000400fa, 0x0000011d,
|
||||
0x0000011e, 0x0000011f, 0x000200f8, 0x0000011e, 0x0004006f, 0x00000006, 0x00000121, 0x000001a6,
|
||||
0x00050085, 0x00000006, 0x00000122, 0x00000121, 0x000001b0, 0x00050083, 0x00000006, 0x00000123,
|
||||
0x0000001d, 0x00000122, 0x000200f9, 0x000000d6, 0x000200f8, 0x0000011f, 0x000200f9, 0x000000d7,
|
||||
0x000200f8, 0x000000d7, 0x00050080, 0x0000002a, 0x00000126, 0x000001a6, 0x000000b4, 0x00050081,
|
||||
0x00000006, 0x00000129, 0x000001a7, 0x000000c8, 0x000200f9, 0x000000d4, 0x000200f8, 0x000000d6,
|
||||
0x000b00f5, 0x00000006, 0x000001aa, 0x0000008f, 0x000000d4, 0x0000008f, 0x000000e8, 0x0000008f,
|
||||
0x000000fc, 0x00000123, 0x0000011e, 0x0008000c, 0x00000006, 0x0000012d, 0x00000001, 0x00000031,
|
||||
0x0000012b, 0x0000009e, 0x0000009c, 0x00050083, 0x00000006, 0x0000012e, 0x0000001d, 0x0000012d,
|
||||
0x00060041, 0x0000002c, 0x00000130, 0x00000029, 0x0000002b, 0x000000b5, 0x0004003d, 0x00000006,
|
||||
0x00000131, 0x00000130, 0x00050085, 0x00000006, 0x00000133, 0x00000131, 0x000001aa, 0x00050085,
|
||||
0x00000006, 0x00000135, 0x00000133, 0x0000012e, 0x00050083, 0x00000006, 0x00000136, 0x0000001d,
|
||||
0x00000135, 0x00060041, 0x0000002c, 0x00000138, 0x00000029, 0x00000137, 0x00000021, 0x0004003d,
|
||||
0x00000006, 0x00000139, 0x00000138, 0x000500ba, 0x0000006e, 0x0000013a, 0x00000139, 0x00000043,
|
||||
0x000300f7, 0x0000013c, 0x00000000, 0x000400fa, 0x0000013a, 0x0000013b, 0x0000013c, 0x000200f8,
|
||||
0x0000013b, 0x0004003d, 0x0000013d, 0x00000140, 0x0000013f, 0x00070050, 0x00000026, 0x00000143,
|
||||
0x00000136, 0x00000136, 0x00000136, 0x0000001d, 0x00040063, 0x00000140, 0x0000006d, 0x00000143,
|
||||
0x000200f9, 0x0000015d, 0x000200f8, 0x0000013c, 0x000500be, 0x0000006e, 0x00000146, 0x00000136,
|
||||
0x00000092, 0x000300f7, 0x00000148, 0x00000000, 0x000400fa, 0x00000146, 0x00000147, 0x00000148,
|
||||
0x000200f8, 0x00000147, 0x000200f9, 0x0000015d, 0x000200f8, 0x00000148, 0x0004003d, 0x0000013d,
|
||||
0x0000014c, 0x0000013f, 0x00050062, 0x00000026, 0x0000014e, 0x0000014c, 0x0000006d, 0x0004003d,
|
||||
0x0000013d, 0x0000014f, 0x0000013f, 0x0008004f, 0x0000000a, 0x00000152, 0x0000014e, 0x0000014e,
|
||||
0x00000000, 0x00000001, 0x00000002, 0x0005008e, 0x0000000a, 0x00000154, 0x00000152, 0x00000136,
|
||||
0x00050051, 0x00000006, 0x00000156, 0x0000014e, 0x00000003, 0x00050051, 0x00000006, 0x00000157,
|
||||
0x00000154, 0x00000000, 0x00050051, 0x00000006, 0x00000158, 0x00000154, 0x00000001, 0x00050051,
|
||||
0x00000006, 0x00000159, 0x00000154, 0x00000002, 0x00070050, 0x00000026, 0x0000015a, 0x00000157,
|
||||
0x00000158, 0x00000159, 0x00000156, 0x00040063, 0x0000014f, 0x0000006d, 0x0000015a, 0x000200f9,
|
||||
0x0000015d, 0x000200f8, 0x0000015d, 0x000100fd, 0x00010038,
|
||||
0x0000021d, 0x00000000, 0x000300fb, 0x0000002d, 0x0000021e, 0x000200f8, 0x0000021e, 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,
|
||||
0x0000002d, 0x0004003d, 0x00000006, 0x00000127, 0x00000126, 0x0004006e, 0x00000019, 0x00000128,
|
||||
0x00000127, 0x000500af, 0x000000b1, 0x00000129, 0x00000125, 0x00000128, 0x000400a8, 0x000000b1,
|
||||
0x0000012a, 0x00000129, 0x000300f7, 0x0000012c, 0x00000000, 0x000400fa, 0x0000012a, 0x0000012b,
|
||||
0x0000012c, 0x000200f8, 0x0000012b, 0x00050051, 0x00000019, 0x0000012e, 0x00000123, 0x00000001,
|
||||
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,
|
||||
0x00000000, 0x000400fa, 0x00000133, 0x00000134, 0x00000135, 0x000200f8, 0x00000134, 0x000200f9,
|
||||
0x0000021d, 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,
|
||||
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,
|
||||
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,
|
||||
0x000100fd, 0x00010038,
|
||||
};
|
||||
+32
-4
@@ -18,7 +18,11 @@ typedef struct __attribute__((aligned(16))) Cpu {
|
||||
uint64_t fpcr; // 320: guest FPCR/FPSR (portable FP/SIMD lowering only; the asm path uses the host's)
|
||||
uint64_t fpsr; // 328
|
||||
uint64_t excl_val_hi; // 336: upper half of a 128-bit exclusive pair (LDXP/LDAXP of two X registers)
|
||||
uint8_t _pad[512 - 344];
|
||||
uint64_t _pad0; // 344
|
||||
float fp_th_s[4]; // 352: FP result check threshold, every lane (rt_fpcr_threshold, runtime/simd_fp.h FOKT)
|
||||
double fp_th_d[2]; // 368
|
||||
__uint128_t fp_arg[3]; // 384: operands of a vector FP op handed to its slow path (runtime/simd_fp.h FN(vredo))
|
||||
uint8_t _pad[512 - 432];
|
||||
__uint128_t v[32]; // 512
|
||||
} Cpu;
|
||||
|
||||
@@ -27,6 +31,8 @@ _Static_assert(offsetof(Cpu, pc) == 264, "pc");
|
||||
_Static_assert(offsetof(Cpu, nzcv) == 272, "nzcv");
|
||||
_Static_assert(offsetof(Cpu, fpcr) == 320, "fpcr");
|
||||
_Static_assert(offsetof(Cpu, fpsr) == 328, "fpsr");
|
||||
_Static_assert(offsetof(Cpu, fp_th_s) == 352 && offsetof(Cpu, fp_th_d) == 368, "fp_th");
|
||||
_Static_assert(offsetof(Cpu, fp_arg) == 384, "fp_arg");
|
||||
_Static_assert(offsetof(Cpu, v) == 512, "v");
|
||||
|
||||
typedef void (*GuestFn)(Cpu *);
|
||||
@@ -39,12 +45,24 @@ void rt_brk(Cpu *c, uint32_t imm, uint64_t pc) __attribute__((noreturn));
|
||||
void rt_udf(Cpu *c, uint64_t pc) __attribute__((noreturn));
|
||||
uint64_t rt_ticks(void);
|
||||
|
||||
// The FP fast paths of runtime/simd_fp.h test FPCR.RMode and the result in one compare: a result is good when its
|
||||
// magnitude differs from c->fp_th_*. In round-to-nearest the threshold is the smallest normal, so NaN and +-smallest
|
||||
// normal fail as before; under a directed RMode it is NaN, both compares are unordered and every result goes through
|
||||
// the redo path, which rounds in the FPCR mode. It must follow every change of c->fpcr: rt_fpcr_sync sets it, and so
|
||||
// does code that creates a Cpu or copies fpcr into one. A zeroed threshold is wrong, not merely slow: it passes
|
||||
// +-smallest normal.
|
||||
static inline void rt_fpcr_threshold(Cpu *c) {
|
||||
int directed = (c->fpcr & (3u << 22)) != 0;
|
||||
for (int i = 0; i < 4; i++) c->fp_th_s[i] = directed ? __builtin_nanf("") : 0x1p-126f;
|
||||
for (int i = 0; i < 2; i++) c->fp_th_d[i] = directed ? __builtin_nan("") : 0x1p-1022;
|
||||
}
|
||||
|
||||
#if defined(__aarch64__)
|
||||
static inline uint64_t rt_get_fpcr(void) { uint64_t v; __asm__ volatile("mrs %0, fpcr" : "=r"(v)); return v; }
|
||||
static inline uint64_t rt_get_fpsr(void) { uint64_t v; __asm__ volatile("mrs %0, fpsr" : "=r"(v)); return v; }
|
||||
static inline void rt_set_fpcr(uint64_t v) { __asm__ volatile("msr fpcr, %0" :: "r"(v)); }
|
||||
static inline void rt_set_fpsr(uint64_t v) { __asm__ volatile("msr fpsr, %0" :: "r"(v)); }
|
||||
static inline void rt_fpcr_sync(const Cpu *c) { (void)c; }
|
||||
static inline void rt_fpcr_sync(Cpu *c) { rt_fpcr_threshold(c); }
|
||||
#else
|
||||
// Host FP state is not the guest's here: code lifted with --simd=c keeps FPCR/FPSR in Cpu (c->fpcr, zeroed
|
||||
// with the Cpu), so the host-side reset in thread start-up has nothing to do.
|
||||
@@ -56,12 +74,20 @@ static inline void rt_set_fpsr(uint64_t v) { (void)v; }
|
||||
// the slow paths of runtime/simd.h, which switch RC around one operation). The FP helpers rely on it without checking,
|
||||
// so it is set wherever FPCR or the host FP context changes: MSR FPCR (recomp/lifter.py), rt_call (thread and fiber
|
||||
// entry, host code calling guest code), fiber resume (runtime/kernel.c fiber_resumed; fibers keep their own MXCSR).
|
||||
static inline void rt_fpcr_sync(const Cpu *c) {
|
||||
// It also sets the FP result check threshold (rt_fpcr_threshold).
|
||||
static inline void rt_fpcr_sync(Cpu *c) {
|
||||
rt_fpcr_threshold(c);
|
||||
unsigned cur = __builtin_ia32_stmxcsr();
|
||||
unsigned want = (cur & ~0xE040u) | (c->fpcr & (1u << 24) ? 0x8040u : 0); // FTZ 0x8000, DAZ 0x40, RC 0x6000
|
||||
if (cur != want) __builtin_ia32_ldmxcsr(want);
|
||||
}
|
||||
#endif
|
||||
// MSR FPCR (recomp/lifter.py): the first guest write of a directed rounding mode (FPCR.RMode, bits 22-23) is logged
|
||||
// once with the caller (main.c rt_fpcr_rmode), to learn whether the game ever leaves round-to-nearest. A test of the
|
||||
// value just stored, at the MSR sites only.
|
||||
void rt_fpcr_rmode(uint64_t fpcr, uint64_t lr);
|
||||
#define RT_FPCR_NOTE(c, lr) \
|
||||
do { if (__builtin_expect((c)->fpcr & (3ull << 22), 0)) rt_fpcr_rmode((c)->fpcr, lr); } while (0)
|
||||
|
||||
// ---- memory: guest addresses are host addresses
|
||||
typedef uint16_t __attribute__((aligned(1), may_alias)) u16u;
|
||||
@@ -69,7 +95,9 @@ typedef uint32_t __attribute__((aligned(1), may_alias)) u32u;
|
||||
typedef uint64_t __attribute__((aligned(1), may_alias)) u64u;
|
||||
typedef uint8_t __attribute__((may_alias)) u8a;
|
||||
|
||||
// Function-entry profiler (runtime/fnprof.c, LARECOMP_FNPROF): one predictable branch per call when off.
|
||||
// Function-entry hook: one predictable branch per call while g_fnprof is 0. The generator emits it only in the
|
||||
// functions of the patch table's `hook` lines (recomp/patches.py), or in every function for a table without any and
|
||||
// with gen.py --fn-enter-all.
|
||||
extern volatile int g_fnprof;
|
||||
void fnprof_hit(uint64_t addr, uint64_t lr, uint64_t x0);
|
||||
#define FN_ENTER(a) do { if (__builtin_expect(g_fnprof, 0)) fnprof_hit(a, c->x[30], c->x[0]); } while (0)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// The mouse pointer's image in the game window while the cursor is not captured (the game's menus, the settings menu):
|
||||
// a gold arrowhead with a notched back, a dark outline, a turquoise gem and a soft shadow, drawn here at the size the
|
||||
// window's DPI asks for instead of the Windows arrow. input_win.c and input_sdl.c make the system cursor from it.
|
||||
// Nothing comes from the game's files.
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "input_wsys.h"
|
||||
|
||||
typedef struct { float x, y; } V;
|
||||
|
||||
// In units of a 32-pixel cursor: the tip at the top left (the hotspot), the wings to the right and below, the notch
|
||||
// between them
|
||||
static const V SHAPE[] = {{1.5f, 1.5f}, {25.0f, 10.5f}, {14.5f, 14.5f}, {10.5f, 25.0f}};
|
||||
static const V GEM[] = {{10.4f, 7.6f}, {13.0f, 10.2f}, {10.4f, 12.8f}, {7.8f, 10.2f}};
|
||||
#define OUTLINE 1.7f // the dark edge's width
|
||||
#define SHADOW 1.6f // the shadow's offset to the bottom right
|
||||
|
||||
static float seg_dist(V p, V a, V b) {
|
||||
float dx = b.x - a.x, dy = b.y - a.y, t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy);
|
||||
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
||||
float ex = a.x + t * dx - p.x, ey = a.y + t * dy - p.y;
|
||||
return sqrtf(ex * ex + ey * ey);
|
||||
}
|
||||
|
||||
// Distance to the polygon's edge, negative inside (even-odd: the shapes are simple)
|
||||
static float poly_sdf(V p, const V *v, int n) {
|
||||
float d = 1e9f;
|
||||
int in = 0;
|
||||
for (int i = 0, j = n - 1; i < n; j = i++) {
|
||||
float e = seg_dist(p, v[j], v[i]);
|
||||
if (e < d) d = e;
|
||||
if ((v[i].y > p.y) != (v[j].y > p.y) && p.x < (v[j].x - v[i].x) * (p.y - v[i].y) / (v[j].y - v[i].y) + v[i].x)
|
||||
in = !in;
|
||||
}
|
||||
return in ? -d : d;
|
||||
}
|
||||
|
||||
// One sample's colour (straight r, g, b in 0..1) and coverage
|
||||
static float sample(V p, float *r, float *g, float *b) {
|
||||
float d = poly_sdf(p, SHAPE, 4);
|
||||
if (d < 0) {
|
||||
if (-d < OUTLINE) { *r = 0.17f, *g = 0.11f, *b = 0.04f; return 1; }
|
||||
if (poly_sdf(p, GEM, 4) < 0) { // the gem, lighter towards its top left
|
||||
float t = (p.x + p.y - 20.4f) / 5.2f + 0.5f;
|
||||
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
||||
*r = 0.62f - 0.42f * t, *g = 0.98f - 0.22f * t, *b = 0.92f - 0.12f * t;
|
||||
return 1;
|
||||
}
|
||||
// gold, pale at the tip and deeper at the wings; a thin light line inside the outline
|
||||
float t = (p.x + p.y) / 34.0f;
|
||||
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
||||
float rim = -d < OUTLINE + 1.0f ? 0.12f : 0;
|
||||
*r = fminf(1, 1.00f - 0.12f * t + rim), *g = fminf(1, 0.93f - 0.32f * t + rim),
|
||||
*b = fminf(1, 0.70f - 0.52f * t + rim);
|
||||
return 1;
|
||||
}
|
||||
V s = {p.x - SHADOW, p.y - SHADOW};
|
||||
float ds = poly_sdf(s, SHAPE, 4);
|
||||
if (ds < 0.8f) { // the shadow, soft at its edge
|
||||
*r = *g = *b = 0;
|
||||
float a = ds < -0.8f ? 1 : (0.8f - ds) / 1.6f;
|
||||
return 0.38f * a;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cursor_art(uint32_t *argb, int size, int *hot) {
|
||||
float k = 32.0f / (float)size;
|
||||
enum { SS = 4 }; // 4 x 4 samples a pixel
|
||||
for (int y = 0; y < size; y++)
|
||||
for (int x = 0; x < size; x++) {
|
||||
float r = 0, g = 0, b = 0, a = 0;
|
||||
for (int sy = 0; sy < SS; sy++)
|
||||
for (int sx = 0; sx < SS; sx++) {
|
||||
V p = {(x + (sx + 0.5f) / SS) * k, (y + (sy + 0.5f) / SS) * k};
|
||||
float sr, sg, sb, c = sample(p, &sr, &sg, &sb);
|
||||
r += sr * c, g += sg * c, b += sb * c, a += c;
|
||||
}
|
||||
uint32_t px = 0;
|
||||
if (a > 0) { // straight alpha, as Windows and SDL take it
|
||||
r /= a, g /= a, b /= a, a /= SS * SS;
|
||||
px = (uint32_t)lrintf(a * 255) << 24 | (uint32_t)lrintf(r * 255) << 16 |
|
||||
(uint32_t)lrintf(g * 255) << 8 | (uint32_t)lrintf(b * 255);
|
||||
}
|
||||
argb[y * size + x] = px;
|
||||
}
|
||||
*hot = (int)(1.5f / k);
|
||||
}
|
||||
@@ -47,6 +47,14 @@ 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);
|
||||
// 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_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
|
||||
|
||||
@@ -1770,6 +1770,7 @@ int probe_fs(void) {
|
||||
pcpu = plat_aligned_alloc(sizeof(Cpu), 64);
|
||||
need(pcpu != NULL, "probe Cpu");
|
||||
memset(pcpu, 0, sizeof *pcpu);
|
||||
rt_fpcr_threshold(pcpu);
|
||||
uint8_t *stack = mem_kernel_alloc(0x10000, 16);
|
||||
pcpu->sp = (uint64_t)(uintptr_t)stack + 0x10000;
|
||||
pcpu->excl_addr = ~0ull;
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
// Mouse wheel and keyboard gameplay tweaks with independent live settings.
|
||||
// The game's native R + D-pad object rotation and D-pad distance controls remain authoritative.
|
||||
#include "gameplay_tweaks.h"
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "input_map.h"
|
||||
#include "input_wsys.h"
|
||||
#include "platform/platform.h"
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BIT(x) (1ull << (x))
|
||||
#define HOLD_FRAMES 3
|
||||
#define GAP_FRAMES 1
|
||||
#define MAX_QUEUED 16
|
||||
enum { NONE, ROTATE, DISTANCE, ITEMS, MAP_ZOOM, WEAPONS };
|
||||
enum { W_IDLE = 0, W_PRIME, W_HOLD, W_GAP, W_WAIT };
|
||||
#define WEAPON_PRIME_MIN_NS 75000000ull
|
||||
#define WEAPON_PRIME_MAX_NS 135000000ull
|
||||
#define WEAPON_HOLD_NS 42000000ull
|
||||
#define WEAPON_GAP_NS 36000000ull
|
||||
|
||||
static PlatMutex lock = PLAT_MUTEX_INIT;
|
||||
static unsigned seen = UINT_MAX;
|
||||
static struct {
|
||||
int available, rotate, c_axis, distance, wheel, keys, map_zoom, weapon_wheel;
|
||||
double rotation_speed, distance_speed, item_speed, map_zoom_speed, weapon_speed;
|
||||
} options;
|
||||
static struct {
|
||||
int kind, axis, direction, queued, hold, gap, primed, valid;
|
||||
double fraction;
|
||||
uint64_t frame, buttons;
|
||||
int32_t rx;
|
||||
} pulse;
|
||||
static struct {
|
||||
int active, phase, direction, scroll_dir, queued, polls_in_phase;
|
||||
int confirm_pending;
|
||||
double fraction;
|
||||
uint64_t phase_until_ns, prime_start_ns, last_frame;
|
||||
int32_t rx;
|
||||
} weapon;
|
||||
static double map_zoom_velocity;
|
||||
static int held_a, held_d;
|
||||
static int consumed_c, consumed_right;
|
||||
static int was_e_down, consumed_e;
|
||||
static uint64_t physical_buttons;
|
||||
|
||||
static void clear_weapon_locked(void) { memset(&weapon, 0, sizeof weapon); }
|
||||
static void clear_locked(void) { memset(&pulse, 0, sizeof pulse); clear_weapon_locked(); map_zoom_velocity = 0; }
|
||||
|
||||
static void refresh_locked(void) {
|
||||
unsigned version = cfg_version();
|
||||
if (seen == version) return;
|
||||
options.available = cfg_bool("TOTK_GAMEPLAY_TWEAKS_ENABLED");
|
||||
options.rotate = cfg_bool("TOTK_GAMEPLAY_ULTRAHAND_ROTATE");
|
||||
options.c_axis = cfg_bool("TOTK_GAMEPLAY_ULTRAHAND_C_AXIS");
|
||||
options.distance = cfg_bool("TOTK_GAMEPLAY_ULTRAHAND_DISTANCE");
|
||||
options.wheel = cfg_bool("TOTK_GAMEPLAY_ITEM_WHEEL");
|
||||
options.keys = cfg_bool("TOTK_GAMEPLAY_ITEM_AD");
|
||||
options.map_zoom = cfg_bool("TOTK_GAMEPLAY_MAP_ZOOM");
|
||||
options.weapon_wheel = cfg_bool("TOTK_GAMEPLAY_WEAPON_WHEEL");
|
||||
options.rotation_speed = cfg_double("TOTK_GAMEPLAY_ROTATION_SENSITIVITY");
|
||||
options.distance_speed = cfg_double("TOTK_GAMEPLAY_DISTANCE_SENSITIVITY");
|
||||
options.item_speed = cfg_double("TOTK_GAMEPLAY_ITEM_SENSITIVITY");
|
||||
options.map_zoom_speed = cfg_double("TOTK_GAMEPLAY_MAP_ZOOM_SENSITIVITY");
|
||||
options.weapon_speed = cfg_double("TOTK_GAMEPLAY_WEAPON_SENSITIVITY");
|
||||
if (!isfinite(options.rotation_speed) || options.rotation_speed < .25 || options.rotation_speed > 4) options.rotation_speed = 1;
|
||||
if (!isfinite(options.distance_speed) || options.distance_speed < .25 || options.distance_speed > 4) options.distance_speed = 1;
|
||||
if (!isfinite(options.item_speed) || options.item_speed < .25 || options.item_speed > 4) options.item_speed = 1;
|
||||
if (!isfinite(options.map_zoom_speed) || options.map_zoom_speed < .25 || options.map_zoom_speed > 4) options.map_zoom_speed = 1;
|
||||
if (!isfinite(options.weapon_speed) || options.weapon_speed < .25 || options.weapon_speed > 4) options.weapon_speed = 1;
|
||||
seen = version;
|
||||
clear_locked();
|
||||
}
|
||||
|
||||
static int item_menu(uint64_t buttons) {
|
||||
if (buttons & BIT(B_L)) return 0;
|
||||
const uint64_t held = BIT(B_LEFT) | BIT(B_UP) | BIT(B_RIGHT) | BIT(B_DOWN);
|
||||
return input_camera_context() == INPUT_CAM_MENU_WHEEL || (buttons & held) != 0;
|
||||
}
|
||||
|
||||
static int object_context(uint64_t buttons) {
|
||||
const uint64_t menus = BIT(B_L) | BIT(B_LEFT) | BIT(B_UP) | BIT(B_RIGHT) | BIT(B_DOWN) |
|
||||
BIT(B_B) | BIT(B_PLUS) | BIT(B_MINUS);
|
||||
return input_camera_context() == INPUT_CAM_ULTRAHAND_OBJECT && !(buttons & menus);
|
||||
}
|
||||
|
||||
static int map_zoom_allowed(uint64_t buttons) {
|
||||
if (!options.map_zoom) return 0;
|
||||
if (object_context(buttons) || item_menu(buttons)) return 0;
|
||||
if (buttons & (BIT(B_L) | BIT(B_ZL) | BIT(B_ZR) | BIT(B_R))) return 0;
|
||||
int ctx = input_camera_context();
|
||||
if (ctx == INPUT_CAM_AIM || ctx == INPUT_CAM_SCOPE ||
|
||||
ctx == INPUT_CAM_ULTRAHAND_OBJECT || ctx == INPUT_CAM_LOCK_ON) {
|
||||
return 0;
|
||||
}
|
||||
// Only the map menu_cursor.c finds: with menu_cursor = 0 (or on 1.2.1) the map is not read, and a fallback to
|
||||
// "allowed" would push the right stick's Y in free roam, where it tilts the camera.
|
||||
return menu_cursor_map();
|
||||
}
|
||||
|
||||
static int weapon_wheel_allowed(uint64_t buttons, int right_down, int already_active) {
|
||||
if (!options.available || !options.weapon_wheel) return 0;
|
||||
if (right_down) return 0;
|
||||
if (!ikb_captured() || menu_cursor_map() || menu_cursor_pointer()) return 0;
|
||||
const uint64_t forbidden = BIT(B_L) | BIT(B_R) | BIT(B_ZL) | BIT(B_ZR) |
|
||||
BIT(B_LEFT) | BIT(B_UP) | BIT(B_RIGHT) | BIT(B_DOWN) |
|
||||
BIT(B_PLUS) | BIT(B_MINUS);
|
||||
if (buttons & forbidden) return 0;
|
||||
|
||||
if (!already_active) {
|
||||
if (menu_cursor_shortcut() == 1 || menu_cursor_strip() || menu_cursor_camera() || menu_cursor_menu())
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ctx = input_camera_context();
|
||||
if (!already_active) {
|
||||
// Opening needs a camera the mouse_direct hooks saw this moment: an unclassified one is also a paused menu,
|
||||
// 1.2.1's menus or any screen menu_cursor.c does not read, where D-pad right and the right stick would move
|
||||
// the menu instead.
|
||||
if (ctx != INPUT_CAM_FREE_ROAM && ctx != INPUT_CAM_LOCK_ON && ctx != INPUT_CAM_VEHICLE)
|
||||
return 0;
|
||||
} else {
|
||||
if (ctx != INPUT_CAM_UNCLASSIFIED && ctx != INPUT_CAM_MENU_WHEEL &&
|
||||
ctx != INPUT_CAM_FREE_ROAM && ctx != INPUT_CAM_LOCK_ON && ctx != INPUT_CAM_VEHICLE)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int gameplay_tweaks_available(void) {
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
int available = options.available;
|
||||
plat_mutex_unlock(&lock);
|
||||
return available;
|
||||
}
|
||||
|
||||
int gameplay_tweaks_capture_needed(void) {
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
int active = options.available && (options.rotate || options.distance || options.wheel ||
|
||||
options.keys || options.map_zoom || options.weapon_wheel);
|
||||
plat_mutex_unlock(&lock);
|
||||
return active;
|
||||
}
|
||||
|
||||
int gameplay_tweaks_map_zoom(void) {
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
int active = options.available && options.map_zoom;
|
||||
plat_mutex_unlock(&lock);
|
||||
return active;
|
||||
}
|
||||
|
||||
int gameplay_tweaks_strip_wheel(uint64_t buttons) {
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
int active = options.available && (weapon.active || (options.wheel && item_menu(buttons)));
|
||||
plat_mutex_unlock(&lock);
|
||||
return active;
|
||||
}
|
||||
|
||||
void gameplay_tweaks_init(void) {
|
||||
gameplay_tweaks_available();
|
||||
}
|
||||
|
||||
void gameplay_tweaks_reset(void) {
|
||||
plat_mutex_lock(&lock);
|
||||
clear_locked();
|
||||
held_a = held_d = 0;
|
||||
physical_buttons = 0;
|
||||
was_e_down = consumed_e = 0;
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
void gameplay_tweaks_wheel(double delta, int c_down, int right_down) {
|
||||
if (!isfinite(delta) || delta == 0) return;
|
||||
if (delta > MAX_QUEUED) delta = MAX_QUEUED;
|
||||
if (delta < -MAX_QUEUED) delta = -MAX_QUEUED;
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
if (!options.available) {
|
||||
clear_locked();
|
||||
plat_mutex_unlock(&lock);
|
||||
return;
|
||||
}
|
||||
int kind = NONE, axis = 0;
|
||||
double sensitivity = 1;
|
||||
if (object_context(physical_buttons)) {
|
||||
if (right_down && options.distance) {
|
||||
kind = DISTANCE;
|
||||
sensitivity = options.distance_speed;
|
||||
} else if (options.rotate) {
|
||||
kind = ROTATE;
|
||||
axis = options.c_axis && c_down;
|
||||
sensitivity = options.rotation_speed;
|
||||
}
|
||||
} else if ((physical_buttons & (BIT(B_LEFT) | BIT(B_UP) | BIT(B_RIGHT) | BIT(B_DOWN))) &&
|
||||
options.wheel && item_menu(physical_buttons)) {
|
||||
kind = ITEMS;
|
||||
sensitivity = options.item_speed;
|
||||
} else if (map_zoom_allowed(physical_buttons)) {
|
||||
kind = MAP_ZOOM;
|
||||
sensitivity = options.map_zoom_speed;
|
||||
} else if (weapon_wheel_allowed(physical_buttons, right_down, weapon.active)) {
|
||||
kind = WEAPONS;
|
||||
}
|
||||
if (!kind) {
|
||||
clear_locked();
|
||||
plat_mutex_unlock(&lock);
|
||||
return;
|
||||
}
|
||||
if (kind == MAP_ZOOM) {
|
||||
if (weapon.active) clear_weapon_locked();
|
||||
map_zoom_velocity -= delta * sensitivity * 16000.0;
|
||||
if (map_zoom_velocity > 65536.0) map_zoom_velocity = 65536.0;
|
||||
if (map_zoom_velocity < -65536.0) map_zoom_velocity = -65536.0;
|
||||
plat_mutex_unlock(&lock);
|
||||
return;
|
||||
}
|
||||
if (kind == WEAPONS) {
|
||||
uint64_t now = plat_now_ns();
|
||||
int new_dir = delta > 0 ? 1 : -1;
|
||||
if (weapon.scroll_dir != 0 && new_dir != weapon.scroll_dir) {
|
||||
weapon.fraction = 0;
|
||||
weapon.queued = 0;
|
||||
if (weapon.active && weapon.phase == W_HOLD) {
|
||||
weapon.phase = W_GAP;
|
||||
weapon.rx = 0;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.phase_until_ns = now + WEAPON_GAP_NS;
|
||||
}
|
||||
}
|
||||
weapon.scroll_dir = new_dir;
|
||||
weapon.fraction += delta * options.weapon_speed;
|
||||
int steps = (int)trunc(weapon.fraction);
|
||||
if (steps != 0) {
|
||||
weapon.confirm_pending = 0;
|
||||
weapon.fraction -= steps;
|
||||
weapon.direction = steps > 0 ? 1 : -1;
|
||||
weapon.queued += (steps > 0 ? steps : -steps);
|
||||
if (weapon.queued > MAX_QUEUED) weapon.queued = MAX_QUEUED;
|
||||
if (!weapon.active) {
|
||||
weapon.active = 1;
|
||||
weapon.phase = W_PRIME;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.prime_start_ns = now;
|
||||
weapon.phase_until_ns = now + WEAPON_PRIME_MAX_NS;
|
||||
weapon.rx = 0;
|
||||
} else if (weapon.phase == W_WAIT) {
|
||||
weapon.phase = W_HOLD;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.phase_until_ns = now + WEAPON_HOLD_NS;
|
||||
weapon.rx = 32767 * weapon.direction;
|
||||
if (weapon.queued > 0) weapon.queued--;
|
||||
}
|
||||
}
|
||||
plat_mutex_unlock(&lock);
|
||||
return;
|
||||
}
|
||||
if (weapon.active) clear_weapon_locked();
|
||||
if (kind != pulse.kind || axis != pulse.axis ||
|
||||
(delta > 0 && pulse.direction < 0) || (delta < 0 && pulse.direction > 0)) {
|
||||
clear_locked();
|
||||
}
|
||||
pulse.kind = kind;
|
||||
pulse.axis = axis;
|
||||
pulse.fraction += delta * sensitivity;
|
||||
int steps = (int)trunc(pulse.fraction);
|
||||
if (steps) {
|
||||
pulse.fraction -= steps;
|
||||
pulse.direction = steps > 0 ? 1 : -1;
|
||||
if (!pulse.queued && !pulse.hold && !pulse.gap) pulse.valid = 0;
|
||||
pulse.queued += steps > 0 ? steps : -steps;
|
||||
if (pulse.queued > MAX_QUEUED) pulse.queued = MAX_QUEUED;
|
||||
}
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
void gameplay_tweaks_prepare_keys(uint8_t *down, uint64_t pad_buttons) {
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
held_a = held_d = 0;
|
||||
int c = down[KEY_C], right = down[KEY_MOUSE_R];
|
||||
int e = down[KEY_E];
|
||||
int e_pressed = e && !was_e_down;
|
||||
was_e_down = e;
|
||||
if (!e) consumed_e = 0;
|
||||
if (!c) consumed_c = 0;
|
||||
if (!right) consumed_right = 0;
|
||||
if (options.available) {
|
||||
if (input_camera_context() == INPUT_CAM_ULTRAHAND_OBJECT) {
|
||||
if (options.rotate && options.c_axis && !(options.distance && right) && c) consumed_c = 1;
|
||||
if (options.distance && right) consumed_right = 1;
|
||||
if (pulse.kind == ROTATE && pulse.axis != (options.c_axis && c)) clear_locked();
|
||||
}
|
||||
if (weapon.active && e_pressed) {
|
||||
consumed_e = 1;
|
||||
weapon.confirm_pending = 1;
|
||||
}
|
||||
if (consumed_e) down[KEY_E] = 0;
|
||||
if (consumed_c) down[KEY_C] = 0;
|
||||
if (consumed_right) down[KEY_MOUSE_R] = 0;
|
||||
uint64_t buttons = pad_buttons | input_map_buttons(down);
|
||||
if (options.keys && item_menu(buttons) && !weapon.active) {
|
||||
held_a = down[KEY_A];
|
||||
held_d = down[KEY_D];
|
||||
down[KEY_A] = down[KEY_D] = 0;
|
||||
}
|
||||
} else {
|
||||
consumed_c = consumed_right = consumed_e = 0;
|
||||
}
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
static void sample_locked(uint64_t frame) {
|
||||
if (pulse.valid && pulse.frame == frame) return;
|
||||
pulse.buttons = 0;
|
||||
pulse.rx = 0;
|
||||
if (pulse.queued || pulse.hold || pulse.gap) {
|
||||
if (pulse.kind == ROTATE) pulse.buttons = BIT(B_R);
|
||||
if (pulse.kind == ROTATE && !pulse.primed) pulse.primed = 1;
|
||||
else if (pulse.gap) pulse.gap--;
|
||||
else {
|
||||
if (!pulse.hold && pulse.queued) {
|
||||
pulse.queued--;
|
||||
pulse.hold = HOLD_FRAMES;
|
||||
}
|
||||
if (pulse.hold) {
|
||||
if (pulse.kind == ROTATE)
|
||||
pulse.buttons |= pulse.axis ? (pulse.direction > 0 ? BIT(B_DOWN) : BIT(B_UP)) :
|
||||
(pulse.direction > 0 ? BIT(B_RIGHT) : BIT(B_LEFT));
|
||||
else if (pulse.kind == DISTANCE)
|
||||
pulse.buttons = pulse.direction < 0 ? BIT(B_UP) : BIT(B_DOWN);
|
||||
else pulse.rx = 32767 * pulse.direction;
|
||||
if (!--pulse.hold) pulse.gap = GAP_FRAMES;
|
||||
}
|
||||
}
|
||||
} else pulse.primed = 0;
|
||||
pulse.valid = 1;
|
||||
pulse.frame = frame;
|
||||
}
|
||||
|
||||
void gameplay_tweaks_apply(uint64_t frame, int active, uint64_t *buttons,
|
||||
int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
(void)lx;
|
||||
(void)ly;
|
||||
plat_mutex_lock(&lock);
|
||||
refresh_locked();
|
||||
physical_buttons = *buttons;
|
||||
if (!active || !options.available) {
|
||||
clear_locked();
|
||||
held_a = held_d = 0;
|
||||
plat_mutex_unlock(&lock);
|
||||
return;
|
||||
}
|
||||
int right = ikb_down(KEY_MOUSE_R);
|
||||
|
||||
if (weapon.active) {
|
||||
if (!weapon_wheel_allowed(physical_buttons, right, 1) || (physical_buttons & BIT(B_B))) {
|
||||
clear_weapon_locked();
|
||||
}
|
||||
}
|
||||
|
||||
if (weapon.active) {
|
||||
uint64_t now = plat_now_ns();
|
||||
if (weapon.last_frame != frame) {
|
||||
weapon.last_frame = frame;
|
||||
weapon.polls_in_phase++;
|
||||
}
|
||||
|
||||
switch (weapon.phase) {
|
||||
case W_PRIME: {
|
||||
uint64_t elapsed = now - weapon.prime_start_ns;
|
||||
int shortcut = (menu_cursor_shortcut() == 1);
|
||||
int ready = (elapsed >= WEAPON_PRIME_MIN_NS && weapon.polls_in_phase >= 3 && shortcut) ||
|
||||
(elapsed >= WEAPON_PRIME_MAX_NS && weapon.polls_in_phase >= 4);
|
||||
if (ready) {
|
||||
if (weapon.queued > 0) {
|
||||
weapon.phase = W_HOLD;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.phase_until_ns = now + WEAPON_HOLD_NS;
|
||||
weapon.rx = 32767 * weapon.direction;
|
||||
weapon.queued--;
|
||||
} else if (weapon.confirm_pending) {
|
||||
clear_weapon_locked();
|
||||
} else {
|
||||
weapon.phase = W_WAIT;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.rx = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case W_HOLD: {
|
||||
if (now >= weapon.phase_until_ns && weapon.polls_in_phase >= 2) {
|
||||
weapon.phase = W_GAP;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.phase_until_ns = now + WEAPON_GAP_NS;
|
||||
weapon.rx = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case W_GAP: {
|
||||
if (now >= weapon.phase_until_ns && weapon.polls_in_phase >= 2) {
|
||||
if (weapon.queued > 0) {
|
||||
weapon.phase = W_HOLD;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.phase_until_ns = now + WEAPON_HOLD_NS;
|
||||
weapon.rx = 32767 * weapon.direction;
|
||||
weapon.queued--;
|
||||
} else if (weapon.confirm_pending) {
|
||||
clear_weapon_locked();
|
||||
} else {
|
||||
weapon.phase = W_WAIT;
|
||||
weapon.polls_in_phase = 0;
|
||||
weapon.rx = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case W_WAIT: {
|
||||
if (weapon.confirm_pending) {
|
||||
clear_weapon_locked();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
clear_weapon_locked();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (weapon.active) {
|
||||
*buttons |= BIT(B_RIGHT);
|
||||
*rx = weapon.rx;
|
||||
*ry = 0;
|
||||
} else {
|
||||
int object = object_context(*buttons), items = item_menu(*buttons);
|
||||
if ((pulse.kind == ROTATE && (!object || !options.rotate || (right && options.distance))) ||
|
||||
(pulse.kind == DISTANCE && (!object || !right || !options.distance)) ||
|
||||
(pulse.kind == ITEMS && (!items || !options.wheel))) {
|
||||
clear_locked();
|
||||
}
|
||||
sample_locked(frame);
|
||||
if (!map_zoom_allowed(*buttons)) {
|
||||
map_zoom_velocity = 0;
|
||||
} else if (fabs(map_zoom_velocity) > 50.0) {
|
||||
int32_t stick_y = (int32_t)map_zoom_velocity;
|
||||
if (stick_y > 32767) stick_y = 32767;
|
||||
if (stick_y < -32767) stick_y = -32767;
|
||||
if (abs(stick_y) > abs(*ry)) *ry = stick_y;
|
||||
map_zoom_velocity *= 0.78;
|
||||
if (fabs(map_zoom_velocity) < 100.0) map_zoom_velocity = 0;
|
||||
}
|
||||
if (pulse.kind == ROTATE || pulse.kind == DISTANCE) {
|
||||
*buttons |= pulse.buttons;
|
||||
// Distance D-pad pulses do not own the look stick. R rotation does,
|
||||
// because the game's rotation mode would otherwise rotate both axes.
|
||||
if (pulse.kind == ROTATE && pulse.buttons) *rx = *ry = 0;
|
||||
} else if (pulse.kind == ITEMS && (pulse.queued || pulse.hold || pulse.gap || pulse.rx)) {
|
||||
*rx = pulse.rx;
|
||||
*ry = 0;
|
||||
} else if (items && options.keys && (held_a || held_d)) {
|
||||
*rx = ((held_d != 0) - (held_a != 0)) * 32767;
|
||||
*ry = 0;
|
||||
}
|
||||
}
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Mouse wheel and keyboard gameplay tweaks: Ultrahand rotation and distance, item and weapon wheel, map zoom.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
int gameplay_tweaks_available(void);
|
||||
int gameplay_tweaks_capture_needed(void);
|
||||
int gameplay_tweaks_map_zoom(void);
|
||||
int gameplay_tweaks_strip_wheel(uint64_t buttons);
|
||||
void gameplay_tweaks_init(void);
|
||||
void gameplay_tweaks_reset(void);
|
||||
void gameplay_tweaks_wheel(double delta, int c_down, int right_down);
|
||||
void gameplay_tweaks_prepare_keys(uint8_t *down, uint64_t pad_buttons);
|
||||
void gameplay_tweaks_apply(uint64_t frame, int active, uint64_t *buttons,
|
||||
int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
|
||||
@@ -24,6 +24,12 @@ uint64_t gfx_vsync_time_ns(uint64_t tick); // kern_now_ns() time
|
||||
double gfx_window_refresh_hz(void); // refresh rate of the window's monitor; 0 unknown
|
||||
int gfx_window_focused(void);
|
||||
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
|
||||
// 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)
|
||||
uint64_t vk_reflex_frame_begin(void); // SIMULATION_START: the new frame's present ID
|
||||
uint64_t vk_reflex_frame(void); // the ID of the frame the game simulates now
|
||||
void vk_reflex_sleep(void); // before SIMULATION_START: the driver's latency sleep
|
||||
|
||||
// ---- shader service client (gfx_shader.c)
|
||||
enum { GFX_STAGE_VS, GFX_STAGE_TCS, GFX_STAGE_TES, GFX_STAGE_GS, GFX_STAGE_FS, GFX_STAGE_CS };
|
||||
|
||||
+214
-3
@@ -239,6 +239,8 @@ unsigned gfx_window_focus_messages(void) { return (unsigned)g_focus_msgs; }
|
||||
|
||||
// Present path (g_pl held): a settings change (cfg_version) reaches the window thread, which applies a changed size or
|
||||
// fullscreen; a changed TOTK_VK_PRESENT rebuilds the swapchain at this present.
|
||||
static void reflex_apply_locked(void);
|
||||
|
||||
static void window_settings_live(void) {
|
||||
static unsigned seen;
|
||||
static int started;
|
||||
@@ -254,9 +256,185 @@ static void window_settings_live(void) {
|
||||
if (started) plat_xchg32(&g_dirty, 1);
|
||||
}
|
||||
if (started) gfx_window_apply_settings();
|
||||
reflex_apply_locked();
|
||||
started = 1;
|
||||
}
|
||||
|
||||
// ---- NVIDIA Reflex Low Latency (VK_NV_low_latency2)
|
||||
static PFN_vkSetLatencySleepModeNV g_reflex_set_mode;
|
||||
static PFN_vkLatencySleepNV g_reflex_sleep;
|
||||
static PFN_vkSetLatencyMarkerNV g_reflex_marker;
|
||||
static VkSemaphore g_reflex_sem;
|
||||
static uint64_t g_reflex_val;
|
||||
// Present IDs (VK_KHR_present_id, VK_NV_low_latency2): each frame gets its ID once, when the game acquires its window
|
||||
// texture (SIMULATION_START, vk_reflex_frame_begin), and the frame carries it to its input sample, its submissions
|
||||
// (vk_reflex_submit_id: the game thread's current frame, or the frame a replay or present thread set for the work it
|
||||
// does) and its present (PresentJob.pid, vk_reflex_present_frame, flip_locked), so the driver can match every marker
|
||||
// of a frame to the present of that frame.
|
||||
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_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;
|
||||
|
||||
static int reflex_mode_from_cfg(void) {
|
||||
const char *v = cfg_value("TOTK_REFLEX");
|
||||
if (!v || !strcmp(v, "off") || !strcmp(v, "0")) return 0;
|
||||
if (!strcmp(v, "boost") || !strcmp(v, "2")) return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void reflex_apply_locked(void) {
|
||||
VkCtx *c = vk_ctx();
|
||||
if (!c || !c->has_nv_reflex || !g_sc) return;
|
||||
if (!g_reflex_set_mode) {
|
||||
g_reflex_set_mode = (PFN_vkSetLatencySleepModeNV)vkGetDeviceProcAddr(c->device, "vkSetLatencySleepModeNV");
|
||||
g_reflex_sleep = (PFN_vkLatencySleepNV)vkGetDeviceProcAddr(c->device, "vkLatencySleepNV");
|
||||
g_reflex_marker = (PFN_vkSetLatencyMarkerNV)vkGetDeviceProcAddr(c->device, "vkSetLatencyMarkerNV");
|
||||
}
|
||||
if (!g_reflex_set_mode) return;
|
||||
if (!g_reflex_sem) {
|
||||
VkSemaphoreTypeCreateInfo ti = {
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO,
|
||||
.semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE,
|
||||
.initialValue = 0
|
||||
};
|
||||
VkSemaphoreCreateInfo si = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, .pNext = &ti};
|
||||
if (vkCreateSemaphore(c->device, &si, NULL, &g_reflex_sem) != VK_SUCCESS) return;
|
||||
}
|
||||
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);
|
||||
if (mode == g_reflex_mode && min_us == g_reflex_min_us) return;
|
||||
g_reflex_mode = mode;
|
||||
g_reflex_min_us = min_us;
|
||||
VkLatencySleepModeInfoNV mi = {
|
||||
.sType = VK_STRUCTURE_TYPE_LATENCY_SLEEP_MODE_INFO_NV,
|
||||
.lowLatencyMode = mode > 0 ? VK_TRUE : VK_FALSE,
|
||||
.lowLatencyBoost = mode == 2 ? VK_TRUE : VK_FALSE,
|
||||
.minimumIntervalUs = min_us
|
||||
};
|
||||
VkResult r = g_reflex_set_mode(c->device, g_sc, &mi);
|
||||
rt_log("REFLEX: NVIDIA Reflex Low Latency -> %s (minInterval=%u us, VK_NV_low_latency2=%s)",
|
||||
mode == 2 ? "ON + BOOST" : mode == 1 ? "ON" : "OFF", min_us, r == VK_SUCCESS ? "OK" : "ERR");
|
||||
}
|
||||
|
||||
int vk_has_reflex(void) {
|
||||
VkCtx *c = vk_ctx();
|
||||
return c && c->has_nv_reflex;
|
||||
}
|
||||
|
||||
// TOTK_TRACE=perf, every LAT_EVERY presents: the time from a frame's start (its window texture acquired) to its
|
||||
// present call on the host, with Reflex off or on, and with Reflex on the driver's own reports of the same frames
|
||||
// (vkGetLatencyTimingsNV): how many came back with every marker matched to their present, and their simulation start
|
||||
// to GPU render end. The frame's start is kept by its ID, so it also shows that a present carries its frame's ID.
|
||||
#define LAT_RING 64
|
||||
#define LAT_EVERY 600
|
||||
static struct { uint64_t id, start_ns; } g_lat_start[LAT_RING];
|
||||
static struct { uint64_t n, ns, presents; } g_lat;
|
||||
static PFN_vkGetLatencyTimingsNV g_reflex_timings;
|
||||
|
||||
uint64_t vk_reflex_frame_begin(void) {
|
||||
uint64_t id = __atomic_add_fetch(&g_reflex_frame_next, 1, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_reflex_frame, id, __ATOMIC_RELAXED);
|
||||
if (rt_trace & RT_TRACE_PERF) g_lat_start[id % LAT_RING].start_ns = kern_now_ns(), g_lat_start[id % LAT_RING].id = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
// g_pl held, after the present of frame pid
|
||||
static void latency_note(VkCtx *c, uint64_t pid) {
|
||||
if (!(rt_trace & RT_TRACE_PERF) || !pid) return;
|
||||
if (g_lat_start[pid % LAT_RING].id == pid) g_lat.n++, g_lat.ns += kern_now_ns() - g_lat_start[pid % LAT_RING].start_ns;
|
||||
if (++g_lat.presents % LAT_EVERY) return;
|
||||
char drv[200] = "";
|
||||
if (g_reflex_mode > 0 && g_sc) {
|
||||
if (!g_reflex_timings) g_reflex_timings = (PFN_vkGetLatencyTimingsNV)vkGetDeviceProcAddr(c->device, "vkGetLatencyTimingsNV");
|
||||
static VkLatencyTimingsFrameReportNV rep[64];
|
||||
VkGetLatencyMarkerInfoNV gi = {.sType = VK_STRUCTURE_TYPE_GET_LATENCY_MARKER_INFO_NV};
|
||||
if (g_reflex_timings) {
|
||||
g_reflex_timings(c->device, g_sc, &gi); // the count first
|
||||
if (gi.timingCount > 64) gi.timingCount = 64;
|
||||
for (uint32_t i = 0; i < gi.timingCount; i++)
|
||||
rep[i] = (VkLatencyTimingsFrameReportNV){.sType = VK_STRUCTURE_TYPE_LATENCY_TIMINGS_FRAME_REPORT_NV};
|
||||
gi.pTimings = rep;
|
||||
if (gi.timingCount) g_reflex_timings(c->device, g_sc, &gi);
|
||||
uint32_t full = 0;
|
||||
double sum = 0;
|
||||
for (uint32_t i = 0; i < gi.timingCount; i++) {
|
||||
const VkLatencyTimingsFrameReportNV *r = &rep[i];
|
||||
if (r->simStartTimeUs && r->simEndTimeUs && r->renderSubmitStartTimeUs && r->presentStartTimeUs &&
|
||||
r->gpuRenderEndTimeUs > r->simStartTimeUs)
|
||||
full++, sum += (double)(r->gpuRenderEndTimeUs - r->simStartTimeUs);
|
||||
}
|
||||
snprintf(drv, sizeof drv, "; driver reports: %u of %u frames with every marker, simulation start to GPU render "
|
||||
"end %.2f ms", full, gi.timingCount, full ? sum / full / 1000.0 : 0.0);
|
||||
}
|
||||
}
|
||||
rt_log("reflex: frame start to present %.2f ms over %llu frames (reflex %s)%s", g_lat.n ? g_lat.ns / 1e6 / g_lat.n : 0.0,
|
||||
(unsigned long long)g_lat.n, g_reflex_mode == 2 ? "boost" : g_reflex_mode == 1 ? "on" : "off", drv);
|
||||
g_lat.n = g_lat.ns = 0;
|
||||
}
|
||||
|
||||
uint64_t vk_reflex_frame(void) { return __atomic_load_n(&g_reflex_frame, __ATOMIC_RELAXED); }
|
||||
|
||||
void vk_reflex_submit_frame(uint64_t id) { t_reflex_submit = id; }
|
||||
|
||||
uint64_t vk_reflex_submit_id(void) { return t_reflex_submit ? t_reflex_submit : vk_reflex_frame(); }
|
||||
|
||||
// The present thread, before the blit of frame id: the present of that blit carries id.
|
||||
void vk_reflex_present_frame(uint64_t id) {
|
||||
// g_blit_pid feeds flip_locked's VkPresentIdKHR (Reflex) and latency_note (TOTK_TRACE=perf); with neither, the
|
||||
// present skips the lock
|
||||
if (!vk_has_reflex() && !(rt_trace & RT_TRACE_PERF)) return;
|
||||
plat_rmutex_lock(&g_pl);
|
||||
g_blit_pid = id;
|
||||
plat_rmutex_unlock(&g_pl);
|
||||
}
|
||||
|
||||
void vk_reflex_marker(int marker, uint64_t pid) {
|
||||
VkCtx *c = vk_ctx();
|
||||
if (!c || !c->has_nv_reflex || !g_reflex_marker || g_reflex_mode <= 0 || !g_sc || !pid) return;
|
||||
plat_rmutex_lock(&g_pl);
|
||||
if (g_sc && g_reflex_marker) {
|
||||
VkSetLatencyMarkerInfoNV mi = {
|
||||
.sType = VK_STRUCTURE_TYPE_SET_LATENCY_MARKER_INFO_NV,
|
||||
.presentID = pid,
|
||||
.marker = (VkLatencyMarkerNV)marker
|
||||
};
|
||||
g_reflex_marker(c->device, g_sc, &mi);
|
||||
}
|
||||
plat_rmutex_unlock(&g_pl);
|
||||
}
|
||||
|
||||
void vk_reflex_sleep(void) {
|
||||
VkCtx *c = vk_ctx();
|
||||
if (!c || !c->has_nv_reflex || !g_reflex_sleep || !g_reflex_sem || g_reflex_mode <= 0 || !g_sc) return;
|
||||
uint64_t val = __atomic_add_fetch(&g_reflex_val, 1, __ATOMIC_RELAXED);
|
||||
VkLatencySleepInfoNV si = {
|
||||
.sType = VK_STRUCTURE_TYPE_LATENCY_SLEEP_INFO_NV,
|
||||
.signalSemaphore = g_reflex_sem,
|
||||
.value = val
|
||||
};
|
||||
// vkLatencySleepNV uses the swapchain, which Vulkan wants externally synchronised with the acquire and the present
|
||||
// (they run under g_pl on the present thread). The wait for the semaphore stays outside the lock.
|
||||
VkResult r = VK_ERROR_INITIALIZATION_FAILED;
|
||||
plat_rmutex_lock(&g_pl);
|
||||
if (g_sc) r = g_reflex_sleep(c->device, g_sc, &si);
|
||||
plat_rmutex_unlock(&g_pl);
|
||||
if (r == VK_SUCCESS) {
|
||||
VkSemaphoreWaitInfo wi = {
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
|
||||
.semaphoreCount = 1,
|
||||
.pSemaphores = &g_reflex_sem,
|
||||
.pValues = &val
|
||||
};
|
||||
vkWaitSemaphores(c->device, &wi, 100000000ULL);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- swapchain
|
||||
static const char *g_present_got = ""; // the TOTK_VK_PRESENT value of the mode the swapchain got; "" before one
|
||||
|
||||
@@ -289,12 +467,29 @@ static void flip_locked(void) {
|
||||
if (!g_flip_on) return;
|
||||
g_flip_on = 0;
|
||||
if (!g_sc) return;
|
||||
VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1,
|
||||
VkCtx *c = vk_ctx();
|
||||
uint64_t pid = 0;
|
||||
VkPresentIdKHR pid_info = {0};
|
||||
if (c && c->has_nv_reflex) {
|
||||
// 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;
|
||||
g_last_pid = pid;
|
||||
pid_info.sType = VK_STRUCTURE_TYPE_PRESENT_ID_KHR;
|
||||
pid_info.swapchainCount = 1;
|
||||
pid_info.pPresentIds = &pid;
|
||||
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,
|
||||
.waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = &g_render_done[g_flip_idx], .swapchainCount = 1, .pSwapchains = &g_sc,
|
||||
.pImageIndices = &g_flip_idx};
|
||||
vk_queue_lock();
|
||||
VkResult r = vkQueuePresentKHR(vk_ctx()->gfx_queue, &pi);
|
||||
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);
|
||||
vk_device_fault_report(r);
|
||||
if (r == VK_ERROR_OUT_OF_DATE_KHR || r == VK_SUBOPTIMAL_KHR) plat_xchg32(&g_dirty, 1);
|
||||
}
|
||||
@@ -338,8 +533,14 @@ static int build_swapchain(void) {
|
||||
vk_queue_lock();
|
||||
vkDeviceWaitIdle(c->device);
|
||||
VkSwapchainKHR old = g_sc;
|
||||
VkSwapchainLatencyCreateInfoNV sci = {
|
||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_LATENCY_CREATE_INFO_NV,
|
||||
.latencyModeEnable = VK_TRUE
|
||||
};
|
||||
VkSwapchainCreateInfoKHR ci = {
|
||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, .surface = g_surface, .minImageCount = count,
|
||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||
.pNext = (c->has_nv_reflex) ? &sci : NULL,
|
||||
.surface = g_surface, .minImageCount = count,
|
||||
.imageFormat = sf.format, .imageColorSpace = sf.colorSpace, .imageExtent = ext, .imageArrayLayers = 1,
|
||||
.imageUsage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, // every surface supports it (the menu overlay draws into it)
|
||||
@@ -376,6 +577,10 @@ static int build_swapchain(void) {
|
||||
}
|
||||
free_capture();
|
||||
vk_queue_unlock();
|
||||
// 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;
|
||||
reflex_apply_locked();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -746,6 +951,7 @@ static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w
|
||||
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 (!defer) flip_locked();
|
||||
} else {
|
||||
vk_device_fault_report(r);
|
||||
@@ -800,6 +1006,11 @@ void gfx_window_release_vk(void) {
|
||||
vk_color_release();
|
||||
vk_hdr_release();
|
||||
vk_contact_release();
|
||||
if (g_reflex_sem) {
|
||||
vkDestroySemaphore(c->device, g_reflex_sem, NULL);
|
||||
g_reflex_sem = VK_NULL_HANDLE;
|
||||
}
|
||||
g_reflex_mode = -1;
|
||||
free_capture();
|
||||
free_thumbs();
|
||||
for (int i = 0; i < FRAMES; i++) {
|
||||
|
||||
+1004
-284
File diff suppressed because it is too large.
Load diff
+7
-2
@@ -24,7 +24,8 @@ void rt_vlogf(const char *fmt, va_list ap);
|
||||
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_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)
|
||||
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
|
||||
@@ -120,7 +121,9 @@ void hostfn_add_override(const char *name, GuestFn fn); // an override outsid
|
||||
const char *hostfn_name(uint64_t addr); // name registered at a synthetic address, NULL if none
|
||||
void hostfn_seal(void); // build the dispatch table (rt_dispatch_init over every
|
||||
// linked module); idempotent; registration ends here
|
||||
uint64_t hostfn_calls(void); // host-function calls so far, all threads
|
||||
uint64_t hostfn_calls(void); // host-function calls counted so far, all threads: only
|
||||
// while hostfn_count is on or under TOTK_TRACE=host
|
||||
void hostfn_count(int on); // count host-function calls (probes); off by default
|
||||
void hostfn_report(void); // call count per host function to stderr, busiest first
|
||||
int hostfn_table_size(int observers); // linked HOST_OVERRIDE (0) / HOST_OBSERVER (1) entries
|
||||
const char *hostfn_table_name(int observers, int i); // symbol of linked entry i, NULL past the end
|
||||
@@ -279,6 +282,8 @@ int cam_pack_build(const void *in, size_t n, const void *zsdic, size_t zsdic_n,
|
||||
// multiplied, malloc'd; 0 = factor 1 or cannot (logged)
|
||||
void cam_pack_served(void); // romfs.c serves the multiplied pack
|
||||
// ---- game resolution (resolution.c): TOTK_OUTPUT_RES, TOTK_RENDER_SCALE
|
||||
uint64_t res_grass_heap_extra_kib(void); // TOTK_GRASS_RANGE: added to the HeapDef grass heap; 0 = none
|
||||
uint64_t res_grass_heap_extra_bytes(void); // the same, added to the application pool, 2 MiB steps
|
||||
uint64_t res_heap_extra_bytes(void); // added to the application pool (mem_init), 2 MiB steps
|
||||
uint64_t res_heap_extra_kib(void); // added to the HeapDef texture heap and its parent; 0 = none
|
||||
uint64_t res_tex_heap_extra_bytes(void); // TOTK_TEX_HEAP_EXTRA_MB: added to the application pool and
|
||||
|
||||
+20
-9
@@ -2,9 +2,9 @@
|
||||
// Host functions at synthetic guest addresses: the HOST_OVERRIDE / HOST_OBSERVER
|
||||
// linker tables, the registry behind them, and the calls between host and guest (rt_call, rt_original).
|
||||
//
|
||||
// Every registered function dispatches through hostfn_entry, which counts the call, traces the first one
|
||||
// (TOTK_TRACE=host) and tail-calls the real function. The registry is fixed by hostfn_seal, which builds the dispatch
|
||||
// table; guest threads start after that, so lookups need no lock.
|
||||
// Every registered function dispatches through hostfn_entry, which counts the call (only while hostfn_count is on or
|
||||
// under TOTK_TRACE=host), traces the first one (TOTK_TRACE=host) and tail-calls the real function. The registry is
|
||||
// fixed by hostfn_seal, which builds the dispatch table; guest threads start after that, so lookups need no lock.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -46,7 +46,8 @@ static int sealed;
|
||||
|
||||
// The call count (hostfn_calls): one counter per calling thread, each on its own cache line, written only by that
|
||||
// thread. A locked add on a per-function counter beside the read-mostly slot fields made the game threads share and
|
||||
// bounce those lines on every host call (1.4.3 town: about 1% of the game threads' time in hostfn_entry).
|
||||
// bounce those lines on every host call (1.4.3 town: about 1% of the game threads' time in hostfn_entry). Only the
|
||||
// probes and TOTK_TRACE=host read it, so a game run does not count: hostfn_entry tests one rt_trace word for both.
|
||||
#define MAX_COUNTERS 4096
|
||||
typedef struct { _Alignas(64) uint64_t n; } Counter;
|
||||
static Counter counters[MAX_COUNTERS];
|
||||
@@ -157,18 +158,28 @@ __attribute__((noinline)) static void hostfn_blocking(Cpu *c, GuestFn fn) {
|
||||
kern_core_back(&away);
|
||||
}
|
||||
|
||||
static void hostfn_entry(Cpu *c) {
|
||||
uint64_t i = (c->pc - RT_HOSTFN_BASE) >> 4;
|
||||
if (__builtin_expect((c->pc & 15) || i >= (uint64_t)nslots, 0)) bad_entry(c);
|
||||
Slot *s = &slots[i];
|
||||
void hostfn_count(int on) {
|
||||
if (on) __atomic_fetch_or(&rt_trace, RT_TRACE_HOSTCOUNT, __ATOMIC_RELAXED);
|
||||
else __atomic_fetch_and(&rt_trace, ~(unsigned)RT_TRACE_HOSTCOUNT, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
// The counted path of hostfn_entry: the call count, and under TOTK_TRACE=host the first call of each function.
|
||||
__attribute__((noinline, cold)) static void hostfn_watch(Cpu *c, Slot *s) {
|
||||
uint64_t *k = thread_calls;
|
||||
if (__builtin_expect(!k, 0)) k = counter_new();
|
||||
if (__builtin_expect(k == &shared_calls, 0)) __atomic_fetch_add(k, 1, __ATOMIC_RELAXED);
|
||||
else __atomic_store_n(k, *k + 1, __ATOMIC_RELAXED);
|
||||
if (__builtin_expect(rt_trace & RT_TRACE_HOSTCALL, 0) && !__atomic_fetch_add(&s->calls, 1, __ATOMIC_RELAXED)) {
|
||||
if ((rt_trace & RT_TRACE_HOSTCALL) && !__atomic_fetch_add(&s->calls, 1, __ATOMIC_RELAXED)) {
|
||||
char lr[96];
|
||||
rt_log("host call %s from %s", s->name, ldr_describe(c->x[30] - 4, lr, sizeof lr));
|
||||
}
|
||||
}
|
||||
|
||||
static void hostfn_entry(Cpu *c) {
|
||||
uint64_t i = (c->pc - RT_HOSTFN_BASE) >> 4;
|
||||
if (__builtin_expect((c->pc & 15) || i >= (uint64_t)nslots, 0)) bad_entry(c);
|
||||
Slot *s = &slots[i];
|
||||
if (__builtin_expect(rt_trace & (RT_TRACE_HOSTCALL | RT_TRACE_HOSTCOUNT), 0)) hostfn_watch(c, s);
|
||||
if (s->blocking) {
|
||||
hostfn_blocking(c, s->fn);
|
||||
return;
|
||||
|
||||
+220
-34
@@ -21,6 +21,7 @@
|
||||
#include "ui/menu.h"
|
||||
#include "vk.h"
|
||||
#include "platform/platform.h"
|
||||
#include "gameplay_tweaks.h"
|
||||
|
||||
enum { STICK_MAX = 32767, STICK_DIR = 16384, TRIGGER_ON = 16384, RESCAN_MS = 1000 };
|
||||
|
||||
@@ -33,6 +34,7 @@ static volatile int32_t g_block, g_menu; // text entry / host menu: 0 off, 1 o
|
||||
enum { PAD_USED = 16384, MOUSE_USED = 6 };
|
||||
static volatile int32_t g_kbm_last = 1;
|
||||
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 int pad_rumble; // the open gamepad has rumble motors
|
||||
@@ -44,6 +46,7 @@ static volatile int32_t pad_layout_shown = -1; // pad_layout for the menu (any
|
||||
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)
|
||||
static char calib_pad_name[128]; // the controller the bias belongs to; empty when there is none
|
||||
|
||||
// SDL buttons of the gamepad inputs (input_map.h PAD_*), by position; PAD_ZL and PAD_ZR are the triggers (axes).
|
||||
static const SDL_GamepadButton pad_sdl[PAD_COUNT] = {
|
||||
@@ -55,9 +58,11 @@ static const SDL_GamepadButton pad_sdl[PAD_COUNT] = {
|
||||
[PAD_DPAD_RIGHT] = SDL_GAMEPAD_BUTTON_DPAD_RIGHT, [PAD_DPAD_DOWN] = SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
[PAD_LPADDLE1] = SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, [PAD_RPADDLE1] = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1,
|
||||
[PAD_LPADDLE2] = SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, [PAD_RPADDLE2] = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2,
|
||||
[PAD_TOUCHPAD] = SDL_GAMEPAD_BUTTON_TOUCHPAD,
|
||||
};
|
||||
|
||||
// TOTK_INPUT_SCRIPT=<file>: lines "<frame> <button> [hold]" or "<frame> LSTICK|RSTICK <x> <y> [hold]", ORed into the real input.
|
||||
// TOTK_INPUT_SCRIPT=<file>: lines "<frame> <button> [hold]", "<frame> LSTICK|RSTICK <x> <y> [hold]", "<frame> MOUSE
|
||||
// <dx> <dy>" or "<frame> WHEEL <notches>" (+ away from the player), ORed into the real input.
|
||||
// <frame> and its hold are 60 Hz ticks of game time since the first present (frame_step_ticks: presents at 60 fps), so
|
||||
// the title menus get the presses at the same game time at any frame limit. A line "@<ms> ..." is timed instead: <ms>
|
||||
// and its hold are milliseconds of the world clock (frame_step_world_us, game time since the loaded save's first
|
||||
@@ -74,6 +79,7 @@ static ScriptEv *script_ev;
|
||||
static int script_n, script_state; // 0 not loaded, 1 loaded
|
||||
static int script_mixed; // the script has timed lines: its untimed ones end where the world clock starts
|
||||
static int32_t script_mouse[2]; // one-shot raw counts, consumed by the camera hook; under lock
|
||||
static int32_t script_wheel; // one-shot wheel notches, taken with the real ones (wheel_stick); under lock
|
||||
|
||||
static void script_load(void) {
|
||||
script_state = 1;
|
||||
@@ -96,7 +102,11 @@ 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, "MOUSE") || !strcmp(name, "LSTICK") || !strcmp(name, "RSTICK")) {
|
||||
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);
|
||||
} else if (!strcmp(name, "MOUSE") || !strcmp(name, "LSTICK") || !strcmp(name, "RSTICK")) {
|
||||
int n = sscanf(line + off, "%ld %ld %lf", &a, &b, &c);
|
||||
if (n < 2) { rt_log("input: script line %d: %s needs x y [hold]", ln, name); continue; }
|
||||
e.stick = name[0] == 'M' ? 3 : name[0] == 'L' ? 1 : 2; e.x = (int32_t)a; e.y = (int32_t)b;
|
||||
@@ -131,14 +141,17 @@ static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
ScriptEv *e = &script_ev[i];
|
||||
if (e->timed ? w < 0 : script_mixed && w >= 0) continue;
|
||||
uint64_t now = e->timed ? (uint64_t)w : tick;
|
||||
if (now < e->at || (now >= e->at + e->hold && (e->logged || !e->timed))) continue;
|
||||
if (e->stick == 3 && e->logged) continue;
|
||||
// A one-shot (MOUSE, WHEEL) goes in at the first poll at or after its time: a poll that skips a tick (the
|
||||
// game below 60 fps) would otherwise lose it
|
||||
if (e->stick >= 3 ? e->logged || now < e->at
|
||||
: now < e->at || (now >= e->at + e->hold && (e->logged || !e->timed))) continue;
|
||||
if (!e->logged) {
|
||||
e->logged = 1;
|
||||
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 == 3) {
|
||||
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);
|
||||
script_mouse[1] = (int32_t)(y < INT32_MIN ? INT32_MIN : y > INT32_MAX ? INT32_MAX : y);
|
||||
@@ -261,6 +274,17 @@ void input_direct_mouse_sample(int enabled, int32_t *dx, int32_t *dy) {
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
// A turn of the real wheel as a WHEEL line of the recording (one-shot, as a MOUSE line). Under lock.
|
||||
static void rec_wheel(int32_t notches) {
|
||||
if (rec_state != 1) return;
|
||||
char what[32];
|
||||
snprintf(what, sizeof what, "WHEEL %d", notches);
|
||||
int64_t w = frame_step_world_us();
|
||||
uint64_t tick = frame_step_ticks();
|
||||
rec_line(tick, w, tick + 1, w, what);
|
||||
fflush(rec);
|
||||
}
|
||||
|
||||
static float mouse_sens = -1; // TOTK_MOUSE_SENS, 0 = mouse camera off; live (cfg_version)
|
||||
static unsigned mouse_sens_seen;
|
||||
|
||||
@@ -401,6 +425,9 @@ static void scan_pads(void) {
|
||||
if (pad && SDL_GamepadConnected(pad)) return;
|
||||
if (pad) {
|
||||
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());
|
||||
calib_pad_name[0] = 0;
|
||||
plat_xchg32(&pad_layout_shown, -1);
|
||||
for (int i = 0; i < 4; i++) plat_xchg32(&pad_labels[i], PAD_LABEL_NONE);
|
||||
rt_log("input: gamepad disconnected");
|
||||
@@ -541,35 +568,86 @@ static int32_t shake_stick(int held) {
|
||||
return (now - from) / SHAKE_SIDE_NS % 2 ? STICK_MAX : -STICK_MAX;
|
||||
}
|
||||
|
||||
// The scroll wheel on the Purah Pad's map, which zooms with the right stick's y (up: in): each notch is a full-tilt
|
||||
// pulse of MAP_ZOOM_PULSE_NS on that stick with MAP_ZOOM_GAP_NS of neutral after it, so a step of the zoom and a
|
||||
// held zoom both see one notch as one push. A fast scroll's notches wait their turn (at most MAP_ZOOM_QUEUE), a turn the
|
||||
// other way drops them. Returns the stick y for this poll, 0 between pulses and off the map. Under lock.
|
||||
#define MAP_ZOOM_PULSE_NS 100000000ull
|
||||
#define MAP_ZOOM_GAP_NS 50000000ull
|
||||
#define MAP_ZOOM_QUEUE 4
|
||||
static int32_t map_zoom_stick(int32_t notches, int on_map) {
|
||||
// The scroll wheel (ikb_wheel_take, and an input script's WHEEL lines) as the stick a gamepad player would move:
|
||||
// - on the Purah Pad's map it zooms: the right stick's y, away from the player zooming in;
|
||||
// - while a D-pad strip (weapons, shields, bows, materials) is held open it steps the choice: the right stick's x, away
|
||||
// from the player to the left, towards the player to the right;
|
||||
// - in a menu with the game's focus box (the inventory, shops, Options, the save list; menu_cursor_menu) it steps the
|
||||
// focus: the left stick's y, away from the player up;
|
||||
// - in the Purah Pad's camera (menu_cursor_camera) it zooms: the D-pad's up (away from the player, in) or down, the
|
||||
// buttons its guide shows for the zoom.
|
||||
// Each notch is a full-tilt pulse with neutral after it (wheel_timing), so the game sees one notch as one step, and a
|
||||
// fast scroll's notches wait their turn (at most WHEEL_QUEUE); a turn the other way drops them. A strip's pulse is the
|
||||
// mouse's (input_direct_mouse_row: 32 ms each way); a menu takes the stick on its own update, a frame of the game's
|
||||
// 30 Hz or less, so its pulse covers two. Elsewhere, and while the settings menu is open, the notches are dropped.
|
||||
enum { WHEEL_NONE, WHEEL_MAP, WHEEL_STRIP, WHEEL_MENU, WHEEL_CAMERA };
|
||||
static const struct { uint64_t pulse_ns, gap_ns; } wheel_timing[] = {
|
||||
[WHEEL_MAP] = {100000000ull, 50000000ull}, [WHEEL_STRIP] = {32000000ull, 32000000ull},
|
||||
[WHEEL_MENU] = {70000000ull, 50000000ull}, [WHEEL_CAMERA] = {100000000ull, 50000000ull}};
|
||||
#define WHEEL_QUEUE 4
|
||||
#define WHEEL_GAP_NS 300000000ull // a menu's focus gap (a tab switch): queued notches wait this long for its next screen
|
||||
|
||||
// The stick value for this poll at the place `where` (WHEEL_*): -STICK_MAX, 0 or STICK_MAX. Under lock.
|
||||
static int32_t wheel_stick(int32_t notches, int where) {
|
||||
static int32_t queued, dir;
|
||||
static uint64_t until; // the end of the pulse (dir != 0) or of the neutral after it
|
||||
static int place;
|
||||
static uint64_t until, none_since; // until: the end of the pulse (dir != 0) or of the neutral after it
|
||||
uint64_t now = plat_now_ns();
|
||||
if (!on_map) { queued = dir = 0, until = 0; return 0; }
|
||||
if (where == WHEEL_NONE) {
|
||||
if (!none_since) none_since = now;
|
||||
if (now - none_since > WHEEL_GAP_NS) queued = 0, place = WHEEL_NONE;
|
||||
dir = 0;
|
||||
return 0;
|
||||
}
|
||||
none_since = 0;
|
||||
if (where != place) queued = dir = 0, until = 0, place = where;
|
||||
if (notches) {
|
||||
if (queued && (notches > 0) != (queued > 0)) queued = 0;
|
||||
queued += notches;
|
||||
queued = queued > MAP_ZOOM_QUEUE ? MAP_ZOOM_QUEUE : queued < -MAP_ZOOM_QUEUE ? -MAP_ZOOM_QUEUE : queued;
|
||||
queued = queued > WHEEL_QUEUE ? WHEEL_QUEUE : queued < -WHEEL_QUEUE ? -WHEEL_QUEUE : queued;
|
||||
}
|
||||
if (dir) {
|
||||
if (now < until) return dir * STICK_MAX;
|
||||
dir = 0, until = now + MAP_ZOOM_GAP_NS;
|
||||
dir = 0, until = now + wheel_timing[where].gap_ns;
|
||||
return 0;
|
||||
}
|
||||
if (now < until || !queued) return 0;
|
||||
dir = queued > 0 ? 1 : -1;
|
||||
queued -= dir;
|
||||
until = now + MAP_ZOOM_PULSE_NS;
|
||||
until = now + wheel_timing[where].pulse_ns;
|
||||
return dir * STICK_MAX;
|
||||
}
|
||||
|
||||
// After the keys, the gamepad and the script: where the wheel goes this poll (b holds the script's D-pad too, so a
|
||||
// scripted strip takes scripted notches). Under lock.
|
||||
static void wheel_route(uint64_t *bp, int32_t sl[2], int32_t sr[2]) {
|
||||
uint64_t b = *bp;
|
||||
int32_t real = state > 0 ? ikb_wheel_take() : 0, notches = real + script_wheel; // the script's under TOTK_INPUT=none too
|
||||
script_wheel = 0;
|
||||
if (menu_is_open()) notches = 0;
|
||||
if (real && notches) {
|
||||
__atomic_store_n(&g_kbm_last, 1, __ATOMIC_RELAXED); // the pointer comes to a menu the wheel turns in
|
||||
rec_wheel(real);
|
||||
}
|
||||
// A strip is its D-pad direction held with its screen open; with the menu cursor off (the screens not read,
|
||||
// menu_cursor_shortcut -1) the buttons alone decide, as for the mouse's selectors
|
||||
int sc = b & (1ull << B_UP | 1ull << B_LEFT | 1ull << B_RIGHT) && !(b & 1ull << B_L) ? menu_cursor_shortcut() : 0;
|
||||
int strip = sc == -1 || sc == 1 || (sc == 0 && menu_cursor_strip());
|
||||
int where = menu_cursor_map() ? WHEEL_MAP
|
||||
: strip ? WHEEL_STRIP
|
||||
: menu_cursor_camera() ? WHEEL_CAMERA
|
||||
: menu_cursor_menu() ? WHEEL_MENU
|
||||
: WHEEL_NONE;
|
||||
if (where == WHEEL_MAP && gameplay_tweaks_map_zoom()) where = WHEEL_NONE;
|
||||
else if (where == WHEEL_STRIP && gameplay_tweaks_strip_wheel(b)) where = WHEEL_NONE;
|
||||
int32_t v = wheel_stick(notches, where);
|
||||
if (!v) return;
|
||||
if (where == WHEEL_CAMERA) *bp |= 1ull << (v > 0 ? B_UP : B_DOWN);
|
||||
else if (where == WHEEL_MAP) pick(&sr[0], &sr[1], 0, v);
|
||||
else if (where == WHEEL_STRIP) pick(&sr[0], &sr[1], -v, 0);
|
||||
else pick(&sl[0], &sl[1], 0, v);
|
||||
}
|
||||
|
||||
// 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(); }
|
||||
@@ -578,7 +656,7 @@ static int pad_physical(uint8_t pd[PAD_COUNT]) {
|
||||
for (int p = PAD_SOUTH; p < PAD_ZL; p++) pd[p] = SDL_GetGamepadButton(pad, pad_sdl[p]);
|
||||
pd[PAD_ZL] = SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_LEFT_TRIGGER) > TRIGGER_ON;
|
||||
pd[PAD_ZR] = SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) > TRIGGER_ON;
|
||||
for (int p = PAD_ZR + 1; p < PAD_COUNT; p++) pd[p] = SDL_GetGamepadButton(pad, pad_sdl[p]); // false without paddles
|
||||
for (int p = PAD_ZR + 1; p < PAD_COUNT; p++) pd[p] = SDL_GetGamepadButton(pad, pad_sdl[p]); // false without paddles or touchpad
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -641,6 +719,30 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
if (!counts || mouse_ignore[k]) down[k] = 0;
|
||||
}
|
||||
was_captured = cap;
|
||||
// On the Purah Pad's map (menu_cursor.c finds it, TOTK_MAP_CLICK) the left mouse button presses A at the
|
||||
// map's cursor, which the mouse moves there, instead of its binding (Y by default). A press is one or the
|
||||
// other from the moment it goes down until it is released, so a button held as the map opens or closes
|
||||
// keeps what it pressed.
|
||||
static int map_held, map_a;
|
||||
if (!down[KEY_MOUSE_L]) map_held = map_a = 0;
|
||||
else if (!map_held) map_held = 1, map_a = menu_cursor_map() && cfg_bool("TOTK_MAP_CLICK");
|
||||
if (map_a) down[KEY_MOUSE_L] = 0, b |= 1ull << B_A;
|
||||
// While a dialogue box is on screen (menu_cursor.c, TOTK_DIALOGUE_CLICK) the left mouse button presses B,
|
||||
// which advances the text and also shows the rest of a line at once, and the right one presses A, instead
|
||||
// of their bindings: Y by default, which opens the dialogue log there, and ZL. A press is one or the other
|
||||
// from the moment it goes down until it is released, so a click that closes the last box does not turn
|
||||
// into an attack while it is still held, and a button held as the box opens does not skip its first line.
|
||||
// Dialogue choices have the pointer, and their clicks are menu_cursor.c's: a left click there is A.
|
||||
static const uint8_t click_key[2] = {KEY_MOUSE_L, KEY_MOUSE_R}, click_btn[2] = {B_B, B_A};
|
||||
static int click_held[2], click_talk[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int key = click_key[i];
|
||||
if (!down[key]) click_held[i] = click_talk[i] = 0;
|
||||
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];
|
||||
}
|
||||
if (cap && !g_menu && !g_block) gameplay_tweaks_prepare_keys(down, b);
|
||||
else gameplay_tweaks_reset();
|
||||
b |= input_map_buttons(down);
|
||||
int32_t k[2];
|
||||
walk_get();
|
||||
@@ -658,13 +760,10 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
// Before the screens were read (the menu cursor off) the buttons alone decide, as before.
|
||||
if (selector && menu_cursor_shortcut() == 0) selector = 0;
|
||||
mouse_camera(k, selector);
|
||||
// On the map the left stick moves the cursor and the right one zooms: the mouse moves the cursor there,
|
||||
// the scroll wheel zooms (map_zoom_stick). Elsewhere the wheel is unbound; its notches are dropped.
|
||||
int map = menu_cursor_map();
|
||||
if (map) pick(&sl[0], &sl[1], k[0], k[1]);
|
||||
// On the map the left stick moves the cursor and the right one zooms: the mouse moves the cursor there
|
||||
// (the scroll wheel zooms, wheel_route)
|
||||
if (menu_cursor_map()) pick(&sl[0], &sl[1], k[0], k[1]);
|
||||
else pick(&sr[0], &sr[1], k[0], k[1]);
|
||||
int32_t zoom = map_zoom_stick(ikb_wheel_take(), map);
|
||||
if (zoom) pick(&sr[0], &sr[1], 0, zoom);
|
||||
int32_t shake = shake_stick(input_map_held(down, B_SHAKE));
|
||||
if (shake) sr[0] = shake, sr[1] = 0;
|
||||
// A mouse shake (mouse_direct.c) moves the stick with the mouse, side by side, and lets go when it rests
|
||||
@@ -679,6 +778,8 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
else if (kbm_used) __atomic_store_n(&g_kbm_last, 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
script_apply(&b, sl, sr);
|
||||
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);
|
||||
// Minus and Plus held together (gamepad or keys) open or close the menu and never reach the game
|
||||
static int combo_held;
|
||||
@@ -710,10 +811,12 @@ static volatile uint64_t g_block_closed, g_menu_closed;
|
||||
|
||||
int input_cursor_allowed(void) {
|
||||
const char *in = cfg_get("TOTK_INPUT");
|
||||
return g_block != 1 && g_menu != 1 && mouse_sens_get() > 0 && !(in && !strcmp(in, "none")) && !menu_cursor_pointer();
|
||||
return g_block != 1 && g_menu != 1 && (gameplay_tweaks_capture_needed() || mouse_sens_get() > 0) &&
|
||||
!(in && !strcmp(in, "none")) && !menu_cursor_pointer();
|
||||
}
|
||||
|
||||
void input_block(int on) {
|
||||
if (on) gameplay_tweaks_reset();
|
||||
if (!on) __atomic_store_n(&g_block_closed, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
plat_xchg32(&g_block, on ? 1 : 2);
|
||||
ikb_cursor_update();
|
||||
@@ -722,6 +825,7 @@ void input_block(int on) {
|
||||
// The in-game menu (ui/menu.cpp) blocks the game's input the same way: g_menu 0 closed, 1 open, 2 closed, waiting for
|
||||
// the release. The cursor is released while it is open, for the menu's mouse.
|
||||
void input_menu(int open) {
|
||||
if (open) gameplay_tweaks_reset();
|
||||
if (!open) __atomic_store_n(&g_menu_closed, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
plat_xchg32(&g_menu, open ? 1 : 2);
|
||||
if (!open) ikb_menu_closed(); // the capture before Esc comes back
|
||||
@@ -856,11 +960,56 @@ void input_motion_axes(const float a[3], const float g[3], double acc[3], double
|
||||
gyro[2] = g[1];
|
||||
}
|
||||
|
||||
// Copy a controller name into cap bytes without splitting a UTF-8 sequence: a name cut mid-character would show as
|
||||
// garbage in the menu and be written to totk.ini the same way.
|
||||
static void copy_name(char *dst, size_t cap, const char *src) {
|
||||
if (!src) src = "";
|
||||
size_t n = strlen(src);
|
||||
if (n >= cap) {
|
||||
n = cap - 1;
|
||||
while (n > 0 && ((unsigned char)src[n] & 0xC0) == 0x80) n--; // back off to the start of the character
|
||||
}
|
||||
memcpy(dst, src, n);
|
||||
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
|
||||
// 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);
|
||||
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 : "");
|
||||
copy_name(dst, cap, id);
|
||||
}
|
||||
|
||||
// Under lock, for each gamepad the sensor code sees (a first one, or one connected after another went away): the
|
||||
// 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) {
|
||||
char id[128];
|
||||
pad_identity(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));
|
||||
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);
|
||||
if (id == sensor_pad) return sensor_ok;
|
||||
sensor_pad = id;
|
||||
pad_bias_select();
|
||||
// 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) &&
|
||||
@@ -908,16 +1057,53 @@ static void motion_main(void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
// Under lock: the sensor thread, once; -1 when SDL is not running.
|
||||
static void motion_thread_start(void) {
|
||||
if (!state) start();
|
||||
if (motion_thread) return;
|
||||
if (!input_motion_enabled()) rt_log("input: motion off (TOTK_MOTION=0); it can be turned on while the game runs");
|
||||
if (state != 1) motion_thread = -1;
|
||||
else {
|
||||
if (!plat_thread_spawn(motion_main, NULL, "motion", 0)) rt_fatal("input: cannot start the motion thread");
|
||||
motion_thread = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void input_motion_start(void) {
|
||||
plat_mutex_lock(&lock);
|
||||
if (!state) start();
|
||||
if (!motion_thread) {
|
||||
if (!input_motion_enabled()) rt_log("input: motion off (TOTK_MOTION=0); it can be turned on while the game runs");
|
||||
if (state != 1) motion_thread = -1;
|
||||
else {
|
||||
if (!plat_thread_spawn(motion_main, NULL, "motion", 0)) rt_fatal("input: cannot start the motion thread");
|
||||
motion_thread = 1;
|
||||
}
|
||||
motion_thread_start();
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
void input_motion_calibrate(void) {
|
||||
plat_mutex_lock(&lock);
|
||||
// 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;
|
||||
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";
|
||||
// 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";
|
||||
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));
|
||||
motion_calibrate_start(motion_global(), id, kern_now_ns());
|
||||
rt_log("input: gyro calibration started on %s", calib_pad_name);
|
||||
}
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
int input_gyro_calibration_enabled(void) { return motion_calibration_enabled(); }
|
||||
|
||||
int input_motion_calib_state(char *pad, size_t cap) {
|
||||
plat_mutex_lock(&lock);
|
||||
int st = motion_thread == 1 ? motion_calib_poll(motion_global(), kern_now_ns()) : MOTION_CALIB_NONE;
|
||||
if (pad && cap) snprintf(pad, cap, "%s", calib_pad_name);
|
||||
plat_mutex_unlock(&lock);
|
||||
return st;
|
||||
}
|
||||
@@ -28,6 +28,20 @@ uint64_t input_buttons_last(void);
|
||||
// mouse_direct.c: the right stick's side a mouse shake gives while Ultrahand holds an object (-1 / +1), 0 while the
|
||||
// mouse does not shake; input.c puts it on the stick
|
||||
int input_direct_mouse_shake(void);
|
||||
enum {
|
||||
INPUT_CAM_UNCLASSIFIED = 0,
|
||||
INPUT_CAM_FREE_ROAM,
|
||||
INPUT_CAM_AIM,
|
||||
INPUT_CAM_SCOPE,
|
||||
INPUT_CAM_LOCK_ON,
|
||||
INPUT_CAM_MENU_WHEEL,
|
||||
INPUT_CAM_ABILITY,
|
||||
INPUT_CAM_ULTRAHAND_OBJECT,
|
||||
INPUT_CAM_VEHICLE,
|
||||
INPUT_CAM_DISABLED,
|
||||
};
|
||||
int input_camera_context(void);
|
||||
int input_gameplay_active(void);
|
||||
// menu_cursor.c: the L ability wheel or a D-pad strip has the focus: 1 / 0, -1 with the menu cursor off (not read)
|
||||
int menu_cursor_shortcut(void);
|
||||
// menu_cursor.c: the pointer in the game's menus (1.4.3). poll: once per pad read, adds a click's A or B; pointer: a
|
||||
@@ -35,6 +49,15 @@ int menu_cursor_shortcut(void);
|
||||
void menu_cursor_poll(uint64_t *buttons);
|
||||
int menu_cursor_pointer(void);
|
||||
int menu_cursor_map(void); // the Purah Pad's map is open: the mouse's stick is the left one (its cursor)
|
||||
// a dialogue box is on screen and TOTK_DIALOGUE_CLICK is on: left click is B, right click A (input.c poll_merged)
|
||||
int menu_cursor_dialogue(void);
|
||||
// A menu screen (not the ability wheel, a D-pad strip or the map) has the game's focus box, whichever device was used
|
||||
// last: input.c turns the scroll wheel into steps of its focus. 0 with the menu cursor off.
|
||||
int menu_cursor_menu(void);
|
||||
// A D-pad strip's screen (ShortCut_00) is open; it has no focus box while held. 0 with the menu cursor off.
|
||||
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);
|
||||
// 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);
|
||||
@@ -91,6 +114,20 @@ int input_rumble_triggers_enabled(void);
|
||||
void input_motion_start(void);
|
||||
// TOTK_MOTION is not "0" (a live setting: read again when cfg_version changes). Off: the sensor reads at rest.
|
||||
int input_motion_enabled(void);
|
||||
// The Controls tab's Calibrate gyro row: start a bias measurement on the open gamepad (starts the sensor thread when
|
||||
// the game has not yet). Callable from any thread.
|
||||
void input_motion_calibrate(void);
|
||||
// What the Calibrate gyro row shows (MOTION_CALIB_*): NONE no bias for this controller, COLLECTING, DONE a bias in
|
||||
// effect (measured in this run or loaded from totk.ini), FAILED the last attempt got no samples and no bias is in
|
||||
// effect, MOVED the last attempt was rejected because the controller moved. pad receives the name of the controller the
|
||||
// bias belongs to (empty when none), copied so the caller does not read a buffer another thread may be rewriting.
|
||||
enum { MOTION_CALIB_NONE, MOTION_CALIB_COLLECTING, MOTION_CALIB_DONE, MOTION_CALIB_FAILED, MOTION_CALIB_MOVED };
|
||||
int input_motion_calib_state(char *pad, size_t cap);
|
||||
// The bias's own switch (gyro_calibration, live). Off: no collection, the fusion takes the raw gyro, and the row's
|
||||
// state reads as before any calibration while the saved keys stay in totk.ini.
|
||||
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);
|
||||
// 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]);
|
||||
@@ -108,3 +145,9 @@ MotionFusion *motion_global(void); // the gamepad's, fed by input_win.c
|
||||
void motion_feed(MotionFusion *m, const double acc_g[3], const double gyro_rad_s[3], uint64_t now_ns);
|
||||
int motion_read(MotionFusion *m, MotionState *out, int max, uint64_t now_ns); // newest first; 0 = none in 200 ms
|
||||
void motion_restart(MotionFusion *m); // angle and direction start over at the next sample
|
||||
// Start a bias measurement at now_ns: samples while the controller rests, then the bias or a rejection (MOTION_CALIB_*).
|
||||
// pad is the controller's identity, written to totk.ini with the bias.
|
||||
void motion_calibrate_start(MotionFusion *m, const char *pad, uint64_t now_ns);
|
||||
int motion_calib_poll(MotionFusion *m, uint64_t now_ns); // MOTION_CALIB_*; ends an attempt whose samples stopped
|
||||
void motion_bias_load(MotionFusion *m); // take the bias from totk.ini (TOTK_GYRO_BIAS_*)
|
||||
void motion_bias_reset(MotionFusion *m); // no bias and no attempt (another controller)
|
||||
+2
-1
@@ -44,7 +44,8 @@ static const char *const action_names[ACTION_COUNT] = {
|
||||
"LSTICK_LEFT", "LSTICK_UP", "LSTICK_RIGHT", "LSTICK_DOWN", "RSTICK_LEFT", "RSTICK_UP", "RSTICK_RIGHT", "RSTICK_DOWN", "SHAKE"};
|
||||
static const char *const pad_names[PAD_COUNT] = {
|
||||
NULL, "south", "east", "west", "north", "lstick", "rstick", "l", "r", "start", "back",
|
||||
"dpad_left", "dpad_up", "dpad_right", "dpad_down", "zl", "zr", "lpaddle1", "rpaddle1", "lpaddle2", "rpaddle2"};
|
||||
"dpad_left", "dpad_up", "dpad_right", "dpad_down", "zl", "zr", "lpaddle1", "rpaddle1", "lpaddle2", "rpaddle2",
|
||||
"touchpad"};
|
||||
static const char *const key_names[KEY_COUNT] = { // each group starts at its id; the ids of a group are consecutive
|
||||
[KEY_A] = "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
|
||||
"v", "w", "x", "y", "z",
|
||||
|
||||
+4
-3
@@ -37,13 +37,14 @@ enum {
|
||||
|
||||
// Gamepad inputs by position (Nintendo layout, as SDL names them), platform-neutral like the key ids. ZL and ZR are the
|
||||
// analog triggers; input_win.c translates SDL buttons and axes to these (one place). The paddles are the back buttons
|
||||
// of an Xbox Elite, DualSense Edge or Steam Controller (SDL's LEFT_PADDLE1 and so on); no Switch button has them by
|
||||
// default, a bind line or the remapping rows add them.
|
||||
// of an Xbox Elite, DualSense Edge or Steam Controller (SDL's LEFT_PADDLE1 and so on), the touchpad is the click of a
|
||||
// DualSense or DualShock 4 touchpad (SDL's TOUCHPAD); no Switch button has them by default, a bind line or the
|
||||
// remapping rows add them. A pad without one never reports it held.
|
||||
enum {
|
||||
PAD_NONE = 0,
|
||||
PAD_SOUTH, PAD_EAST, PAD_WEST, PAD_NORTH, PAD_LSTICK, PAD_RSTICK, PAD_L, PAD_R, PAD_START, PAD_BACK,
|
||||
PAD_DPAD_LEFT, PAD_DPAD_UP, PAD_DPAD_RIGHT, PAD_DPAD_DOWN, PAD_ZL, PAD_ZR,
|
||||
PAD_LPADDLE1, PAD_RPADDLE1, PAD_LPADDLE2, PAD_RPADDLE2,
|
||||
PAD_LPADDLE1, PAD_RPADDLE1, PAD_LPADDLE2, PAD_RPADDLE2, PAD_TOUCHPAD,
|
||||
PAD_COUNT
|
||||
};
|
||||
|
||||
|
||||
+41
-2
@@ -12,18 +12,21 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "input_map.h"
|
||||
#include "input_sdl.h"
|
||||
#include "input_wsys.h"
|
||||
#include "gameplay_tweaks.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
static SDL_Window *win;
|
||||
static volatile uint8_t key_held[KEY_COUNT];
|
||||
static volatile int32_t esc_held, f8_held, focused;
|
||||
static volatile int32_t mouse_dx, mouse_dy; // relative motion since the last ikb_mouse_take, whole counts
|
||||
static volatile int32_t mouse_wheel; // wheel turned while captured, in 1/120 notches (ikb_wheel_take)
|
||||
static volatile int32_t mouse_wheel; // wheel turned while captured or over the window, in 1/120 notches
|
||||
// (ikb_wheel_take)
|
||||
static float rem_x, rem_y; // window thread: the fractions SDL reported beyond them
|
||||
static volatile int32_t mouse_travel; // raw counts moved in total, captured or not (ikb_mouse_travel)
|
||||
static float travel_rem; // window thread: the fraction of a count beyond mouse_travel
|
||||
@@ -143,6 +146,7 @@ static void cursor_apply(void) {
|
||||
plat_xchg32(&mouse_dy, 0);
|
||||
rem_x = rem_y = 0;
|
||||
plat_xchg32(&captured, want);
|
||||
if (!want) gameplay_tweaks_reset();
|
||||
}
|
||||
|
||||
// The pointer's place in the window (the window thread): x and y are SDL window units, the same space the mouse
|
||||
@@ -199,8 +203,37 @@ void ikb_menu_closed(void) {
|
||||
if (o & CUR_ESC) plat_cas32(&cur_rel, 0, o);
|
||||
}
|
||||
|
||||
// pointer_image = 1: the pointer over the window while the cursor is not captured is cursor_art.c's, sized by the
|
||||
// window's display scale; 0 (the default) keeps SDL's arrow. Window thread, at the window's creation and whenever the
|
||||
// settings change (input_sdl_idle), so the menu switches it live. SDL's arrow stays when SDL refuses the image.
|
||||
static void art_cursor(SDL_Window *w) {
|
||||
static SDL_Cursor *art;
|
||||
static int shown = -1, failed;
|
||||
static unsigned seen = ~0u;
|
||||
unsigned v = cfg_version();
|
||||
if (v == seen && shown >= 0) return;
|
||||
seen = v;
|
||||
int want = cfg_bool("TOTK_POINTER_IMAGE");
|
||||
if (want == shown) return;
|
||||
if (want && !art && !failed) {
|
||||
float scale = SDL_GetWindowDisplayScale(w);
|
||||
int size = (int)lrintf(32 * (scale > 0 ? scale : 1)), hot;
|
||||
size = size < 32 ? 32 : size > 128 ? 128 : size;
|
||||
SDL_Surface *s = SDL_CreateSurface(size, size, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (s && s->pitch == size * 4) {
|
||||
cursor_art(s->pixels, size, &hot);
|
||||
art = SDL_CreateColorCursor(s, hot, hot);
|
||||
}
|
||||
if (s) SDL_DestroySurface(s);
|
||||
if (!art) failed = 1, rt_log("input: the pointer's image failed (%s); the arrow stays", SDL_GetError());
|
||||
}
|
||||
SDL_SetCursor(want && art ? art : SDL_GetDefaultCursor());
|
||||
shown = want;
|
||||
}
|
||||
|
||||
void input_sdl_window(SDL_Window *w) {
|
||||
win = w;
|
||||
art_cursor(w);
|
||||
wake_event = SDL_RegisterEvents(1);
|
||||
plat_xchg32(&focused, (SDL_GetWindowFlags(w) & SDL_WINDOW_INPUT_FOCUS) != 0);
|
||||
__atomic_store_n(&ptr_have, 0, __ATOMIC_RELEASE); // the pointer's place is unknown until it enters or moves
|
||||
@@ -209,6 +242,7 @@ void input_sdl_window(SDL_Window *w) {
|
||||
|
||||
void input_sdl_idle(void) {
|
||||
if (cur_pending) cursor_apply();
|
||||
if (win) art_cursor(win);
|
||||
pointer_apply();
|
||||
}
|
||||
|
||||
@@ -266,10 +300,15 @@ void input_sdl_event(const SDL_Event *e) {
|
||||
__atomic_store_n(&ptr_have, 0, __ATOMIC_RELEASE);
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL: // notches, + away from the player (a flipped wheel reports the other sign)
|
||||
if (captured) {
|
||||
// Captured, or released over the focused window: a game menu with the pointer takes it (input.c)
|
||||
if (captured || (focused && __atomic_load_n(&ptr_have, __ATOMIC_ACQUIRE))) {
|
||||
float y = e->wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -e->wheel.y : e->wheel.y;
|
||||
plat_add32(&mouse_wheel, (int32_t)(y * 120));
|
||||
}
|
||||
if (input_gameplay_active()) {
|
||||
double delta = e->wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? e->wheel.y : -e->wheel.y;
|
||||
gameplay_tweaks_wheel(delta, ikb_down(KEY_C), ikb_down(KEY_MOUSE_R));
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
plat_xchg32(&focused, 1);
|
||||
|
||||
+54
-4
@@ -13,6 +13,7 @@
|
||||
#include "input_win.h"
|
||||
#include "input_map.h"
|
||||
#include "input_wsys.h"
|
||||
#include "gameplay_tweaks.h"
|
||||
#include "nvn_api.h"
|
||||
#include "ui/menu.h"
|
||||
#include "vk.h"
|
||||
@@ -84,7 +85,8 @@ uint32_t input_key_char(int key) {
|
||||
// ---- mouse camera: raw motion accumulated by the window thread, one stick sample per presented frame
|
||||
static volatile LONG mouse_dx, mouse_dy; // raw counts since the last frame sample
|
||||
static volatile LONG mouse_travel; // raw counts moved in total, captured or not (ikb_mouse_travel)
|
||||
static volatile LONG mouse_wheel; // wheel turned while captured, in WHEEL_DELTA units (ikb_wheel_take)
|
||||
static volatile LONG mouse_wheel; // wheel turned while captured or over the window, in WHEEL_DELTA units
|
||||
// (ikb_wheel_take)
|
||||
static volatile LONG cur_captured; // cursor hidden and confined to the client area
|
||||
static volatile LONG cur_active; // WM_ACTIVATEAPP: the window's application is active
|
||||
// Bits: CUR_REL, Esc or activation by a click on the title bar or border: until a client click; CUR_ESC, set with CUR_REL
|
||||
@@ -118,9 +120,43 @@ static void cursor_update(HWND h) {
|
||||
if (cur_captured) ClipCursor(NULL);
|
||||
InterlockedExchange(&cur_captured, 0);
|
||||
}
|
||||
if (!cur_captured) gameplay_tweaks_reset();
|
||||
ReleaseSRWLockExclusive(&cur_lock);
|
||||
}
|
||||
|
||||
// The pointer shown over the client area while the cursor is not captured (cursor_art.c), 32 pixels at 96 DPI and
|
||||
// larger with the window's DPI; made again when the DPI changes. Window thread. NULL when Windows refuses it: the
|
||||
// window class's arrow stays.
|
||||
static HCURSOR art_cursor(HWND h) {
|
||||
static HCURSOR cur;
|
||||
static UINT made_dpi;
|
||||
UINT dpi = GetDpiForWindow(h);
|
||||
if (!dpi) dpi = USER_DEFAULT_SCREEN_DPI;
|
||||
if (cur && dpi == made_dpi) return cur;
|
||||
int size = MulDiv(32, (int)dpi, USER_DEFAULT_SCREEN_DPI), hot;
|
||||
size = size < 32 ? 32 : size > 128 ? 128 : size;
|
||||
BITMAPV5HEADER bh = {.bV5Size = sizeof bh, .bV5Width = size, .bV5Height = -size, .bV5Planes = 1, .bV5BitCount = 32,
|
||||
.bV5Compression = BI_BITFIELDS, .bV5RedMask = 0xff0000, .bV5GreenMask = 0xff00,
|
||||
.bV5BlueMask = 0xff, .bV5AlphaMask = 0xff000000u};
|
||||
void *bits = NULL;
|
||||
HDC dc = GetDC(NULL);
|
||||
HBITMAP color = CreateDIBSection(dc, (BITMAPINFO *)&bh, DIB_RGB_COLORS, &bits, NULL, 0);
|
||||
ReleaseDC(NULL, dc);
|
||||
HBITMAP mask = CreateBitmap(size, size, 1, 1, NULL);
|
||||
HCURSOR made = NULL;
|
||||
if (color && mask && bits) {
|
||||
cursor_art(bits, size, &hot);
|
||||
ICONINFO ii = {.fIcon = FALSE, .xHotspot = (DWORD)hot, .yHotspot = (DWORD)hot, .hbmMask = mask,
|
||||
.hbmColor = color};
|
||||
made = (HCURSOR)CreateIconIndirect(&ii);
|
||||
}
|
||||
if (color) DeleteObject(color);
|
||||
if (mask) DeleteObject(mask);
|
||||
if (!made) return cur; // the old size, or NULL
|
||||
cur = made, made_dpi = dpi; // the old one may still be on screen: kept (a DPI change is rare)
|
||||
return cur;
|
||||
}
|
||||
|
||||
int input_cursor_released(void) { return (cur_rel & CUR_REL) != 0; }
|
||||
|
||||
void input_cursor_suspend(int on) {
|
||||
@@ -148,13 +184,27 @@ int input_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res) {
|
||||
InterlockedAdd(&mouse_dy, y);
|
||||
}
|
||||
}
|
||||
// The wheel comes in the same message (usButtonData, signed, + away from the player)
|
||||
if (cur_captured && ri.header.dwType == RIM_TYPEMOUSE && (ri.data.mouse.usButtonFlags & RI_MOUSE_WHEEL))
|
||||
// The wheel comes in the same message (usButtonData, signed, + away from the player). It counts while the
|
||||
// cursor is captured, or released over the client area: a game menu with the pointer (menu_cursor.c) takes it
|
||||
// as steps of its focus. input.c drops the notches where nothing takes them.
|
||||
float px, py;
|
||||
if (ri.header.dwType == RIM_TYPEMOUSE && (ri.data.mouse.usButtonFlags & RI_MOUSE_WHEEL) &&
|
||||
(cur_captured || ikb_pointer(&px, &py)))
|
||||
InterlockedAdd(&mouse_wheel, (SHORT)ri.data.mouse.usButtonData);
|
||||
break; // DefWindowProc must see WM_INPUT for cleanup
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
if (input_gameplay_active())
|
||||
gameplay_tweaks_wheel(-(double)(short)HIWORD(w) / WHEEL_DELTA,
|
||||
ikb_down(KEY_C), ikb_down(KEY_MOUSE_R));
|
||||
break;
|
||||
case WM_SETCURSOR:
|
||||
if (cur_captured && LOWORD(l) == HTCLIENT) { SetCursor(NULL); *res = TRUE; return 1; }
|
||||
if (LOWORD(l) == HTCLIENT) {
|
||||
// pointer_image = 1: the pointer of cursor_art.c in place of the window class's arrow (0, the default:
|
||||
// the arrow, left to DefWindowProc)
|
||||
HCURSOR c = cur_captured || !cfg_bool("TOTK_POINTER_IMAGE") ? NULL : art_cursor(h);
|
||||
if (cur_captured || c) { SetCursor(c); *res = TRUE; return 1; }
|
||||
}
|
||||
break;
|
||||
case WM_SYSCOMMAND: // Alt pressed alone would enter the window menu loop, which stalls the game: Alt is a game key
|
||||
if ((w & 0xFFF0) == SC_KEYMENU && l == 0) { *res = 0; return 1; }
|
||||
|
||||
@@ -13,10 +13,16 @@ void ikb_pointer_set(float nx, float ny); // moves the pointer there (the wind
|
||||
int ikb_captured(void); // the cursor is captured for the mouse camera
|
||||
void ikb_mouse_take(int32_t *dx, int32_t *dy); // raw mouse motion since the last call, in counts
|
||||
uint32_t ikb_mouse_travel(void); // raw counts the mouse moved in total (|dx| + |dy|), captured or not
|
||||
int32_t ikb_wheel_take(void); // whole wheel notches turned while captured since the last call (+ away
|
||||
// from the player); a high-resolution wheel's part of a notch is kept
|
||||
int32_t ikb_wheel_take(void); // whole wheel notches turned since the last call while the cursor was
|
||||
// captured or over the focused window (+ away from the player); a
|
||||
// high-resolution wheel's part of a notch is kept
|
||||
void ikb_cursor_update(void); // what input_cursor_allowed says may have changed
|
||||
void ikb_menu_closed(void); // the menu closed: a capture that Esc gave up comes back
|
||||
|
||||
// ---- shared by the back ends
|
||||
// cursor_art.c: the pointer's image at size x size pixels (0xAARRGGBB, straight alpha, rows from the top) and its
|
||||
// hotspot (*hot, the same in x and y). Pure.
|
||||
void cursor_art(uint32_t *argb, int size, int *hot);
|
||||
|
||||
// ---- what input.c provides the back end
|
||||
int input_cursor_allowed(void); // no text entry or menu open, the mouse camera on, input not disabled
|
||||
@@ -783,6 +783,7 @@ int probe_ipc(void) {
|
||||
return 0;
|
||||
}
|
||||
ldr_load(rt_config()->exefs);
|
||||
hostfn_count(1); // the stats line reads the host-call count
|
||||
kern_run_on_guest_main(guest_main);
|
||||
probe_unknown_service();
|
||||
RtStats s = rt_stats();
|
||||
|
||||
@@ -1445,6 +1445,7 @@ static RtThread *thr_new(int prio, int core, uint64_t mask) {
|
||||
Cpu *c = plat_aligned_alloc(sizeof(Cpu), 64);
|
||||
if (!t || !c) rt_fatal("kernel: thread allocation");
|
||||
memset(c, 0, sizeof *c);
|
||||
rt_fpcr_threshold(c);
|
||||
plat_cond_init(&t->cv);
|
||||
t->prio = prio;
|
||||
t->core = core;
|
||||
@@ -2259,6 +2260,7 @@ static void fiber_switch_to(RtThread *t, const Cpu *from, Fiber *to) {
|
||||
dst->tpidr = from->tpidr;
|
||||
dst->tpidrro = from->tpidrro;
|
||||
dst->fpcr = from->fpcr;
|
||||
rt_fpcr_threshold(dst); // fiber_resumed syncs MXCSR on the other side; the threshold follows fpcr at once
|
||||
dst->fpsr = from->fpsr;
|
||||
dst->excl_addr = ~0ull;
|
||||
dst->thread = t;
|
||||
@@ -2291,6 +2293,7 @@ void kern_fiber_initialize(Cpu *c) {
|
||||
plat_fiber_free(f->host);
|
||||
}
|
||||
memset(f->cpu, 0, sizeof *f->cpu);
|
||||
rt_fpcr_threshold(f->cpu);
|
||||
f->cpu->excl_addr = ~0ull;
|
||||
f->addr = addr;
|
||||
f->func = c->x[1];
|
||||
|
||||
@@ -855,6 +855,7 @@ int probe_kernel(void) {
|
||||
test_platform();
|
||||
test_oom_commit();
|
||||
test_crash_report();
|
||||
hostfn_count(1); // test_lifted_ticks and the stats line read the host-call count
|
||||
kern_run_on_guest_main(probe_main);
|
||||
RtStats s = rt_stats();
|
||||
printf("stats: %llu SVCs, %llu threads, %llu host calls\n", (unsigned long long)s.svcs,
|
||||
|
||||
@@ -643,6 +643,7 @@ static void check_got(void) {
|
||||
hostfn_seal();
|
||||
Cpu *c = plat_aligned_alloc(sizeof(Cpu), 64);
|
||||
memset(c, 0, sizeof *c);
|
||||
rt_fpcr_threshold(c);
|
||||
uint8_t *stack = mem_kernel_alloc(0x10000, 16);
|
||||
c->sp = (uint64_t)(uintptr_t)stack + 0x10000;
|
||||
c->excl_addr = ~0ull;
|
||||
|
||||
@@ -161,6 +161,16 @@ const RtConfig *rt_config(void) { return &cfg; }
|
||||
volatile int g_fnprof = 0; // resolution.c switches it on until the game sets its render size (res_fn_hit)
|
||||
void fnprof_hit(uint64_t addr, uint64_t lr, uint64_t x0) { (void)lr, res_fn_hit(addr, x0); }
|
||||
|
||||
// cpu.h RT_FPCR_NOTE: diagnostic only, the write itself takes effect as before (runtime/simd.h slow paths).
|
||||
void rt_fpcr_rmode(uint64_t fpcr, uint64_t lr) {
|
||||
static int seen;
|
||||
if (__atomic_exchange_n(&seen, 1, __ATOMIC_RELAXED)) return;
|
||||
static const char *const mode[] = {"nearest", "+inf", "-inf", "zero"};
|
||||
char at[128];
|
||||
rt_log("fpcr: guest code set rounding mode %s (FPCR %#llx), in a function called from %s", mode[(fpcr >> 22) & 3],
|
||||
(unsigned long long)fpcr, ldr_describe(lr, at, sizeof at));
|
||||
}
|
||||
|
||||
void rt_brk(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
char at[128], lr[128];
|
||||
rt_fatal("brk #%#x at %s (lr %s)", imm, ldr_describe(pc, at, sizeof at), ldr_describe(c->x[30], lr, sizeof lr));
|
||||
@@ -558,6 +568,7 @@ static int selftest(void) {
|
||||
CHECK(s.functions > 0, "no functions linked");
|
||||
Cpu *c = plat_aligned_alloc(sizeof(Cpu), 64);
|
||||
memset(c, 0, sizeof *c);
|
||||
rt_fpcr_threshold(c);
|
||||
uint64_t r = rt_call(c, probe, 1, (uint64_t)7);
|
||||
CHECK(rt_dispatch_lookup(probe) && r == 42 && host_probe_hits == 1 && c->x[30] == 0,
|
||||
"a registered host function does not dispatch through rt_call");
|
||||
|
||||
+3
-2
@@ -263,11 +263,12 @@ void mem_init(void) {
|
||||
L = (RtGuestLayout){
|
||||
.aslr = {low, RT_ADDRESS_LIMIT - low},
|
||||
.stack = {low + STACK_OFF, STACK_SIZE},
|
||||
.heap = {low + HEAP_OFF, HEAP_CAP + res_tex_heap_extra_bytes()},
|
||||
.heap = {low + HEAP_OFF, HEAP_CAP + res_tex_heap_extra_bytes() + res_grass_heap_extra_bytes()},
|
||||
.alias = {alias, ALIAS_SIZE},
|
||||
.kernel = {RT_KERNEL_BASE, RT_KERNEL_SIZE},
|
||||
.hostfn = {RT_HOSTFN_BASE, RT_HOSTFN_SIZE},
|
||||
.pool = pool ? strtoull(pool, NULL, 0) : DEFAULT_POOL + res_heap_extra_bytes() + res_tex_heap_extra_bytes(),
|
||||
.pool = pool ? strtoull(pool, NULL, 0)
|
||||
: DEFAULT_POOL + res_heap_extra_bytes() + res_tex_heap_extra_bytes() + res_grass_heap_extra_bytes(),
|
||||
};
|
||||
if (!L.pool) rt_fatal("memory: TOTK_APP_POOL is 0");
|
||||
}
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
// Inline equality compares and copies for the replay's per-draw paths (TOTK_MEMX=0|1|check, default 1).
|
||||
// ucrtbase's memcmp walks 8 bytes a step with a call around it, and the replay compares and copies a few hundred
|
||||
// bytes at a time thousands of times a frame (pipeline states, shader answers, descriptor signatures): MX_EQ and
|
||||
// MX_CPY do the same work with 32-byte loads in the caller, so a constant size unrolls and a variable one loops
|
||||
// without a call. MX_EQ answers only equal or not, never an order. MX_CPY is memcpy: source and destination never
|
||||
// overlap. 1: the inline forms. 0: memcmp/memcpy as before. check: memcmp/memcpy, and every MX_EQ also runs the
|
||||
// inline compare and logs a different answer (vk_memx_bad). The mode is read once per process (vk_memx_init); calls
|
||||
// before that take the off path.
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int vk_memx_mode; // -1 before vk_memx_init, 0 off, 1 on, 2 check
|
||||
void vk_memx_init(void);
|
||||
void vk_memx_bad(const char *file, int line, size_t n);
|
||||
|
||||
typedef uint64_t mx_v4 __attribute__((vector_size(32), aligned(1)));
|
||||
typedef uint64_t mx_v2 __attribute__((vector_size(16), aligned(1)));
|
||||
|
||||
static inline __attribute__((always_inline)) mx_v4 mx_ld4(const uint8_t *p) {
|
||||
mx_v4 v;
|
||||
__builtin_memcpy(&v, p, 32);
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) mx_v2 mx_ld2(const uint8_t *p) {
|
||||
mx_v2 v;
|
||||
__builtin_memcpy(&v, p, 16);
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) uint64_t mx_ld1(const uint8_t *p) {
|
||||
uint64_t v;
|
||||
__builtin_memcpy(&v, p, 8);
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) uint32_t mx_ldw(const uint8_t *p) {
|
||||
uint32_t v;
|
||||
__builtin_memcpy(&v, p, 4);
|
||||
return v;
|
||||
}
|
||||
|
||||
// 1 when the n bytes at a and b are equal. Sizes of 32 and up compare in 128-byte steps with one branch each, the
|
||||
// last partial step as an overlapping 32-byte load from the end; smaller sizes take two overlapping loads.
|
||||
static inline __attribute__((always_inline)) int mx_eq(const void *a, const void *b, size_t n) {
|
||||
const uint8_t *p = a, *q = b;
|
||||
if (n >= 32) {
|
||||
size_t i = 0;
|
||||
for (; i + 128 <= n; i += 128) {
|
||||
mx_v4 d = (mx_ld4(p + i) ^ mx_ld4(q + i)) | (mx_ld4(p + i + 32) ^ mx_ld4(q + i + 32)) |
|
||||
(mx_ld4(p + i + 64) ^ mx_ld4(q + i + 64)) | (mx_ld4(p + i + 96) ^ mx_ld4(q + i + 96));
|
||||
if (d[0] | d[1] | d[2] | d[3]) return 0;
|
||||
}
|
||||
mx_v4 d = {0, 0, 0, 0};
|
||||
for (; i + 32 <= n; i += 32) d |= mx_ld4(p + i) ^ mx_ld4(q + i);
|
||||
if (i < n) d |= mx_ld4(p + n - 32) ^ mx_ld4(q + n - 32);
|
||||
return !(d[0] | d[1] | d[2] | d[3]);
|
||||
}
|
||||
if (n >= 16) {
|
||||
mx_v2 d = (mx_ld2(p) ^ mx_ld2(q)) | (mx_ld2(p + n - 16) ^ mx_ld2(q + n - 16));
|
||||
return !(d[0] | d[1]);
|
||||
}
|
||||
if (n >= 8) return !((mx_ld1(p) ^ mx_ld1(q)) | (mx_ld1(p + n - 8) ^ mx_ld1(q + n - 8)));
|
||||
if (n >= 4) return !((mx_ldw(p) ^ mx_ldw(q)) | (mx_ldw(p + n - 4) ^ mx_ldw(q + n - 4)));
|
||||
for (size_t i = 0; i < n; i++)
|
||||
if (p[i] != q[i]) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// memcpy of n bytes between buffers that do not overlap: 32-byte moves, the last partial one overlapping the one
|
||||
// before it (it rewrites bytes it already wrote with the same values).
|
||||
static inline __attribute__((always_inline)) void mx_cpy(void *d, const void *s, size_t n) {
|
||||
uint8_t *p = d;
|
||||
const uint8_t *q = s;
|
||||
if (n >= 32) {
|
||||
mx_v4 last = mx_ld4(q + n - 32);
|
||||
for (size_t i = 0; i + 32 <= n; i += 32) {
|
||||
__asm__("" : "+r"(p)); // opaque to the loop-idiom pass, which would turn the loop back into a memcpy call
|
||||
mx_v4 v = mx_ld4(q + i);
|
||||
__builtin_memcpy(p + i, &v, 32);
|
||||
}
|
||||
__builtin_memcpy(p + n - 32, &last, 32);
|
||||
return;
|
||||
}
|
||||
if (n >= 16) {
|
||||
mx_v2 x = mx_ld2(q), y = mx_ld2(q + n - 16);
|
||||
__builtin_memcpy(p, &x, 16), __builtin_memcpy(p + n - 16, &y, 16);
|
||||
return;
|
||||
}
|
||||
if (n >= 8) {
|
||||
uint64_t x = mx_ld1(q), y = mx_ld1(q + n - 8);
|
||||
__builtin_memcpy(p, &x, 8), __builtin_memcpy(p + n - 8, &y, 8);
|
||||
return;
|
||||
}
|
||||
if (n >= 4) {
|
||||
uint32_t x = mx_ldw(q), y = mx_ldw(q + n - 4);
|
||||
__builtin_memcpy(p, &x, 4), __builtin_memcpy(p + n - 4, &y, 4);
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < n; i++) p[i] = q[i];
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) int mx_eq_at(const void *a, const void *b, size_t n, const char *file,
|
||||
int line) {
|
||||
if (vk_memx_mode == 1) return mx_eq(a, b, n);
|
||||
int r = !memcmp(a, b, n);
|
||||
if (vk_memx_mode == 2 && mx_eq(a, b, n) != r) vk_memx_bad(file, line, n);
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void mx_cpy_sw(void *d, const void *s, size_t n) {
|
||||
if (vk_memx_mode == 1) mx_cpy(d, s, n);
|
||||
else memcpy(d, s, n);
|
||||
}
|
||||
|
||||
#define MX_EQ(a, b, n) mx_eq_at((a), (b), (n), __FILE__, __LINE__)
|
||||
#define MX_NE(a, b, n) (!MX_EQ(a, b, n))
|
||||
#define MX_CPY(d, s, n) mx_cpy_sw((d), (s), (n))
|
||||
+114
-11
@@ -20,6 +20,14 @@
|
||||
//
|
||||
// Only while keyboard and mouse are the device used last (input_kbm_last): a gamepad player sees the menus unchanged.
|
||||
// TOTK_MENU_CURSOR (live, default 1): 0 leaves the menus to the keys and the pad.
|
||||
//
|
||||
// With TOTK_MAP_CLICK=1 (live, default 0: one key per controller button) input.c makes the left mouse button A on the
|
||||
// map (menu_cursor_map), so a click acts at the map's cursor. The map is found only while TOTK_MENU_CURSOR is on.
|
||||
//
|
||||
// The same read of the open screens tells input.c when a dialogue box is on screen (menu_cursor_dialogue), where the
|
||||
// left mouse button presses B (it advances the text and skips its scroll) and the right one A, instead of their
|
||||
// bindings (Y by default, which opens the dialogue log, and ZL). TOTK_DIALOGUE_CLICK (live, default 0: one key per
|
||||
// controller button) switches that on its own: it does not need the pointer.
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -50,6 +58,10 @@ enum { DI_PROJ = 0x10, DI_VIEW = 0x50, LYT_ROOT = 0x18, LYT_SIZE = 0x28, LYT_NAM
|
||||
// nn::ui2d::Pane
|
||||
enum { PANE_PARENT = 0x18, PANE_SIZE = 0x50, PANE_FLAG = 0x58, PANE_ALPHA = 0x59, PANE_BASE = 0x5b, PANE_MTX = 0x70 };
|
||||
|
||||
// How far the pointer moves, in layout units (1280 x 720 across the picture: 1.5 window pixels at 1080p, 3 at 4K),
|
||||
// before it takes back a focus that the wheel, the keys or the pad moved away from it (menu_cursor_poll)
|
||||
#define DEAD_ZONE 6.0f
|
||||
|
||||
static uint64_t main_lo, main_hi;
|
||||
|
||||
static int ok_at(uint64_t p, uint64_t n) {
|
||||
@@ -166,16 +178,24 @@ static void layout_name(uint64_t scr, char *out, size_t n) {
|
||||
// 1.4.3 constructor keeps). The map has no focus box, so it is found here: the Purah Pad's frame (AppMenuOverlay_00)
|
||||
// with AppMap_00 and the menu's background AppMenuBG_00 open. The Scope opens the frame over AppMap_00 without that
|
||||
// background (Weeping of the Empire's engine/runtime/totk_menu_cursor.cpp census tells them apart the same way).
|
||||
// The dialogue window (DIALOGUE_SCREEN) has no focus box either: the scan remembers its screen for dialogue_shown.
|
||||
// A D-pad strip has no focus box either while it is held open: *strip is ShortCut_00 being open. *camera is the
|
||||
// Purah Pad's camera (the ability wheel's camera): the frame and its pointer CameraPointer_00 open without AppMap_00,
|
||||
// which the Scope has with them.
|
||||
// TOTK_MENU_CURSOR_LOG=1 logs the open screens whenever the set changes.
|
||||
enum { SM_COUNT = 0x8, SM_SCREENS = 0x10 };
|
||||
static int map_open(void) {
|
||||
#define DIALOGUE_SCREEN "MessageDialog_00" // the box a character's lines and the game's messages are shown in
|
||||
#define DIALOGUE_GAP_MS 500 // how long after the box closed a click is still the dialogue's
|
||||
static uint64_t dialogue_scr; // game thread only
|
||||
static int map_open(int *strip, int *camera) {
|
||||
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);
|
||||
*strip = *camera = 0;
|
||||
if (n <= 0 || n > 1024 || !ok_at(arr, 8ull * (uint64_t)n)) return 0;
|
||||
const char *e = cfg_get("TOTK_MENU_CURSOR_LOG");
|
||||
int verbose = e && !strcmp(e, "1"), pad = 0, map = 0, bg = 0;
|
||||
int verbose = e && !strcmp(e, "1"), pad = 0, map = 0, bg = 0, pointer = 0;
|
||||
char list[1024];
|
||||
size_t len = 0;
|
||||
uint64_t h = 1469598103934665603ull;
|
||||
@@ -187,6 +207,9 @@ static int map_open(void) {
|
||||
pad |= !strcmp(nm, "AppMenuOverlay_00");
|
||||
map |= !strcmp(nm, "AppMap_00");
|
||||
bg |= !strcmp(nm, "AppMenuBG_00");
|
||||
if (!strcmp(nm, DIALOGUE_SCREEN)) dialogue_scr = scr;
|
||||
pointer |= !strcmp(nm, "CameraPointer_00");
|
||||
*strip |= !strcmp(nm, "ShortCut_00");
|
||||
if (!verbose) continue;
|
||||
for (const char *c = nm; *c; c++) h = (h ^ (uint8_t)*c) * 1099511628211ull;
|
||||
if (len < sizeof list - 64) len += (size_t)snprintf(list + len, sizeof list - len, "%s%s", len ? " " : "", nm);
|
||||
@@ -194,8 +217,22 @@ static int map_open(void) {
|
||||
static uint64_t last;
|
||||
static int lines;
|
||||
if (verbose && h != last && lines < 200) last = h, lines++, rt_log("menu_cursor: open screens: %s", list);
|
||||
*camera = pad && pointer && !map && !bg;
|
||||
return pad && map && bg;
|
||||
}
|
||||
// The dialogue window is open. Read at every pad read from the screen the last scan found open, so a click follows the
|
||||
// box without the scan's 100 ms: the game keeps its screens, so the one found once is the one that opens the next time.
|
||||
// A screen that is no longer that layout (a reload built the screens again) is forgotten until a scan finds it.
|
||||
static int dialogue_shown(void) {
|
||||
uint64_t scr = dialogue_scr;
|
||||
if (!scr) return 0;
|
||||
if (!game_object(scr, SCR_REQUEST + 1)) { dialogue_scr = 0; return 0; }
|
||||
if (rd8(scr + SCR_STATE) != SCR_OPENED) return 0;
|
||||
char nm[48];
|
||||
layout_name(scr, nm, sizeof nm);
|
||||
if (strcmp(nm, DIALOGUE_SCREEN)) { dialogue_scr = 0; return 0; }
|
||||
return 1;
|
||||
}
|
||||
static void layout_size(uint64_t scr, float *lw, float *lh) {
|
||||
*lw = 1920, *lh = 1080;
|
||||
uint64_t lyt = rd64(scr + SCR_LAYOUT);
|
||||
@@ -280,15 +317,29 @@ static int gameplay_screen(const char *nm) {
|
||||
|
||||
static volatile int32_t g_pointer; // a menu has the pointer: input_cursor_allowed releases the capture
|
||||
static volatile int32_t g_map; // the Purah Pad's map is open (not the Scope): the mouse moves its cursor
|
||||
static volatile int32_t g_dialogue; // a dialogue box is on screen and TOTK_DIALOGUE_CLICK is on: left B, right A
|
||||
static volatile int32_t g_menu; // a menu screen has the focus box, from either device (the scroll wheel's steps)
|
||||
static volatile int32_t g_strip; // a D-pad strip's screen is open (the scroll wheel's steps along it)
|
||||
static volatile int32_t g_camera; // the Purah Pad's camera is open (the scroll wheel zooms it)
|
||||
|
||||
int menu_cursor_pointer(void) { return __atomic_load_n(&g_pointer, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_map(void) { return __atomic_load_n(&g_map, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_dialogue(void) { return __atomic_load_n(&g_dialogue, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_menu(void) { return __atomic_load_n(&g_menu, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_strip(void) { return __atomic_load_n(&g_strip, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_camera(void) { return __atomic_load_n(&g_camera, __ATOMIC_RELAXED); }
|
||||
|
||||
static int enabled(void) {
|
||||
if (!RT_V143) return 0;
|
||||
const char *v = cfg_get("TOTK_MENU_CURSOR"), *in = cfg_get("TOTK_INPUT");
|
||||
return !(v && !strcmp(v, "0")) && !(in && !strcmp(in, "none"));
|
||||
}
|
||||
// The left click in dialogue: its own setting, on with the menu cursor off too
|
||||
static int dialogue_enabled(void) {
|
||||
if (!RT_V143) return 0;
|
||||
const char *in = cfg_get("TOTK_INPUT");
|
||||
return cfg_bool("TOTK_DIALOGUE_CLICK") && !(in && !strcmp(in, "none"));
|
||||
}
|
||||
|
||||
static void set_pointer(int on) {
|
||||
if (plat_xchg32(&g_pointer, on) == on) return;
|
||||
@@ -317,27 +368,68 @@ static void log_screen(const Focus *f, const char *nm, int n, float lw, float lh
|
||||
|
||||
// Once per pad read on the game thread: the pointer's hover and clicks, as pad buttons (A, B) for this read
|
||||
void menu_cursor_poll(uint64_t *buttons) {
|
||||
static int inited, pending_a, held_l, held_r;
|
||||
static int inited, pending_a, held_l, held_r, anchored;
|
||||
static uint64_t pending_node, pending_until, hold_until, hold_bit, menu_seen;
|
||||
static float last_px = -1, last_py = -1;
|
||||
static uint64_t ptr_node, last_focus; // the item the pointer last pointed at, the focus at the last read
|
||||
static float last_px = -1, last_py = -1, anchor_px, anchor_py;
|
||||
if (!inited) {
|
||||
inited = 1;
|
||||
main_lo = MOD_MAIN_BASE, main_hi = MOD_MAIN_BASE + MAIN_SIZE;
|
||||
if (RT_V143) rt_log("menu_cursor: on for 1.4.3 (TOTK_MENU_CURSOR=0 turns it off)");
|
||||
}
|
||||
if (!enabled()) { set_pointer(0); __atomic_store_n(&g_map, 0, __ATOMIC_RELAXED); return; }
|
||||
Focus f = focus_now();
|
||||
char nm[48] = "";
|
||||
if (f.screen) layout_name(f.screen, nm, sizeof nm);
|
||||
int cursor = enabled(), talk = dialogue_enabled();
|
||||
if (!cursor && !talk) {
|
||||
set_pointer(0);
|
||||
__atomic_store_n(&g_map, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_dialogue, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_menu, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_strip, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_camera, 0, __ATOMIC_RELAXED);
|
||||
return;
|
||||
}
|
||||
// The open screens are scanned every 100 ms, not at every pad read: each screen costs memory queries
|
||||
uint64_t now = plat_now_ms();
|
||||
static uint64_t map_at;
|
||||
static int map, map_logged;
|
||||
if (!map_at || now - map_at >= 100) map_at = now, map = map_open();
|
||||
static int map, map_logged, dialogue_logged, strip, camera;
|
||||
if (!map_at || now - map_at >= 100) map_at = now, map = map_open(&strip, &camera);
|
||||
// Between two lines of a conversation the game closes the box and opens it again, so a click made in that gap still
|
||||
// counts as dialogue for DIALOGUE_GAP_MS after the box was last open. The first clicks after a conversation fall
|
||||
// in it too and are B or A, as they are for a player who taps the button through the last line.
|
||||
// TOTK_MENU_CURSOR_LOG=1 logs how long each gap was.
|
||||
static uint64_t dialogue_seen;
|
||||
int box = talk && dialogue_shown();
|
||||
if (!talk) dialogue_seen = 0;
|
||||
if (box) {
|
||||
static int gap_lines;
|
||||
const char *e = cfg_get("TOTK_MENU_CURSOR_LOG");
|
||||
uint64_t gap = dialogue_seen ? now - dialogue_seen : 0;
|
||||
if (gap > 30 && gap < 5000 && gap_lines < 100 && e && !strcmp(e, "1"))
|
||||
gap_lines++, rt_log("menu_cursor: the dialogue box was closed for %llu ms", (unsigned long long)gap);
|
||||
dialogue_seen = now;
|
||||
}
|
||||
int dialogue = box || (dialogue_seen && now - dialogue_seen < DIALOGUE_GAP_MS);
|
||||
if (dialogue && !dialogue_logged)
|
||||
dialogue_logged = 1, rt_log("menu_cursor: a dialogue box is open (" DIALOGUE_SCREEN "): left click is B, "
|
||||
"right click A (TOTK_DIALOGUE_CLICK=1)");
|
||||
__atomic_store_n(&g_dialogue, dialogue, __ATOMIC_RELAXED);
|
||||
if (!cursor) {
|
||||
set_pointer(0);
|
||||
__atomic_store_n(&g_map, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_menu, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_strip, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_camera, 0, __ATOMIC_RELAXED);
|
||||
return;
|
||||
}
|
||||
__atomic_store_n(&g_strip, strip, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_camera, camera, __ATOMIC_RELAXED);
|
||||
Focus f = focus_now();
|
||||
char nm[48] = "";
|
||||
if (f.screen) layout_name(f.screen, nm, sizeof nm);
|
||||
if (map && !map_logged) map_logged = 1, rt_log("menu_cursor: the map is open: the mouse moves its cursor");
|
||||
__atomic_store_n(&g_map, map, __ATOMIC_RELAXED);
|
||||
// With the gamepad as the last device the menus stay as they are on the console: no pointer, the capture kept.
|
||||
// Moving the mouse (or a key) makes keyboard and mouse the last device and the pointer comes.
|
||||
__atomic_store_n(&g_menu, f.screen && !gameplay_screen(nm) && !map, __ATOMIC_RELAXED);
|
||||
int menu = f.screen && !gameplay_screen(nm) && ikb_foreground() && input_kbm_last();
|
||||
if (menu) menu_seen = now;
|
||||
// A menu's focus gap (a tab switch, a popup opening: no focus box for a frame or two) keeps the pointer where it
|
||||
@@ -352,7 +444,7 @@ void menu_cursor_poll(uint64_t *buttons) {
|
||||
return;
|
||||
}
|
||||
if (gap) return; // a click's focus request waits for the next screen
|
||||
if (!menu) { pending_a = 0; last_px = last_py = -1; return; }
|
||||
if (!menu) { pending_a = 0, anchored = 0, ptr_node = last_focus = 0; last_px = last_py = -1; return; }
|
||||
if (pending_a) { // the focus asked for by a click: A once it is there
|
||||
if (rd64(f.control + CTL_ACTIVE) == pending_node) {
|
||||
pending_a = 0, hold_until = now + 60, hold_bit = 1ull << B_A;
|
||||
@@ -366,11 +458,21 @@ void menu_cursor_poll(uint64_t *buttons) {
|
||||
if (click_r) { hold_until = now + 60, hold_bit = 1ull << B_B; *buttons |= hold_bit; return; }
|
||||
float px, py;
|
||||
if (!picture_pos(&px, &py)) return;
|
||||
// The focus moved to another item than the pointer's (the scroll wheel, the keys, the pad): the pointer takes it
|
||||
// back only after it has left a dead zone of DEAD_ZONE layout units around where it was then, so a hand resting on
|
||||
// the mouse does not undo a scroll. A click still acts at once.
|
||||
if (f.node != last_focus) {
|
||||
if (f.node != ptr_node) anchored = 1, anchor_px = px, anchor_py = py;
|
||||
last_focus = f.node;
|
||||
}
|
||||
int moved = fabsf(px - last_px) > 0.001f || fabsf(py - last_py) > 0.001f;
|
||||
if (!moved && !click_l) return;
|
||||
last_px = px, last_py = py;
|
||||
float lw, lh;
|
||||
layout_size(f.screen, &lw, &lh);
|
||||
if (anchored && !click_l && fabsf(px - anchor_px) * lw < DEAD_ZONE && fabsf(py - anchor_py) * lh < DEAD_ZONE)
|
||||
return;
|
||||
anchored = 0;
|
||||
Xf xf = screen_xf(f.screen);
|
||||
Pt p = {(px - 0.5f) * lw, (0.5f - py) * lh, px * 2 - 1, 1 - py * 2, NULL};
|
||||
if (xf.ok && !xf_plain(&xf, lw, lh)) p.t = &xf;
|
||||
@@ -379,6 +481,7 @@ void menu_cursor_poll(uint64_t *buttons) {
|
||||
log_screen(&f, nm, n, lw, lh, p.t, n && stale_hit_panes(n, btn, lw, lh, p.t));
|
||||
uint64_t at = n ? node_at(n, node, btn, &p, lw, lh) : 0;
|
||||
if (!at) return;
|
||||
ptr_node = at;
|
||||
if (at != f.node) move_focus(&f, at);
|
||||
if (click_l) {
|
||||
if (at == f.node) { hold_until = now + 60, hold_bit = 1ull << B_A; *buttons |= hold_bit; }
|
||||
|
||||
+3
-2
@@ -30,8 +30,9 @@ typedef struct {
|
||||
int kind, enabled;
|
||||
ModProblem problem;
|
||||
uint32_t replaced, added, overridden; // romfs.c: files served (replacing / added), files a higher mod serves
|
||||
uint32_t other_version; // files for another game version (RomFS *.Product.<n>.*, ExeFS patches
|
||||
// for another build), not used
|
||||
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
|
||||
uint32_t pending, pending_key; // ExeFS patch files the build lacks; FNV-1a of their names and contents
|
||||
|
||||
+206
-6
@@ -7,19 +7,30 @@
|
||||
// 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. 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.
|
||||
// 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.
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
enum { MOTION_RING = 64 };
|
||||
// A calibration skips CALIB_SETTLE samples (0.5 s at the sensor thread's 4 ms), then averages CALIB_SAMPLES (1 s).
|
||||
enum { MOTION_RING = 64, CALIB_SETTLE = 125, CALIB_SAMPLES = 250 };
|
||||
#define STALE_NS 200000000ull // no sample for 200 ms: no motion
|
||||
#define CALIB_TIMEOUT_NS 5000000000ull // 5 s without a sample: the attempt gives up
|
||||
// Largest per-axis standard deviation of the averaged samples (rad/s, about 2.3 deg/s) that still counts as holding
|
||||
// still. The spread, not the mean, tells a moved controller from a biased one: a factory bias shifts every sample
|
||||
// alike (0.14 rad/s on one Pro Controller's z axis) and passes, while the noise of a resting pad or a steady hand stays
|
||||
// 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
|
||||
|
||||
struct MotionFusion {
|
||||
PlatMutex lock;
|
||||
@@ -29,6 +40,15 @@ struct MotionFusion {
|
||||
double R[3][3]; // controller -> reference; row i = reference axis i in controller coordinates
|
||||
double angle[3];
|
||||
int restart;
|
||||
double gyro_bias[3]; // the controller's resting gyro (rad/s), subtracted from every sample while the switch is on
|
||||
int bias_valid; // gyro_bias holds a measured or loaded estimate, so a zero is a value
|
||||
int calibrating; // an attempt is collecting samples
|
||||
int calib_count; // samples of the attempt so far, the skipped settle samples included
|
||||
double calib_sum[3], calib_sq[3]; // sum and sum of squares of the averaged samples, per axis
|
||||
uint64_t calib_start_ns; // when the attempt started (the timeout)
|
||||
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
|
||||
};
|
||||
|
||||
MotionFusion *motion_new(void) {
|
||||
@@ -44,6 +64,7 @@ static MotionFusion *global;
|
||||
static void global_init(void *arg) {
|
||||
(void)arg;
|
||||
global = motion_new();
|
||||
global->persist = 1;
|
||||
}
|
||||
|
||||
MotionFusion *motion_global(void) {
|
||||
@@ -107,11 +128,115 @@ static void integrate(double R[3][3], const double gyro[3], const double acc[3],
|
||||
orthonormalize(R);
|
||||
}
|
||||
|
||||
void motion_feed(MotionFusion *m, const double acc[3], const double gyro[3], uint64_t now) {
|
||||
// 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) {
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof buf, "%.6f", bias[0]);
|
||||
cfg_set("TOTK_GYRO_BIAS_X", buf);
|
||||
snprintf(buf, sizeof buf, "%.6f", bias[1]);
|
||||
cfg_set("TOTK_GYRO_BIAS_Y", buf);
|
||||
snprintf(buf, sizeof buf, "%.6f", bias[2]);
|
||||
cfg_set("TOTK_GYRO_BIAS_Z", buf);
|
||||
cfg_set("TOTK_GYRO_BIAS_PAD", pad);
|
||||
// Saved now rather than at the menu's save tick, which may not run if the menu is closed first.
|
||||
if (cfg_save())
|
||||
rt_log("motion: gyro bias calibrated from %d samples: %.5f %.5f %.5f rad/s (spread %.4f rad/s)", CALIB_SAMPLES,
|
||||
bias[0], bias[1], bias[2], spread);
|
||||
else
|
||||
rt_log("motion: gyro bias %.5f %.5f %.5f rad/s could not be written to totk.ini; it applies to this run only",
|
||||
bias[0], bias[1], bias[2]);
|
||||
}
|
||||
|
||||
// The one timeout decision, for the sample path and the menu's poll alike: CALIB_TIMEOUT_NS without a sample since the
|
||||
// attempt started or since its last sample, so a slow sensor tick only lengthens the attempt. now may trail a sample
|
||||
// the sensor thread stored meanwhile; that is no timeout. Called with m->lock held; the caller logs, with the lock
|
||||
// released. A bias that is already in effect stays in effect and the row keeps reporting it; a controller with no
|
||||
// bias shows the failure.
|
||||
static int calib_check_timeout(MotionFusion *m, uint64_t now) {
|
||||
uint64_t since = m->last_ns > m->calib_start_ns ? m->last_ns : m->calib_start_ns;
|
||||
if (!m->calibrating || now <= since || now - since <= CALIB_TIMEOUT_NS) return 0;
|
||||
m->calibrating = 0;
|
||||
m->calib_result = m->bias_valid ? MOTION_CALIB_DONE : MOTION_CALIB_FAILED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// The bias's own switch (gyro_calibration, live, default 1): off, the fusion takes the raw gyro, an attempt in
|
||||
// progress is dropped, and the menu's calibrate entry does nothing. The saved keys stay untouched, so turning it
|
||||
// back on restores the last calibration.
|
||||
int motion_calibration_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_CALIBRATION");
|
||||
}
|
||||
return on;
|
||||
}
|
||||
|
||||
// One calibration sample, m->lock held. The first CALIB_SETTLE samples are skipped: the button press that started the
|
||||
// attempt shakes the controller. The next CALIB_SAMPLES are averaged per axis into the bias, unless their spread shows
|
||||
// the controller moved (CALIB_MAX_SPREAD). Returns 1 when the attempt ended with a new bias, -1 when it was rejected,
|
||||
// 0 while it goes on; *spread receives the largest per-axis standard deviation of a finished attempt.
|
||||
static int calib_sample(MotionFusion *m, const double g[3], double *spread) {
|
||||
if (++m->calib_count <= CALIB_SETTLE) return 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
m->calib_sum[i] += g[i];
|
||||
m->calib_sq[i] += g[i] * g[i];
|
||||
}
|
||||
if (m->calib_count < CALIB_SETTLE + CALIB_SAMPLES) return 0;
|
||||
m->calibrating = 0;
|
||||
double mean[3], worst = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
mean[i] = m->calib_sum[i] / CALIB_SAMPLES;
|
||||
double var = m->calib_sq[i] / CALIB_SAMPLES - mean[i] * mean[i];
|
||||
double sd = var > 0 ? sqrt(var) : 0;
|
||||
if (sd > worst) worst = sd;
|
||||
}
|
||||
*spread = worst;
|
||||
if (worst > CALIB_MAX_SPREAD) {
|
||||
m->calib_result = MOTION_CALIB_MOVED; // the bias in effect, if any, stays
|
||||
return -1;
|
||||
}
|
||||
memcpy(m->gyro_bias, mean, sizeof mean);
|
||||
m->bias_valid = 1;
|
||||
m->calib_result = MOTION_CALIB_DONE;
|
||||
m->restart = 1; // the angle and direction start over from the new bias
|
||||
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;
|
||||
char saved_pad[sizeof m->calib_pad] = "";
|
||||
int ended = 0, timed_out = 0, samples = 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
|
||||
m->last_ns = now;
|
||||
// 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) {
|
||||
m->calibrating = 0;
|
||||
m->calib_result = m->bias_valid ? MOTION_CALIB_DONE : MOTION_CALIB_NONE;
|
||||
}
|
||||
if (m->calibrating) {
|
||||
if (calib_check_timeout(m, now)) {
|
||||
timed_out = 1;
|
||||
samples = m->calib_count;
|
||||
started = m->calib_start_ns;
|
||||
} else if ((ended = calib_sample(m, gyro_raw, &spread)) != 0) {
|
||||
memcpy(saved, ended > 0 ? m->gyro_bias : m->calib_sum, sizeof saved);
|
||||
if (ended < 0)
|
||||
for (int i = 0; i < 3; i++) saved[i] /= CALIB_SAMPLES;
|
||||
snprintf(saved_pad, sizeof saved_pad, "%s", m->calib_pad);
|
||||
}
|
||||
}
|
||||
m->last_ns = now; // after the timeout check, which measures the gap before this sample
|
||||
// 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);
|
||||
if (m->restart) {
|
||||
align_to(m->R, acc);
|
||||
memset(m->angle, 0, sizeof m->angle);
|
||||
@@ -128,7 +253,20 @@ void motion_feed(MotionFusion *m, const double acc[3], const double gyro[3], uin
|
||||
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++;
|
||||
// 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 (timed_out)
|
||||
rt_log("motion: gyro calibration timed out after %.1f s (%d samples): sensor data not arriving",
|
||||
(now - started) / 1e9, samples);
|
||||
if (ended < 0)
|
||||
rt_log("motion: gyro calibration rejected, the controller moved: spread %.4f rad/s over the limit %.2f "
|
||||
"(mean %.5f %.5f %.5f rad/s)", spread, CALIB_MAX_SPREAD, saved[0], saved[1], saved[2]);
|
||||
if (ended > 0) {
|
||||
if (m->persist) save_bias(saved, saved_pad, spread);
|
||||
else rt_log("motion: gyro bias calibrated: %.5f %.5f %.5f rad/s (spread %.4f rad/s)", saved[0], saved[1],
|
||||
saved[2], spread);
|
||||
}
|
||||
}
|
||||
|
||||
int motion_read(MotionFusion *m, MotionState *out, int max, uint64_t now) {
|
||||
@@ -152,3 +290,65 @@ void motion_restart(MotionFusion *m) {
|
||||
memset(m->angle, 0, sizeof m->angle);
|
||||
plat_mutex_unlock(&m->lock);
|
||||
}
|
||||
|
||||
void motion_calibrate_start(MotionFusion *m, const char *pad, uint64_t now) {
|
||||
plat_mutex_lock(&m->lock);
|
||||
m->calibrating = 1;
|
||||
m->calib_count = 0;
|
||||
memset(m->calib_sum, 0, sizeof m->calib_sum);
|
||||
memset(m->calib_sq, 0, sizeof m->calib_sq);
|
||||
m->calib_start_ns = now;
|
||||
snprintf(m->calib_pad, sizeof m->calib_pad, "%s", pad ? pad : "");
|
||||
plat_mutex_unlock(&m->lock);
|
||||
}
|
||||
|
||||
// One axis of totk.ini; a value that is not a number leaves the axis at zero and is named in the log, so a
|
||||
// hand-edited or damaged line does not silently read as a calibrated zero.
|
||||
static double bias_value(const char *key) {
|
||||
const char *v = cfg_get(key);
|
||||
if (!v || !*v) return 0;
|
||||
char *end;
|
||||
double d = strtod(v, &end);
|
||||
if (end == v || *end || !isfinite(d)) {
|
||||
rt_log("motion: %s = \"%s\" is not a number; that axis starts uncalibrated", key, v);
|
||||
return 0;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
void motion_bias_load(MotionFusion *m) {
|
||||
double bias[3] = {bias_value("TOTK_GYRO_BIAS_X"), bias_value("TOTK_GYRO_BIAS_Y"), bias_value("TOTK_GYRO_BIAS_Z")};
|
||||
plat_mutex_lock(&m->lock);
|
||||
memcpy(m->gyro_bias, bias, sizeof bias);
|
||||
m->bias_valid = 1;
|
||||
m->calib_result = MOTION_CALIB_DONE;
|
||||
plat_mutex_unlock(&m->lock);
|
||||
}
|
||||
|
||||
void motion_bias_reset(MotionFusion *m) {
|
||||
plat_mutex_lock(&m->lock);
|
||||
memset(m->gyro_bias, 0, sizeof m->gyro_bias);
|
||||
// An attempt that was collecting belongs to the previous controller: its samples must not complete against this
|
||||
// one, and its name must not label a bias measured from another controller.
|
||||
m->calibrating = 0;
|
||||
m->calib_count = 0;
|
||||
m->calib_pad[0] = 0;
|
||||
m->calib_result = MOTION_CALIB_NONE;
|
||||
m->bias_valid = 0;
|
||||
plat_mutex_unlock(&m->lock);
|
||||
}
|
||||
|
||||
// Also ends an attempt whose samples stopped (the sensor thread no longer calls motion_feed): without this the row
|
||||
// would read "Calibrating..." forever. Logs with the lock released: the menu thread calls this on every redraw.
|
||||
int motion_calib_poll(MotionFusion *m, uint64_t now) {
|
||||
plat_mutex_lock(&m->lock);
|
||||
int timed_out = calib_check_timeout(m, now);
|
||||
int st = m->calibrating ? MOTION_CALIB_COLLECTING : m->calib_result;
|
||||
uint64_t start = m->calib_start_ns;
|
||||
int count = m->calib_count;
|
||||
plat_mutex_unlock(&m->lock);
|
||||
if (timed_out)
|
||||
rt_log("motion: gyro calibration timed out after %.1f s (%d samples): the sensor thread stopped feeding it",
|
||||
(now - start) / 1e9, count);
|
||||
return st;
|
||||
}
|
||||
@@ -121,6 +121,8 @@ void input_direct_mouse_row(int32_t dx, float sensitivity, uint64_t now, InputMo
|
||||
#define HOST_MOUSE_HAND (RT_PATCH_PAGE + 0xf90)
|
||||
#define HOST_MOUSE_ORBIT_STATE (RT_PATCH_PAGE + 0xf70)
|
||||
static _Thread_local uint64_t mouse_input_object;
|
||||
static volatile int32_t cam_blocked, cam_kind;
|
||||
static uint64_t cam_kind_at;
|
||||
|
||||
// Where a game version keeps what the hooks read and write (recomp/patches-v143.txt, patches-v121.txt). The camera
|
||||
// input update keeps its flags in w21, its input object in x20 and y in s10 in both; the free orbit's object is x0 at
|
||||
@@ -362,6 +364,7 @@ static void camera_input(Cpu *c) {
|
||||
const unsigned rx = mouse_layout()->input_x;
|
||||
mouse_input_object = 0;
|
||||
uint32_t flags = (uint32_t)c->x[21];
|
||||
__atomic_store_n(&cam_blocked, (flags & 1) != 0, __ATOMIC_RELAXED);
|
||||
int accept = !(flags & 1) && !input_direct_mouse_selector_active();
|
||||
__atomic_store_n(&accepts_mouse, accept, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&last_update, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
@@ -456,6 +459,8 @@ static void camera_input(Cpu *c) {
|
||||
// directly and move its persistent pitch/yaw by the same amounts so the next update starts at the new orientation.
|
||||
// The controller still handles its gamepad input, following, collision and focus normally.
|
||||
static void orbit_begin(Cpu *c) {
|
||||
__atomic_store_n(&cam_kind, INPUT_CAM_FREE_ROAM, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&cam_kind_at, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
orbit.object = 0;
|
||||
uint64_t object = c->x[0];
|
||||
if (direct_mode()) {
|
||||
@@ -1034,6 +1039,45 @@ static void camera_load(Cpu *c) {
|
||||
rt_log("mouse: load hook called from main+%#llx, no such site", (unsigned long long)offset);
|
||||
abort();
|
||||
}
|
||||
int mapped = INPUT_CAM_UNCLASSIFIED;
|
||||
switch (s->mode) {
|
||||
case MODE_AIM:
|
||||
case MODE_LOCKON_AIM:
|
||||
mapped = INPUT_CAM_AIM;
|
||||
break;
|
||||
case MODE_SCOPE:
|
||||
case MODE_FINDER:
|
||||
mapped = INPUT_CAM_SCOPE;
|
||||
break;
|
||||
case MODE_ABILITY:
|
||||
case MODE_ABILITY_OFFSET:
|
||||
mapped = INPUT_CAM_ABILITY;
|
||||
break;
|
||||
case MODE_LOCKON:
|
||||
mapped = INPUT_CAM_LOCK_ON;
|
||||
break;
|
||||
case MODE_HORSE:
|
||||
case MODE_HORSE_LOCKON:
|
||||
mapped = INPUT_CAM_VEHICLE;
|
||||
break;
|
||||
case MODE_TALK:
|
||||
case MODE_TALK_MANUAL:
|
||||
mapped = INPUT_CAM_DISABLED;
|
||||
break;
|
||||
case MODE_CLIMB:
|
||||
case MODE_WAKEBOARD:
|
||||
case MODE_SHIELD:
|
||||
case MODE_WATERFALL:
|
||||
case MODE_TAIL:
|
||||
mapped = INPUT_CAM_FREE_ROAM;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (mapped != INPUT_CAM_UNCLASSIFIED) {
|
||||
__atomic_store_n(&cam_kind, mapped, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&cam_kind_at, plat_now_ns(), __ATOMIC_RELEASE);
|
||||
}
|
||||
uint64_t at = load_address(c, s->insn);
|
||||
if (s->role == ROLE_BASE_STORE) { // performs the store, of the value plus the degrees when there are any
|
||||
uint32_t bits = (uint32_t)c->v[s->insn & 31];
|
||||
@@ -1099,4 +1143,23 @@ __attribute__((constructor)) static void mouse_direct_register(void) {
|
||||
rt_register_host(HOST_MOUSE_HAND, hand_input);
|
||||
rt_register_host(HOST_MOUSE_LOAD, camera_load);
|
||||
}
|
||||
|
||||
int input_camera_context(void) {
|
||||
static int patch_id = -2;
|
||||
if (patch_id == -2) patch_id = rt_patch_set("mouse_direct");
|
||||
if (patch_id < 0 || !rt_patch_enabled(patch_id)) return INPUT_CAM_UNCLASSIFIED;
|
||||
uint64_t now = plat_now_ns();
|
||||
if (hand_active(now)) return INPUT_CAM_ULTRAHAND_OBJECT;
|
||||
uint64_t kat = __atomic_load_n(&cam_kind_at, __ATOMIC_ACQUIRE);
|
||||
int kind = (kat && now - kat < 150000000ull) ? __atomic_load_n(&cam_kind, __ATOMIC_RELAXED) : INPUT_CAM_UNCLASSIFIED;
|
||||
if (kind == INPUT_CAM_SCOPE || kind == INPUT_CAM_AIM) return kind;
|
||||
uint64_t last = __atomic_load_n(&last_update, __ATOMIC_ACQUIRE);
|
||||
int cam_alive = last && now - last < 150000000ull;
|
||||
if (cam_alive && __atomic_load_n(&cam_blocked, __ATOMIC_RELAXED)) return INPUT_CAM_MENU_WHEEL;
|
||||
if (kind != INPUT_CAM_UNCLASSIFIED) return kind;
|
||||
if (cam_alive) return INPUT_CAM_FREE_ROAM;
|
||||
return INPUT_CAM_UNCLASSIFIED;
|
||||
}
|
||||
#else
|
||||
int input_camera_context(void) { return INPUT_CAM_UNCLASSIFIED; }
|
||||
#endif
|
||||
@@ -435,6 +435,7 @@ int probe_movie(void) {
|
||||
C = plat_aligned_alloc(sizeof(Cpu), 64);
|
||||
CHECK(C, "Cpu allocation");
|
||||
memset(C, 0, sizeof *C);
|
||||
rt_fpcr_threshold(C);
|
||||
|
||||
uint64_t obj_mem[2] = {0}, obj = U(obj_mem);
|
||||
volatile int32_t ev[4] = {0};
|
||||
|
||||
@@ -494,7 +494,7 @@ static int sync_ahead(void) {
|
||||
// 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 (TOTK_SHADOW=1 on native Windows); "
|
||||
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");
|
||||
on = 0;
|
||||
}
|
||||
|
||||
@@ -687,6 +687,8 @@ NVN_API(nvnWindowAcquireTexture) {
|
||||
sleep_until(at);
|
||||
perf_end(PERF_PACE, p0);
|
||||
}
|
||||
vk_reflex_sleep();
|
||||
vk_reflex_marker(0, vk_reflex_frame_begin()); // VK_LATENCY_MARKER_SIMULATION_START_NV: a new frame and its ID
|
||||
// The sync means "the display no longer reads this image". Presents are copies queued in submit order, so it is
|
||||
// already satisfied: fenced = 3 with fence 0.
|
||||
if (s) {
|
||||
@@ -710,6 +712,7 @@ NVN_API(nvnQueuePresentTexture) {
|
||||
if (o->magic != NVN_WIN_MAGIC || idx < 0 || idx >= o->ntex || idx >= 4 || !o->tex[idx])
|
||||
rt_fatal("nvn: QueuePresentTexture of image %d on window %p", idx, (void *)o);
|
||||
o->presents++;
|
||||
vk_reflex_marker(1, vk_reflex_frame()); // VK_LATENCY_MARKER_SIMULATION_END_NV
|
||||
const tex_t *t = (const tex_t *)o->tex[idx];
|
||||
uint64_t period = present_period(o), now = kern_now_ns();
|
||||
uint64_t slot = now + pace(&o->pace, now, period);
|
||||
|
||||
+5
-2
@@ -1,5 +1,6 @@
|
||||
// Ported from MacNativeGames games/totk/third_party/d2r_gfx/gfx/nvn/nvn_hmap.h @ b75be8cf (MIT, Copyright (c) 2026
|
||||
// jhaizhou; origin d2r-mobile); Chinese duplicate comments dropped, code unchanged.
|
||||
// jhaizhou; origin d2r-mobile); Chinese duplicate comments dropped, code unchanged but for
|
||||
// nvn_hm_get's key compare (MX_EQ, memx.h).
|
||||
//
|
||||
// Open-addressing hash table from fixed-length byte keys -> pointers (linear probing + backward shift on deletion, no
|
||||
// tombstones). The replay hot path uses it instead of a boxed dictionary: keys are not boxed, no allocation, a lookup
|
||||
@@ -11,6 +12,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "memx.h"
|
||||
|
||||
typedef struct { uint8_t *keys; void **vals; uint32_t klen, cap, n; } nvn_hmap; // vals[i] == NULL means an empty slot
|
||||
|
||||
static inline uint64_t nvn_hm_hash(const void *k, uint32_t len) {
|
||||
@@ -25,7 +28,7 @@ static inline void *nvn_hm_get(const nvn_hmap *m, const void *k) {
|
||||
if (!m->n) return NULL;
|
||||
for (uint32_t i = (uint32_t)nvn_hm_hash(k, m->klen) & (m->cap - 1);; i = (i + 1) & (m->cap - 1)) {
|
||||
if (!m->vals[i]) return NULL;
|
||||
if (!memcmp(m->keys + (size_t)i * m->klen, k, m->klen)) return m->vals[i];
|
||||
if (MX_EQ(m->keys + (size_t)i * m->klen, k, m->klen)) return m->vals[i];
|
||||
}
|
||||
}
|
||||
static inline void *nvn_hm_put(nvn_hmap *m, const void *k, void *v);
|
||||
|
||||
@@ -919,6 +919,7 @@ int probe_nvn(void) {
|
||||
if (child && *child) return run_as_child(child);
|
||||
// The probe checks the null back end whatever TOTK_GPU says; the choice is made once, at the first object call.
|
||||
((RtConfig *)rt_config())->gpu = "null";
|
||||
rt_fpcr_threshold(&cpu); // the FP result check threshold of a fresh Cpu (cpu.h): a zeroed one is wrong, not slow
|
||||
nvn_procs_register();
|
||||
hostfn_seal();
|
||||
kern_run_on_guest_main(probe_main);
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
// Recall and Ultrahand target check (patch set "ability", recomp/patches-v143.txt and patches-v121.txt).
|
||||
//
|
||||
// main+0x1bd0138 on 1.4.3 (main+0x1622b60 on 1.2.1, the same code and actor offsets) runs while an ability picks its
|
||||
// target. Once the owner's request says ready, it loads the result holder from the owner (x8 = [x19+0x6b0]), the
|
||||
// target actor from the holder (x21 = [x8]), links the actor (main+0x155ec: reads the actor's +0x10, +0x24 and
|
||||
// +0x1a8), reads [[x21+0x228]+0xb0] (main+0x9a89d4) and takes a reference on that (main+0x2b8464: an atomic
|
||||
// read-modify-write of the word at +0x90). The holder can be reused memory by then, and the game crashes reading
|
||||
// 0xffffffffffffffff (Windows' report of a non-canonical address) minutes to hours into play. UltraTears
|
||||
// (kuraeow/ultratears, "ability target guard") found the class; this code is ours.
|
||||
//
|
||||
// A target is dropped only where the game's own code would fault on it: the holder or the actor unreadable, a link
|
||||
// record the game follows unreadable or read-only, the component pointer unreadable, or the reference word
|
||||
// unreadable or in a module's code or read-only data. Every
|
||||
// other target goes on exactly as the game reads it, so no target the game can handle is ever lost. UltraTears' test
|
||||
// of a live actor (its link record [actor+0x1a8] points back to it at +0x40 and carries its id at +0x48) is not in the
|
||||
// game's code: the game links an actor whose link record is null without complaint. It runs here as a log line only,
|
||||
// to show in players' logs whether it would ever reject a live target.
|
||||
//
|
||||
// The first site replaces `ldr x21, [x8]` with a call here; the second, at the game's `cbz x21` right after it, becomes
|
||||
// `mov x21, x9; cbz x21`. The answer travels in x9 because the lifted caller keeps x21 (callee-saved) in a C local
|
||||
// across the call and reloads only caller-saved registers; x9 is dead there on every path. x9 gets the holder's first
|
||||
// word, or 0 for a dropped target, which the cbz skips for this frame as it skips an empty one. A null or tagged
|
||||
// (bit 0) word goes back unchanged: the game skips those itself. No other register changes.
|
||||
// Only an ability's target pick reaches this (hundreds of calls an hour), so the memory queries cost nothing.
|
||||
#include <stdint.h>
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#if __has_include("patches.h")
|
||||
#include "patches.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_PATCH_PAGE
|
||||
|
||||
#define HOST_ABILITY_TARGET (RT_PATCH_PAGE + 0xf60)
|
||||
#define ACTOR_SPAN 0x230 // the actor fields the function and its callees read: +0x10 .. +0x22f
|
||||
|
||||
static int readable(uint64_t a, uint64_t n) { return a && !(a & 3) && mem_guest_readable(a, n); }
|
||||
|
||||
static uint64_t u64_at(uint64_t a) { return *(volatile uint64_t *)(uintptr_t)a; }
|
||||
static uint32_t u32_at(uint64_t a) { return *(volatile uint32_t *)(uintptr_t)a; }
|
||||
|
||||
// [a, a+4) inside a module's code or read-only data: a write there faults.
|
||||
static int read_only_module(uint64_t a) {
|
||||
for (int i = 0; i < ldr_count(); i++) {
|
||||
const RtLoaded *m = ldr_module(i);
|
||||
if (a - m->base < m->size) return a - m->base < m->data_off;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NULL when the game's code can follow the actor without a fault, else what would fault.
|
||||
static const char *faults(uint64_t actor) {
|
||||
if (!readable(actor, ACTOR_SPAN)) return "actor not readable";
|
||||
// main+0x155ec (1.2.1: main+0x809ecc) follows a non-null link record unless the actor's state word +0x24 is 7..11:
|
||||
// it stores the record in the owner, updates +0x50 atomically (main+0x15838) and later compares +0x40 and +0x48.
|
||||
uint64_t link = u64_at(actor + 0x1a8);
|
||||
if (link && u32_at(actor + 0x24) - 7 >= 5 &&
|
||||
(!readable(link + 0x40, 0x18) || read_only_module(link + 0x50)))
|
||||
return "link record not writable";
|
||||
uint64_t comp = u64_at(actor + 0x228);
|
||||
if (!comp) return NULL; // main+0x9a89d4 returns 0 for it and the game stops there
|
||||
if (!readable(comp + 0xb0, 8)) return "component not readable";
|
||||
uint64_t ref = u64_at(comp + 0xb0);
|
||||
if (!ref) return NULL; // the game's cbz x0 skips the reference
|
||||
if (!readable(ref + 0x90, 4) || read_only_module(ref + 0x90)) return "reference word not writable";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// UltraTears' live-actor test, for the log: NULL when it passes.
|
||||
static const char *not_live(uint64_t actor) {
|
||||
uint64_t link = u64_at(actor + 0x1a8);
|
||||
if (!readable(link + 0x40, 0x10)) return "link record not readable";
|
||||
if (u64_at(link + 0x40) != actor) return "link record points elsewhere";
|
||||
if (u32_at(link + 0x48) != u32_at(actor + 0x10)) return "link record has another id";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void host_ability_target(Cpu *c) {
|
||||
static uint64_t checked, dropped, mismatched;
|
||||
uint64_t holder = c->x[8], actor = 0;
|
||||
const char *why = NULL;
|
||||
if (!readable(holder, 8)) why = "holder not readable";
|
||||
else if ((actor = u64_at(holder)) && !(actor & 1)) why = faults(actor);
|
||||
if (why) {
|
||||
c->x[9] = 0;
|
||||
uint64_t n = __atomic_add_fetch(&dropped, 1, __ATOMIC_RELAXED);
|
||||
if (n <= 20 || !(n & (n - 1)))
|
||||
rt_log("ability: target dropped, the game would fault on it (%s): holder %#llx actor %#llx; %llu dropped",
|
||||
why, (unsigned long long)holder, (unsigned long long)actor, (unsigned long long)n);
|
||||
return;
|
||||
}
|
||||
c->x[9] = actor;
|
||||
if (!actor || (actor & 1)) return;
|
||||
uint64_t k = __atomic_add_fetch(&checked, 1, __ATOMIC_RELAXED);
|
||||
const char *odd = not_live(actor);
|
||||
if (!odd) {
|
||||
if (k == 1) rt_log("ability: first target checked (TOTK_ABILITY_GUARD=0: no check)");
|
||||
return;
|
||||
}
|
||||
uint64_t n = __atomic_add_fetch(&mismatched, 1, __ATOMIC_RELAXED);
|
||||
if (n <= 20 || !(n & (n - 1)))
|
||||
rt_log("ability: target kept although the live-actor test fails (%s): actor %#llx; %llu of %llu targets", odd,
|
||||
(unsigned long long)actor, (unsigned long long)n, (unsigned long long)k);
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void ability_register(void) {
|
||||
rt_register_host(HOST_ABILITY_TARGET, host_ability_target);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "gfx.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "ov.h"
|
||||
@@ -93,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);
|
||||
vk_reflex_marker(6, vk_reflex_frame()); // VK_LATENCY_MARKER_INPUT_SAMPLE_NV
|
||||
}
|
||||
*out = s;
|
||||
ret_x(c, 1);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <opus/opus.h>
|
||||
|
||||
#include "host.h"
|
||||
#include "audio_cat.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define CODEC_R_INVALID 0x1fcd1u // MacNativeGames' "invalid argument" result for nn::codec
|
||||
@@ -153,6 +154,7 @@ static void ov_decode(Cpu *c) {
|
||||
int got = opus_decode(d->dec, in + 8, (opus_int32)n, out, (int)capacity, 0);
|
||||
opus_uint32 final = 0;
|
||||
if (got >= 0) opus_decoder_ctl(d->dec, OPUS_GET_FINAL_RANGE(&final));
|
||||
int channels = d->channels;
|
||||
release(d);
|
||||
if (got < 0) {
|
||||
rt_log("nn::codec: opus_decode: %s", opus_strerror(got));
|
||||
@@ -163,6 +165,8 @@ static void ov_decode(Cpu *c) {
|
||||
rt_log("nn::codec: Opus final range %#x != stream %#x (logged once)", (unsigned)final, (unsigned)range);
|
||||
*consumed = 8 + n;
|
||||
*samples = got;
|
||||
if (got > 0 && audio_cat_active()) // the PCM's sound category for the music / effects / voice volumes
|
||||
audio_cat_on_opus_decode(guest, (uint64_t)(uintptr_t)in, (uint64_t)(uintptr_t)out, (uint64_t)got * (uint64_t)channels * sizeof(int16_t));
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -618,6 +618,43 @@ static void probe_feedback(uint32_t pid, uint32_t style) {
|
||||
near3(ms[0].dir, 1, 0, 0, 0.01),
|
||||
"fusion restart: %d states in the frame of the Start, %d after one sample (sampling %lld, angle %.4f rev)", same,
|
||||
next, (long long)ms[0].sampling, (double)ms[0].angle[2]);
|
||||
// Gyro bias calibration on the private instance (not written to totk.ini): a large steady bias with resting noise
|
||||
// is measured and then subtracted, so a resting controller reads no rotation and its yaw holds; samples that swing
|
||||
// (the controller moved) are rejected and leave the measured bias in effect; an attempt without samples times out.
|
||||
const double bias[3] = {-0.031, -0.011, -0.141};
|
||||
double g[3];
|
||||
motion_calibrate_start(m, "probe pad", t);
|
||||
for (int i = 0; i < 375; i++) {
|
||||
for (int j = 0; j < 3; j++) g[j] = bias[j] + (i & 1 ? 0.01 : -0.01);
|
||||
motion_feed(m, down, g, t += 4000000);
|
||||
}
|
||||
int done = motion_calib_poll(m, t);
|
||||
for (int i = 0; i < 250; i++) motion_feed(m, down, bias, t += 4000000);
|
||||
motion_read(m, ms, 1, t + 1000000);
|
||||
CHECK(done == MOTION_CALIB_DONE && near3(ms[0].gyro, 0, 0, 0, 1e-4) && fabs(ms[0].angle[2]) < 1e-3 &&
|
||||
near3(ms[0].dir, 1, 0, 0, 0.001),
|
||||
"calibration: state %d, resting gyro %.5f %.5f %.5f rev/s, yaw %.5f rev after 1 s", done,
|
||||
(double)ms[0].gyro[0], (double)ms[0].gyro[1], (double)ms[0].gyro[2], (double)ms[0].angle[2]);
|
||||
motion_calibrate_start(m, "probe pad", t);
|
||||
for (int i = 0; i < 375; i++) {
|
||||
for (int j = 0; j < 3; j++) g[j] = bias[j] + (j == 0 && (i & 1) ? 0.2 : 0);
|
||||
motion_feed(m, down, g, t += 4000000);
|
||||
}
|
||||
int moved = motion_calib_poll(m, t);
|
||||
motion_feed(m, down, bias, t += 4000000);
|
||||
motion_read(m, ms, 1, t + 1000000);
|
||||
CHECK(moved == MOTION_CALIB_MOVED && near3(ms[0].gyro, 0, 0, 0, 1e-4),
|
||||
"calibration of a moving controller: state %d, resting gyro %.5f %.5f %.5f rev/s", moved,
|
||||
(double)ms[0].gyro[0], (double)ms[0].gyro[1], (double)ms[0].gyro[2]);
|
||||
motion_bias_reset(m);
|
||||
motion_calibrate_start(m, "probe pad", t);
|
||||
int waiting = motion_calib_poll(m, t + 1000000000ull), failed = motion_calib_poll(m, t + 6000000000ull);
|
||||
motion_feed(m, down, bias, t += 4000000);
|
||||
motion_read(m, ms, 1, t + 1000000);
|
||||
CHECK(waiting == MOTION_CALIB_COLLECTING && failed == MOTION_CALIB_FAILED &&
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "audio_cat.h"
|
||||
|
||||
#if __has_include("patches.h")
|
||||
#include "patches.h"
|
||||
@@ -235,6 +236,10 @@ static void decode(Cpu *c, uint64_t dict, uint64_t dict_size, uint64_t ddict, ui
|
||||
}
|
||||
c->x[0] = r;
|
||||
count(size, r, kern_now_ns() - t0);
|
||||
// A sound bank (BARS) for the music / effects / voice volumes (audio_cat.c); its compressed bytes were tagged
|
||||
// by the RomFS read, which gives the bank's category.
|
||||
if (r >= 16 && !memcmp((const void *)(uintptr_t)dst, "BARS", 4) && audio_cat_active())
|
||||
audio_cat_scan_bars(dst, (uint64_t)r, audio_cat_lookup(src));
|
||||
}
|
||||
|
||||
static void host_multiframe(Cpu *c) { decode(c, c->x[5], c->x[6], c->x[7], GUEST_MULTIFRAME, 8); }
|
||||
|
||||
+138
-2
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <SDL3/SDL_clipboard.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "platform.h"
|
||||
|
||||
// The write-watch ABI of Linux 6.7 (uapi linux/fs.h and linux/userfaultfd.h), for headers older than it: the release
|
||||
@@ -1250,7 +1251,135 @@ const char *plat_user_locale(void) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Noto CJK as the common distributions and SteamOS install it; one collection covers every CJK language.
|
||||
// A CJK font for the menu: the file that draws this language on this system.
|
||||
//
|
||||
// The languages the catalog has (ja, ko, zh-Hans, zh-Hant) are not covered by the font built into the menu, so their
|
||||
// glyphs are merged in from a system file. Distributions disagree on where Noto CJK lives, and a sandboxed build
|
||||
// (Flatpak, Snap, an AppImage on a host whose fonts are mounted at /run/host/fonts) may have no Noto CJK where the
|
||||
// fixed paths expect it while the host still has CJK fonts that would do. So ask fontconfig first: it is the database
|
||||
// Tk/Xft and every other Linux toolkit reads, it knows /app/share/fonts, the XDG data dirs, /run/host/fonts and the
|
||||
// per-user dirs, and adding a font there is enough -- the menu does not need to learn about it. The fixed
|
||||
// distribution paths stay as the fallback for a system without fontconfig, and TOTK_MENU_FONT overrides both.
|
||||
//
|
||||
// fontconfig is loaded with dlopen rather than linked, so a host without libfontconfig (a bare container) still builds
|
||||
// and runs and just takes the fallback. The runtime already links -ldl for the NVIDIA libraries.
|
||||
|
||||
static int cjk_lang(const char *lang) {
|
||||
return !strcmp(lang, "ja") || !strcmp(lang, "ko") || !strcmp(lang, "zh-Hans") || !strcmp(lang, "zh-Hant");
|
||||
}
|
||||
|
||||
// The fontconfig language tag of a catalog language. GL says zh-Hans/zh-Hant, but fontconfig and OpenType name the
|
||||
// faces zh-cn/zh-tw (Noto Sans CJK SC is lang=zh-cn), and a pattern naming only zh-hans does not reach it.
|
||||
static const char *cjk_lang_tag(const char *lang) {
|
||||
if (!strcmp(lang, "ja")) return "ja";
|
||||
if (!strcmp(lang, "ko")) return "ko";
|
||||
if (!strcmp(lang, "zh-Hans")) return "zh-cn";
|
||||
return "zh-tw";
|
||||
}
|
||||
|
||||
// The handful of fontconfig calls used here (2.0 ABI, unchanged since). Loaded once, kept for the process: the menu
|
||||
// rebuilds its atlas when the window height changes and must not dlopen on every rebuild.
|
||||
typedef struct _FcPattern FcPattern;
|
||||
typedef struct _FcCharSet FcCharSet;
|
||||
typedef struct _FcConfig FcConfig;
|
||||
|
||||
typedef struct {
|
||||
int state; // 0 untried, 1 usable, -1 no fontconfig on this system
|
||||
FcPattern *(*NameParse)(const unsigned char *);
|
||||
void (*PatternDestroy)(FcPattern *);
|
||||
int (*PatternAddCharSet)(FcPattern *, const char *, const FcCharSet *);
|
||||
int (*PatternGetString)(const FcPattern *, const char *, int, unsigned char **);
|
||||
FcCharSet *(*CharSetCreate)(void);
|
||||
int (*CharSetAddChar)(FcCharSet *, unsigned int);
|
||||
void (*CharSetDestroy)(FcCharSet *);
|
||||
FcPattern *(*FontMatch)(FcConfig *, FcPattern *, int *); // 3 args: (config, pattern, FcResult *)
|
||||
int (*PatternGetCharSet)(const FcPattern *, const char *, int, FcCharSet **);
|
||||
int (*CharSetHasChar)(const FcCharSet *, unsigned int);
|
||||
FcConfig *(*ConfigGetCurrent)(void);
|
||||
int (*Init)(void);
|
||||
} Fc;
|
||||
|
||||
static Fc fc;
|
||||
|
||||
static int fc_load(void) {
|
||||
if (fc.state) return fc.state > 0;
|
||||
void *lib = plat_lib_open("libfontconfig.so.1");
|
||||
if (!lib) lib = plat_lib_open("libfontconfig.so");
|
||||
if (!lib) { fc.state = -1; return 0; }
|
||||
fc.NameParse = (FcPattern *(*)(const unsigned char *))plat_lib_sym(lib, "FcNameParse");
|
||||
fc.PatternDestroy = (void (*)(FcPattern *))plat_lib_sym(lib, "FcPatternDestroy");
|
||||
fc.PatternAddCharSet = (int (*)(FcPattern *, const char *, const FcCharSet *))plat_lib_sym(lib, "FcPatternAddCharSet");
|
||||
fc.PatternGetString = (int (*)(const FcPattern *, const char *, int, unsigned char **))plat_lib_sym(lib, "FcPatternGetString");
|
||||
fc.CharSetCreate = (FcCharSet *(*)(void))plat_lib_sym(lib, "FcCharSetCreate");
|
||||
fc.CharSetAddChar = (int (*)(FcCharSet *, unsigned int))plat_lib_sym(lib, "FcCharSetAddChar");
|
||||
fc.CharSetDestroy = (void (*)(FcCharSet *))plat_lib_sym(lib, "FcCharSetDestroy");
|
||||
fc.FontMatch = (FcPattern *(*)(FcConfig *, FcPattern *, int *))plat_lib_sym(lib, "FcFontMatch");
|
||||
fc.PatternGetCharSet = (int (*)(const FcPattern *, const char *, int, FcCharSet **))plat_lib_sym(lib, "FcPatternGetCharSet");
|
||||
fc.CharSetHasChar = (int (*)(const FcCharSet *, unsigned int))plat_lib_sym(lib, "FcCharSetHasChar");
|
||||
fc.ConfigGetCurrent = (FcConfig *(*)(void))plat_lib_sym(lib, "FcConfigGetCurrent");
|
||||
fc.Init = (int (*)(void))plat_lib_sym(lib, "FcInit");
|
||||
if (!fc.NameParse || !fc.PatternDestroy || !fc.PatternAddCharSet || !fc.PatternGetString || !fc.CharSetCreate ||
|
||||
!fc.CharSetAddChar || !fc.CharSetDestroy || !fc.FontMatch || !fc.ConfigGetCurrent ||
|
||||
!fc.PatternGetCharSet || !fc.CharSetHasChar) {
|
||||
fc.state = -1;
|
||||
return 0;
|
||||
}
|
||||
// FcInit loads the configuration and the font set; FcConfigGetCurrent is NULL before it, and FcFontMatch asserts
|
||||
// on a NULL config. Idempotent, so the second call of a rebuild costs a flag check.
|
||||
if (fc.Init) fc.Init();
|
||||
if (!fc.ConfigGetCurrent()) {
|
||||
fc.state = -1;
|
||||
return 0;
|
||||
}
|
||||
fc.state = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// The file fontconfig picks for this language, or 0. Asks for the generic CJK-capable family with the language set and
|
||||
// one representative character of that language in the charset, so a Latin-only or Japanese face cannot win by default.
|
||||
static int fc_font_for(const char *lang, char *out, size_t cap) {
|
||||
static const struct { const char *lang; unsigned int cp; } probe[] = {
|
||||
{"ja", 0x65E5}, // 日
|
||||
{"ko", 0xD55C}, // 한
|
||||
{"zh-Hans", 0x8BBE}, // 设
|
||||
{"zh-Hant", 0x8A2D}, // 設
|
||||
};
|
||||
unsigned int cp = 0;
|
||||
for (size_t i = 0; i < sizeof probe / sizeof *probe; i++)
|
||||
if (!strcmp(probe[i].lang, lang)) cp = probe[i].cp;
|
||||
if (!cp || !fc_load()) return 0;
|
||||
char query[64];
|
||||
snprintf(query, sizeof query, "sans-serif:lang=%s", cjk_lang_tag(lang));
|
||||
FcPattern *pat = fc.NameParse((const unsigned char *)query);
|
||||
if (!pat) return 0;
|
||||
FcCharSet *cs = fc.CharSetCreate();
|
||||
int ok = 0;
|
||||
if (cs) {
|
||||
fc.CharSetAddChar(cs, cp);
|
||||
if (fc.PatternAddCharSet(pat, "charset", cs)) {
|
||||
int result = 0; // FcResult; FcFontMatch asserts when this pointer is NULL
|
||||
FcPattern *m = fc.FontMatch(fc.ConfigGetCurrent(), pat, &result);
|
||||
unsigned char *file = NULL;
|
||||
if (m) {
|
||||
// fontconfig returns the closest pattern even when nothing covers the character, so check the charset
|
||||
// before trusting it: without this a Latin-only system hands back DejaVu Sans and the menu merges no
|
||||
// glyphs while believing it did.
|
||||
FcCharSet *got = NULL;
|
||||
if (result == 0 /* FcResultMatch */ &&
|
||||
fc.PatternGetCharSet(m, "charset", 0, &got) == 0 && got && fc.CharSetHasChar(got, cp) &&
|
||||
fc.PatternGetString(m, "file", 0, &file) == 0 && file)
|
||||
ok = snprintf(out, cap, "%s", (const char *)file) < (int)cap;
|
||||
fc.PatternDestroy(m);
|
||||
}
|
||||
}
|
||||
fc.CharSetDestroy(cs);
|
||||
}
|
||||
fc.PatternDestroy(pat);
|
||||
return ok;
|
||||
}
|
||||
|
||||
// See platform.h. TOTK_MENU_FONT names a file to use for every CJK language; then fontconfig; then the fixed paths,
|
||||
// which are the normal layout on SteamOS and the distributions that predate fontconfig's own lookup.
|
||||
int plat_font_path(const char *lang, char *out, size_t cap) {
|
||||
static const char *files[] = {
|
||||
"/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc",
|
||||
@@ -1259,7 +1388,14 @@ int plat_font_path(const char *lang, char *out, size_t cap) {
|
||||
"/usr/share/fonts/noto/NotoSansCJK-Regular.ttc",
|
||||
"/usr/share/fonts/truetype/noto/NotoSansCJK-Regular.ttc",
|
||||
};
|
||||
if (strcmp(lang, "ja") && strcmp(lang, "ko") && strcmp(lang, "zh-Hans") && strcmp(lang, "zh-Hant")) return 0;
|
||||
if (!cjk_lang(lang)) return 0;
|
||||
char override[PATH_MAX];
|
||||
if (plat_getenv("TOTK_MENU_FONT", override, sizeof override) && plat_file_exists(override))
|
||||
return snprintf(out, cap, "%s", override) < (int)cap;
|
||||
// menu_font_fontconfig=0 skips the fontconfig lookup and keeps the five fixed paths, for a player whose fontconfig
|
||||
// resolves to a face the font parser cannot read. Read through cfg_bool like every other switch, so totk.ini and
|
||||
// the TOTK_ variable both work and the menu can grey it out.
|
||||
if (cfg_bool("TOTK_MENU_FONT_FONTCONFIG") && fc_font_for(lang, out, cap) && plat_file_exists(out)) return 1;
|
||||
for (size_t i = 0; i < sizeof files / sizeof *files; i++)
|
||||
if (plat_file_exists(files[i])) return snprintf(out, cap, "%s", files[i]) < (int)cap;
|
||||
return 0;
|
||||
|
||||
@@ -387,7 +387,9 @@ const char *plat_ui_language(void);
|
||||
const char *plat_user_locale(void);
|
||||
uint32_t plat_thread_id(void); // id of the calling thread, for unique file names
|
||||
// A system font file with the glyphs of a catalog language ("ja", "ko", "zh-Hans", "zh-Hant"): the menu shows each
|
||||
// language's name in its own script. Copies the UTF-8 path into out; 0 when the system has none.
|
||||
// language's name in its own script. Copies the UTF-8 path into out; 0 when the system has none. On Linux the file is
|
||||
// the one fontconfig picks for that language (so a sandbox that installs a font where its fontconfig finds it needs no
|
||||
// code change), with TOTK_MENU_FONT overriding it and the usual distribution paths as the fallback.
|
||||
int plat_font_path(const char *lang, char *out, size_t cap);
|
||||
// The operating system and its build ("Windows 10.0.28000") into out; 0 when unknown.
|
||||
int plat_os_version(char *out, size_t cap);
|
||||
|
||||
+54
-4
@@ -243,6 +243,23 @@ static double scene_scale(void) {
|
||||
|
||||
uint64_t res_heap_extra_bytes(void) { return ((res_heap_extra_kib() << 10) + 0x1fffff) & ~0x1fffffull; }
|
||||
|
||||
// TOTK_GRASS_RANGE (percent, 50 to 400; 100 = the game's): how far around the camera grass blades grow. The near grass
|
||||
// map (the grass patch set, recomp/patches-v121.txt and patches-v143.txt) covers 62.5 m and draws into 256x256 and
|
||||
// 128x128 textures; other values scale the extent, its step and both textures together, so the grass keeps its detail
|
||||
// per metre. The larger textures come from the grass heap "草" of the HeapDef, which has no room for them (at 200 %
|
||||
// without growth the game stops at start on a failed allocation), so it grows by 9318 KiB, its size in 1.4.3, times
|
||||
// the textures' growth in area (k^2 - 1).
|
||||
#define GRASS_HEAP_KIB 9318
|
||||
static int grass_pct(void) {
|
||||
int pct = cfg_int("TOTK_GRASS_RANGE");
|
||||
return pct < 50 ? 50 : pct > 400 ? 400 : pct;
|
||||
}
|
||||
uint64_t res_grass_heap_extra_kib(void) {
|
||||
int pct = grass_pct();
|
||||
return pct > 100 ? (uint64_t)GRASS_HEAP_KIB * (uint64_t)(pct * pct - 10000) / 10000 : 0;
|
||||
}
|
||||
uint64_t res_grass_heap_extra_bytes(void) { return ((res_grass_heap_extra_kib() << 10) + 0x1fffff) & ~0x1fffffull; }
|
||||
|
||||
// TOTK_TEX_HEAP_EXTRA_MB (0 to 4096): more room in "TextureHeap" and its parent "ゲームグラフィックス", the heap the
|
||||
// world's textures stream into. HD texture packs made for emulators with 8 GB of DRAM grow it by about 3.3 GiB in their
|
||||
// own HeapDef; without the room the game runs out and starts its panic Blood Moon over and over. The pool and the heap
|
||||
@@ -397,9 +414,9 @@ int res_heapdef_plain(const void *in, size_t n) {
|
||||
}
|
||||
|
||||
int res_heapdef_build(const void *in, size_t n, void **out, size_t *out_n) {
|
||||
uint64_t extra = res_heap_extra_kib(), tex = tex_heap_extra_kib();
|
||||
uint64_t extra = res_heap_extra_kib(), tex = tex_heap_extra_kib(), grass = res_grass_heap_extra_kib();
|
||||
*out = NULL;
|
||||
if (!extra && !tex) return 0;
|
||||
if (!extra && !tex && !grass) return 0;
|
||||
Byml b;
|
||||
uint32_t heaps = 0;
|
||||
size_t dta_at = 0, gfx_at = 0;
|
||||
@@ -439,6 +456,17 @@ int res_heapdef_build(const void *in, size_t n, void **out, size_t *out_n) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (grass) {
|
||||
size_t at = heap_size_field(&b, heaps, "\xe8\x8d\x89"); // 草, the grass heap
|
||||
if (at) {
|
||||
int32_t g, g2;
|
||||
memcpy(&g, b.p + at, 4);
|
||||
g2 = g + (int32_t)grass;
|
||||
memcpy(b.p + at, &g2, 4);
|
||||
rt_log("resolution: HeapDef grass heap %d -> %d KiB (TOTK_GRASS_RANGE)", g, g2);
|
||||
} else
|
||||
rt_log("resolution: the HeapDef table has no grass heap; grass_range may run out of grass memory");
|
||||
}
|
||||
size_t cap = ZSTD_compressBound(b.n);
|
||||
void *z = malloc(cap);
|
||||
size_t zn = z ? ZSTD_compress(z, cap, b.p, b.n, 9) : 0;
|
||||
@@ -499,8 +527,29 @@ static void res_shadow_range(void) {
|
||||
rt_log("resolution: shadow cascades end at %g, %g, %g and %g m", d[0], d[1], d[2], d[3]);
|
||||
}
|
||||
|
||||
// The grass map's values on page +128..+144 (the grass patch set): extent, step, the two texture sizes, and the
|
||||
// half extent main+0x206340c picks instead of the extent. Texture sizes stay multiples of 32.
|
||||
static void res_grass_range(void) {
|
||||
int pct = grass_pct(), set = rt_patch_set("grass");
|
||||
if (pct == 100) return;
|
||||
if (set < 0) {
|
||||
rt_log("resolution: this game version has no grass patch set; grass_range stays 100");
|
||||
return;
|
||||
}
|
||||
float k = pct / 100.0f, f[2] = {62.5f * k, 3.90625f * k}, half = 31.25f * k;
|
||||
uint32_t t[2] = {(uint32_t)(256 * pct / 100 + 16) / 32 * 32, (uint32_t)(128 * pct / 100 + 16) / 32 * 32};
|
||||
uint8_t *page = rt_patch_page();
|
||||
memcpy(page + 128, f, sizeof f);
|
||||
memcpy(page + 136, t, sizeof t);
|
||||
memcpy(page + 144, &half, sizeof half);
|
||||
rt_patch_switch(set, 1);
|
||||
rt_log("resolution: grass map %g m, textures %ux%u and %ux%u (TOTK_GRASS_RANGE=%d)", f[0], t[0], t[0], t[1], t[1],
|
||||
pct);
|
||||
}
|
||||
|
||||
void res_init(void) {
|
||||
res_shadow_range();
|
||||
res_grass_range();
|
||||
if (!bigger()) {
|
||||
rt_log("resolution: the game's own (output 1920x1080, scene 1600x900)");
|
||||
shadow_init(rt_patch_page());
|
||||
@@ -645,8 +694,9 @@ void res_fn_hit(uint64_t addr, uint64_t x0) {
|
||||
}
|
||||
|
||||
void res_present(Cpu *c) {
|
||||
// The hook runs on every guest function entry while it waits: should the game set its render size before
|
||||
// res_init or never, it stops after 1800 presents (half a minute at 60 fps) and modes change at the next start.
|
||||
// Should the game set its render size before res_init or never, the hook (FN_ENTER of the hooked functions,
|
||||
// recomp/patches-v143.txt `hook`) stops after 1800 presents (half a minute at 60 fps) and modes change at the
|
||||
// next start.
|
||||
static unsigned waited;
|
||||
if (g_fnprof && !renderer && ++waited == 1800) {
|
||||
g_fnprof = 0;
|
||||
|
||||
+187
-24
@@ -38,6 +38,7 @@
|
||||
#include "mods.h"
|
||||
#include "romfs_config.h"
|
||||
#include "romfs_path.h"
|
||||
#include "audio_cat.h"
|
||||
#include "platform/platform.h"
|
||||
#include "restbl.h"
|
||||
#include "sha256.h"
|
||||
@@ -69,6 +70,7 @@ static PlatMutex lock = PLAT_MUTEX_INIT;
|
||||
static uint64_t handles[NH]; // file index + 1; 0 is free
|
||||
static uint32_t handle_ovl[NH]; // overlay slot + 1 of an open handle, 0 = original
|
||||
static PlatFile *handle_file[NH]; // the handle's open overlay file, when handle_ovl is set
|
||||
static uint8_t handle_audio_cat[NH]; // the open file's sound category (audio_cat.c), AUDIO_CAT_UNKNOWN when not audio
|
||||
static Overlay *overlays; // sorted by RomFS index after overlay_init
|
||||
static size_t noverlay, overlay_cap;
|
||||
static char **added; // RomFS paths of the added files, sorted; added[k] is index file_count + k
|
||||
@@ -340,7 +342,8 @@ static void overlay_push(Overlay o) {
|
||||
}
|
||||
|
||||
// 1 when path names a file of one game version only (Product.<n> in a name: the resource size table, the actor
|
||||
// database and other version-bound files); the RomFS lacking it means it is another version's.
|
||||
// database and other version-bound files); the RomFS lacking it means it is another version's, or a name this version
|
||||
// still asks for (mod_walk_cb).
|
||||
static int other_version(const char *path) {
|
||||
for (const char *p = strstr(path, ".Product."); p; p = strstr(p + 1, ".Product.")) {
|
||||
const char *d = p + strlen(".Product.");
|
||||
@@ -420,9 +423,18 @@ static int mod_walk_cb(const char *leaf, int kind, uint64_t size, void *ctx) {
|
||||
}
|
||||
uint64_t i = index_any_case(path);
|
||||
if (i == UINT64_MAX && other_version(path)) {
|
||||
if (is_restbl(path)) shipped_add(file, w->k + 1, 1); // its entries for this mod's files still apply
|
||||
m->other_version++;
|
||||
return 1;
|
||||
// Another version's resource size table is no file this game opens; its entries for this mod's files still
|
||||
// apply.
|
||||
if (is_restbl(path)) {
|
||||
shipped_add(file, w->k + 1, 1);
|
||||
return 1;
|
||||
}
|
||||
// Any other file is served under its own name below, as an added file, the way LayeredFS shows a console every
|
||||
// file of a mod: the game does ask for names its RomFS lacks. Measured on 1.4.3 with mods on (trace = fs): it
|
||||
// opened Sound/Resource/Pack_MasterSword.Product.110.bars.zs, where its RomFS holds Product.140 and the
|
||||
// unversioned file only. A sound mod that ships its pack under all those names stayed silent while this file
|
||||
// was left out.
|
||||
}
|
||||
PlatFile *f = open_read(file);
|
||||
if (!f) {
|
||||
@@ -878,7 +890,7 @@ static void *plain_mod_heapdef(size_t *n, const char **who) {
|
||||
return NULL;
|
||||
}
|
||||
static void heapdef_overlay(void) {
|
||||
if (!res_heap_extra_kib() && !res_tex_heap_extra_bytes()) return;
|
||||
if (!res_heap_extra_kib() && !res_tex_heap_extra_bytes() && !res_grass_heap_extra_kib()) return;
|
||||
static const char keeps[] = "the game keeps its own resolution";
|
||||
Overlay *base;
|
||||
size_t n;
|
||||
@@ -957,11 +969,29 @@ 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
|
||||
// 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) {
|
||||
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(path, sizeof path, "%s/%s/manifest.tsv", base, name) < (int)sizeof path && plat_file_exists(path))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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: 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).
|
||||
// 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
|
||||
@@ -977,23 +1007,29 @@ static void overlay_init(void) {
|
||||
int wide = 0;
|
||||
unsigned out[2];
|
||||
res_wanted(out);
|
||||
unsigned shape[2] = {out[0], out[1]}; // the --aspect of the folder made for this shape
|
||||
cfg_shape_size(out[0], out[1], shape);
|
||||
if (!patches && res_wants_wide_overlay(out)) {
|
||||
if (snprintf(def, sizeof def, "%s/romfs-patches-%ux%u/manifest.tsv", index_dir, out[0], out[1]) < (int)sizeof def &&
|
||||
plat_file_exists(def)) {
|
||||
def[strlen(def) - strlen("/manifest.tsv")] = 0;
|
||||
char name[128];
|
||||
if (shaped_name(index_dir, "romfs-patches", out[0], out[1], name, sizeof name) &&
|
||||
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);
|
||||
} else {
|
||||
rt_log("RomFS overlay: no romfs-patches-%ux%u for this game resolution, the UI keeps its 16:9 layout "
|
||||
"(tools/make_romfs_patches.py --aspect %ux%u)", out[0], out[1], out[0], out[1]);
|
||||
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);
|
||||
char *dir = prompts_folders[i].dir;
|
||||
if (wide) snprintf(dir, sizeof prompts_folders[i].dir, "%s-%ux%u", name, out[0], out[1]);
|
||||
else snprintf(dir, sizeof prompts_folders[i].dir, "%s", name);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
snprintf(dir, sizeof prompts_folders[i].dir, "%s", name);
|
||||
prompts_folders[i].ready =
|
||||
snprintf(path, sizeof path, "%s/%s/manifest.tsv", index_dir, dir) < (int)sizeof path && plat_file_exists(path);
|
||||
}
|
||||
@@ -1025,7 +1061,7 @@ static void overlay_init(void) {
|
||||
char why[256];
|
||||
if (prompts_off == ROMFS_PROMPTS_SHAPE)
|
||||
snprintf(why, sizeof why, "the game resolution has no %s (tools/make_romfs_patches.py --prompts %s "
|
||||
"--aspect %ux%u)", wanted_dir, prompts_wanted + strlen("romfs-patches-"), out[0], out[1]);
|
||||
"--aspect %ux%u)", wanted_dir, prompts_wanted + strlen("romfs-patches-"), shape[0], shape[1]);
|
||||
else
|
||||
snprintf(why, sizeof why, "%s", prompts_off == ROMFS_PROMPTS_PATCHES
|
||||
? "TOTK_ROMFS_PATCHES is set"
|
||||
@@ -1081,26 +1117,138 @@ static void index_path(char *out, size_t cap) {
|
||||
strcpy(out + k, "romfs-index.bin");
|
||||
}
|
||||
|
||||
// 1 when <prefix>-<w>x<h> has a manifest next to romfs-index.bin. Works before fs_init: index_dir is not set that early
|
||||
// (cfg_init, res_init and resolution.c decide run first), so the index path is worked out again here.
|
||||
static int shaped_folder_ready(const char *prefix, unsigned w, unsigned h) {
|
||||
char dir[2100], path[2200];
|
||||
index_path(dir, sizeof dir);
|
||||
// The folder of romfs-index.bin. Works before fs_init: index_dir is not set that early (cfg_init, res_init and
|
||||
// resolution.c decide run first), so the index path is worked out again here.
|
||||
static void index_folder(char *dir, size_t cap) {
|
||||
index_path(dir, cap);
|
||||
char *sep = plat_last_sep(dir);
|
||||
if (sep) *sep = 0;
|
||||
else strcpy(dir, ".");
|
||||
return snprintf(path, sizeof path, "%s/%s-%ux%u/manifest.tsv", dir, prefix, w, h) < (int)sizeof path &&
|
||||
plat_file_exists(path);
|
||||
}
|
||||
|
||||
// 1 when the game resolution w x h has the UI layout of its shape: romfs-patches-<w>x<h>, the folder overlay_init
|
||||
// looks for.
|
||||
// 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) {
|
||||
char dir[2100], name[128];
|
||||
index_folder(dir, sizeof dir);
|
||||
return shaped_name(dir, prefix, w, h, name, sizeof name);
|
||||
}
|
||||
|
||||
// 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); }
|
||||
|
||||
// 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); }
|
||||
|
||||
// ---- 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.
|
||||
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);
|
||||
uint64_t n = 0;
|
||||
snprintf(path, sizeof path, "%s/build-cache/rebuild.txt", dir);
|
||||
char *text = (char *)plat_file_read(path, &n);
|
||||
if (!text) return 0;
|
||||
char *lines[5] = {0};
|
||||
int k = 0;
|
||||
for (char *p = text; k < 5 && p < text + n;) {
|
||||
char *e = memchr(p, '\n', (size_t)(text + n - p));
|
||||
if (!e) e = text + n;
|
||||
if (e > p && e[-1] == '\r') e[-1] = 0;
|
||||
*e = 0;
|
||||
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;
|
||||
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));
|
||||
}
|
||||
|
||||
int romfs_shape_can_prepare(void) {
|
||||
static int known = -1;
|
||||
if (known < 0) {
|
||||
char python[1024], script[1100], dir[2100];
|
||||
known = prepare_tools(python, sizeof python, script, sizeof script, dir, sizeof dir);
|
||||
}
|
||||
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;
|
||||
|
||||
static int shape_was_started(const char *folder) {
|
||||
for (int i = 0; i < shape_started_n; i++)
|
||||
if (!strcmp(shape_started[i], folder)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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.
|
||||
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;
|
||||
}
|
||||
|
||||
int romfs_shape_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;
|
||||
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);
|
||||
int started = 0, failed = 0;
|
||||
if (!shaped_name(dir, "romfs-patches", w, h, name, sizeof name)) {
|
||||
snprintf(folder, sizeof folder, "romfs-patches-%s", size);
|
||||
snprintf(out, sizeof out, "%s/%s", dir, folder);
|
||||
const char *argv[] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--aspect", size,
|
||||
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);
|
||||
return started && !failed;
|
||||
}
|
||||
|
||||
static void load_index(void) {
|
||||
char path[2100];
|
||||
index_path(path, sizeof path);
|
||||
@@ -1249,12 +1397,21 @@ uint32_t romfs_open(uint64_t *out, const char *path, int mode) {
|
||||
if (!f || memcmp(&id, &o->id, sizeof id))
|
||||
rt_fatal("RomFS overlay %s is missing or changed since the start check (restart the game)", o->path);
|
||||
}
|
||||
// The handle keeps its sound category (audio_cat.c) even while the volume settings are at 100, so a stream opened
|
||||
// before a setting moves is classified by its later reads. A stream may start reading past its header (the
|
||||
// header came with the BARS bank), so the coefficients are taken from the image here.
|
||||
int cat = audio_cat_from_path(p);
|
||||
if (cat != AUDIO_CAT_UNKNOWN && !ov && image_map && audio_cat_active()) {
|
||||
Entry e = entry(i);
|
||||
if (e.size >= 0x40) audio_cat_scan_bwav(image_map + e.offset, e.size < 4096 ? e.size : 4096, cat);
|
||||
}
|
||||
plat_mutex_lock(&lock);
|
||||
for (unsigned j = 1; j < NH; j++)
|
||||
if (!handles[j]) {
|
||||
handles[j] = i + 1;
|
||||
handle_ovl[j] = ov;
|
||||
handle_file[j] = f;
|
||||
handle_audio_cat[j] = (uint8_t)cat;
|
||||
*out = ROMFS_HANDLE_BASE + j;
|
||||
plat_mutex_unlock(&lock);
|
||||
return 0;
|
||||
@@ -1304,6 +1461,11 @@ uint32_t romfs_read(uint64_t *out, uint64_t h, int64_t offset, void *buffer, uin
|
||||
done += (uint64_t)r;
|
||||
}
|
||||
*out = done;
|
||||
uint64_t j = h - ROMFS_HANDLE_BASE;
|
||||
if (handle_audio_cat[j] != AUDIO_CAT_UNKNOWN && done && audio_cat_active()) {
|
||||
if (offset == 0) audio_cat_scan_bwav(buffer, done, handle_audio_cat[j]);
|
||||
audio_cat_tag_range((uint64_t)(uintptr_t)buffer, done, handle_audio_cat[j]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1326,6 +1488,7 @@ void romfs_close(uint64_t h) {
|
||||
handles[j] = 0;
|
||||
handle_ovl[j] = 0;
|
||||
handle_file[j] = NULL;
|
||||
handle_audio_cat[j] = 0;
|
||||
plat_mutex_unlock(&lock);
|
||||
if (of) plat_file_close(of);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#version 450
|
||||
// Screen-space contact shadows (runtime/vk_contact.c). Each pixel of the game's lit scene colour marches a short way
|
||||
// toward the sun through the linear depth target; when the ray passes behind something close in front of it, the pixel
|
||||
// is in a contact shadow the shadow maps are too coarse to show, and its colour is darkened.
|
||||
// Screen-space contact shadows (runtime/vk_contact.c). Each pixel of the game's lit scene colour on a surface facing
|
||||
// the sun marches a short way toward the sun through the linear depth target; when the ray passes behind something
|
||||
// close in front of it, the pixel is in a contact shadow the shadow maps are too coarse to show, and its colour is
|
||||
// darkened.
|
||||
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
|
||||
@@ -28,6 +29,27 @@ float ign(vec2 px) { // interleaved gradient noise: a per-pixel start offset t
|
||||
return fract(52.9829189 * fract(dot(px, vec2(0.06711056, 0.00583715))));
|
||||
}
|
||||
|
||||
vec3 pos_at(ivec2 q) { // the view-space position of a pixel, clamped to the image
|
||||
q = clamp(q, ivec2(0), ivec2(pc.size.xy) - 1);
|
||||
return view_pos((vec2(q) + 0.5) * pc.size.zw, texelFetch(lin_depth, q, 0).x * pc.proj.z);
|
||||
}
|
||||
|
||||
// The surface normal from the linear depth: on each axis the neighbour nearer in depth, so an edge pixel takes the
|
||||
// slope of its own surface rather than the step to what lies behind it. Turned toward the camera. On the image border
|
||||
// the clamped neighbour is the pixel itself, a zero difference that would make the normal NaN, so the side inside the
|
||||
// image is taken there.
|
||||
vec3 normal_at(ivec2 px, vec3 p) {
|
||||
ivec2 last = ivec2(pc.size.xy) - 1;
|
||||
vec3 l = pos_at(px - ivec2(1, 0)), r = pos_at(px + ivec2(1, 0));
|
||||
vec3 d = pos_at(px - ivec2(0, 1)), u = pos_at(px + ivec2(0, 1));
|
||||
bool take_r = px.x == 0 || (px.x < last.x && abs(r.z - p.z) < abs(p.z - l.z));
|
||||
bool take_u = px.y == 0 || (px.y < last.y && abs(u.z - p.z) < abs(p.z - d.z));
|
||||
vec3 dx = take_r ? r - p : p - l;
|
||||
vec3 dy = take_u ? u - p : p - d;
|
||||
vec3 n = normalize(cross(dx, dy));
|
||||
return dot(n, p) > 0.0 ? -n : n;
|
||||
}
|
||||
|
||||
void main() {
|
||||
ivec2 px = ivec2(gl_GlobalInvocationID.xy);
|
||||
if (px.x >= int(pc.size.x) || px.y >= int(pc.size.y)) return;
|
||||
@@ -37,6 +59,12 @@ void main() {
|
||||
if (z > 80.0) return;
|
||||
vec2 uv = (vec2(px) + 0.5) * pc.size.zw;
|
||||
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
|
||||
// already put on it (dark silhouettes of rock faces in the Gerudo sandstorm haze). Faces at a grazing angle to the
|
||||
// sun get a share that grows with that angle.
|
||||
float lit = smoothstep(0.0, 0.3, dot(normal_at(px, p), pc.light.xyz));
|
||||
if (!(lit > 0.0)) return; // also a NaN normal: the march is skipped rather than writing NaN into the colour
|
||||
// the march grows with distance, as one pixel covers more ground; thickness keeps thin blades from hiding the sky
|
||||
float len = pc.light.w * clamp(z / 10.0, 0.4, 3.0);
|
||||
float thick = 0.15 + z * 0.01;
|
||||
@@ -56,7 +84,7 @@ void main() {
|
||||
}
|
||||
}
|
||||
float fade = 1.0 - smoothstep(40.0, 80.0, z);
|
||||
float k = 1.0 - pc.proj.w * occ * fade;
|
||||
float k = 1.0 - pc.proj.w * occ * fade * lit;
|
||||
if (pc.opt.x > 0.5) {
|
||||
imageStore(scene, px, vec4(k, k, k, 1.0));
|
||||
return;
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
#version 450
|
||||
// Portions adapted from RenoDX. Copyright (C) 2025-2026 Carlos Lopez Jr. and RenoDX contributors.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// The game's tonemap pass for HDR output (runtime/vk_hdr.c vk_hdr_shader_swap puts it in place of the translated
|
||||
// shader when TOTK_HDR=1). Same inputs as the game's: fp_t_tcb_8 (bloom, clamped to 10000 as the game does) plus
|
||||
// fp_t_tcb_A (the scene), weights in c1[0] and the saturation grade in c3[0]. The game maps luminance and each channel
|
||||
// with 1 - e^-x, blends the two by the luminance curve squared, clamps to 0..1 and grades saturation. Here the curve is
|
||||
// the game's up to PIVOT and a straight line with its slope above, so mid-greys look as in SDR and highlights keep
|
||||
// going; the grade works on the colour divided by its largest channel above 1; a roll-off on the largest channel stops
|
||||
// at the display's peak. The output is relative to the HUD's white (1.0), which the present maps to TOTK_HDR_UI_NITS.
|
||||
// Hue correction (hdr.z, TOTK_HDR_HUE): the game's SDR clamp turns bright saturated colours towards white (a torch flame
|
||||
// clips red, then green, and reads yellow-white, the colour its emitted light was tuned to); the extended curve keeps
|
||||
// their ratios, so they stay saturated. From the picture's white upwards the colour moves towards the game's own SDR
|
||||
// result at the HDR luminance, by up to hdr.z (RenoDX's TotK mod has the same control).
|
||||
// Approach after RenoDX's TotK mod by souperman9 and Musa (github.com/clshortfuse/renodx, src/games/totk, MIT): its
|
||||
// "extended vanilla" curve.
|
||||
// fp_t_tcb_A (the scene), weights in c1[0] and the saturation grade in c3[0].
|
||||
//
|
||||
// The HDR reconstruction follows RenoDX's TotK defaults more closely than the original recomp implementation:
|
||||
// - the game's 1 - e^-x tone curve is extended along its tangent above 0.18;
|
||||
// - the vanilla SDR tonemap is kept as a donor for hue and purity;
|
||||
// - MacLeod-Boynton hue/purity transfer is performed through XYZ/LMS in BT.2020. hdr.z (TOTK_HDR_HUE, 0..1) scales
|
||||
// both: at its default 0.7 the hue moves 70% and the purity 65% of the way to the SDR donor, RenoDX's defaults
|
||||
// ("Hue Shift" and "SDR Blowout"); at 0 bright colours keep the extended curve's saturation. This replaces the
|
||||
// earlier blend towards the SDR result scaled to the HDR luminance, which the same setting drove;
|
||||
// - the game's saturation grade is applied after a temporary neutral max-channel compression, then expanded back;
|
||||
// - the result is constrained to non-negative BT.709 and display-mapped with per-channel Neutwo in linear BT.2020;
|
||||
// - RenoDX's default 2.2 gamma correction is folded into the native linear path: the Neutwo peak is corrected before
|
||||
// display mapping and the corresponding sRGB-to-gamma-2.2 appearance correction is applied after tone mapping.
|
||||
// The output remains linear BT.709 relative to the HUD's white (1.0), so the game's later HUD passes and the existing
|
||||
// HDR10 present encoder continue to work unchanged.
|
||||
//
|
||||
// Color reconstruction, gamma correction and Neutwo math adapted from RenoDX (MIT), clshortfuse/renodx commit
|
||||
// 43c067b755a6a741f6500b2b936570f1462dcfbe, notably src/games/totk/tonemap.slang,
|
||||
// src/games/totk/macleod_boynton.hlsli, src/shaders/colorcorrect.hlsl and src/shaders/tonemap/neutwo.hlsl.
|
||||
// Bindings are those of the game's translated shader: vk_hdr.c rewrites them from the original's names.
|
||||
layout(location = 0) in vec4 uv;
|
||||
layout(location = 0) out vec4 color;
|
||||
@@ -26,15 +36,264 @@ layout(set = 0, binding = 3, std140) uniform C1 { vec4 v[4096]; } fp_c1;
|
||||
layout(set = 0, binding = 4, std140) uniform C3 { vec4 v[4096]; } fp_c3;
|
||||
|
||||
const float PIVOT = 0.18;
|
||||
const float PURITY_PER_HUE = 0.65 / 0.70; // RenoDX's default SDR blowout against its default hue shift
|
||||
const float GAMMA = 2.2;
|
||||
const float MB_EPSILON = 1e-20;
|
||||
const float MB_INTERVAL_MAX = 1e30;
|
||||
const float MB_NEAR_WHITE_EPSILON = 1e-14;
|
||||
const float MB_T_MIN = 1e-6;
|
||||
|
||||
float curve(float x) { // the game's 1 - e^-x below PIVOT, its tangent there above
|
||||
float y0 = 1.0 - exp(-PIVOT);
|
||||
return x <= PIVOT ? 1.0 - exp(-x) : y0 + exp(-PIVOT) * (x - PIVOT);
|
||||
}
|
||||
|
||||
vec3 curve3(vec3 x) { return vec3(curve(x.r), curve(x.g), curve(x.b)); }
|
||||
// Column-major GLSL matrices. Values match the RenoDX TotK MacLeod-Boynton implementation.
|
||||
const mat3 XYZ_TO_LMS_2006 = mat3(
|
||||
vec3(0.185082982238733, -0.134433056469973, 0.000789456671966863),
|
||||
vec3(0.584081279463687, 0.405752392775348, -0.000912281325916184),
|
||||
vec3(-0.0240722415044404, 0.0358252602217631, 0.0198490812339463));
|
||||
const mat3 LMS_TO_XYZ_2006 = mat3(
|
||||
vec3(2.628474773947687, 0.8765342837340055, -0.06425592569153735),
|
||||
vec3(-3.761263499279893, 1.2003038085515867, 0.20476359921126536),
|
||||
vec3(9.9763571339745, -1.1033785928646218, 49.93266413348867));
|
||||
const mat3 BT709_TO_XYZ = mat3(
|
||||
vec3(0.4123907993, 0.2126390059, 0.0193308187),
|
||||
vec3(0.3575843394, 0.7151686788, 0.1191947798),
|
||||
vec3(0.1804807884, 0.0721923154, 0.9505321522));
|
||||
const mat3 XYZ_TO_BT709 = mat3(
|
||||
vec3(3.2409699419, -0.9692436363, 0.0556300797),
|
||||
vec3(-1.5373831776, 1.8759675015, -0.2039769589),
|
||||
vec3(-0.4986107603, 0.0415550574, 1.0569715142));
|
||||
const mat3 BT2020_TO_XYZ = mat3(
|
||||
vec3(0.6369580483, 0.2627002120, 0.0),
|
||||
vec3(0.1446169036, 0.6779980715, 0.0280726930),
|
||||
vec3(0.1688809752, 0.0593017165, 1.0609850577));
|
||||
const mat3 XYZ_TO_BT2020 = mat3(
|
||||
vec3(1.7166511880, -0.6666843518, 0.0176398574),
|
||||
vec3(-0.3556707838, 1.6164812366, -0.0427706133),
|
||||
vec3(-0.2533662814, 0.0157685458, 0.9421031212));
|
||||
// The chains the per-pixel code uses, folded at compile time: one matrix per conversion instead of two.
|
||||
const mat3 BT709_TO_BT2020 = XYZ_TO_BT2020 * BT709_TO_XYZ;
|
||||
const mat3 BT2020_TO_BT709 = XYZ_TO_BT709 * BT2020_TO_XYZ;
|
||||
const mat3 BT2020_TO_LMS = XYZ_TO_LMS_2006 * BT2020_TO_XYZ;
|
||||
const mat3 LMS_TO_BT2020 = XYZ_TO_BT2020 * LMS_TO_XYZ_2006;
|
||||
// D65 white (x 0.31272, y 0.32903) in LMS, and its MacLeod-Boynton coordinates (l, s) = (L, S) / (L + M).
|
||||
const vec3 WHITE_LMS = XYZ_TO_LMS_2006 * vec3(0.31272 / 0.32903, 1.0, (1.0 - 0.31272 - 0.32903) / 0.32903);
|
||||
const vec2 MB_WHITE = vec2(WHITE_LMS.x, WHITE_LMS.z) / (WHITE_LMS.x + WHITE_LMS.y);
|
||||
|
||||
float maxc(vec3 c) { return max(c.r, max(c.g, c.b)); }
|
||||
float minc(vec3 c) { return min(c.r, min(c.g, c.b)); }
|
||||
float div_safe(float a, float b, float fallback) { return b == 0.0 ? fallback : a / b; }
|
||||
|
||||
vec3 to_bt2020(vec3 c) { return BT709_TO_BT2020 * c; }
|
||||
vec3 to_bt709(vec3 c) { return BT2020_TO_BT709 * c; }
|
||||
|
||||
// RenoDX GammaSafe(c, true, 2.2): sRGBDecode(GammaEncode(c, 2.2)). Used on the peak ratio before Neutwo.
|
||||
float srgb_decode(float c) {
|
||||
return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
float gamma22_to_srgb_linear(float c) {
|
||||
float a = abs(c);
|
||||
float v = srgb_decode(pow(a, 1.0 / GAMMA));
|
||||
return c < 0.0 ? -v : v;
|
||||
}
|
||||
|
||||
// RenoDX GammaSafe(c, false, 2.2): GammaDecode(sRGBEncode(c), 2.2). In RenoDX this is paired with a gamma-2.2
|
||||
// intermediate encode/decode. The native recomp stays linear, so applying this once here gives the same linear result.
|
||||
float srgb_encode(float c) {
|
||||
return c <= 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0 / 2.4) - 0.055;
|
||||
}
|
||||
float srgb_linear_to_gamma22_linear(float c) {
|
||||
float a = abs(c);
|
||||
float v = pow(srgb_encode(a), GAMMA);
|
||||
return c < 0.0 ? -v : v;
|
||||
}
|
||||
vec3 srgb_linear_to_gamma22_linear(vec3 c) {
|
||||
return vec3(srgb_linear_to_gamma22_linear(c.r),
|
||||
srgb_linear_to_gamma22_linear(c.g),
|
||||
srgb_linear_to_gamma22_linear(c.b));
|
||||
}
|
||||
|
||||
float vanilla_curve(float x) { return 1.0 - exp(-x); }
|
||||
float extended_curve(float x) {
|
||||
float y0 = vanilla_curve(PIVOT);
|
||||
return x <= PIVOT ? vanilla_curve(x) : y0 + exp(-PIVOT) * (x - PIVOT);
|
||||
}
|
||||
vec3 extended_curve3(vec3 x) {
|
||||
return vec3(extended_curve(x.r), extended_curve(x.g), extended_curve(x.b));
|
||||
}
|
||||
|
||||
// RenoDX's generic TotK extended-vanilla path uses BT.601 luma for the SDR donor and HDR extension.
|
||||
float bt601_luma(vec3 c) { return dot(c, vec3(0.2989030703, 0.5866198547, 0.1144770751)); }
|
||||
|
||||
vec3 vanilla_tonemap(vec3 x) {
|
||||
float lum_in = bt601_luma(x);
|
||||
float lum_out = vanilla_curve(lum_in);
|
||||
vec3 by_lum = x * div_safe(lum_out, lum_in, 0.0);
|
||||
vec3 by_channel = vec3(vanilla_curve(x.r), vanilla_curve(x.g), vanilla_curve(x.b));
|
||||
float blend = clamp(lum_out, 0.0, 1.0);
|
||||
return mix(by_lum, by_channel, blend * blend);
|
||||
}
|
||||
|
||||
vec3 extended_vanilla_tonemap(vec3 x) {
|
||||
float lum_in = bt601_luma(x);
|
||||
float lum_out = extended_curve(lum_in);
|
||||
vec3 by_lum = x * div_safe(lum_out, lum_in, 0.0);
|
||||
vec3 by_channel = extended_curve3(x);
|
||||
float blend = clamp(vanilla_curve(lum_in), 0.0, 1.0);
|
||||
return mix(by_lum, by_channel, blend * blend);
|
||||
}
|
||||
|
||||
vec2 mb_from_lms(vec3 lms) {
|
||||
float t = lms.x + lms.y;
|
||||
return t > 0.0 ? vec2(lms.x / t, lms.z / t) : vec2(0.0);
|
||||
}
|
||||
|
||||
vec3 lms_from_mb_t(vec2 mb, float t) {
|
||||
return vec3(mb.x * t, (1.0 - mb.x) * t, mb.y * t);
|
||||
}
|
||||
|
||||
void interval_lower_zero(float a, float b, out float lo, out float hi) {
|
||||
if (abs(a) < MB_EPSILON) {
|
||||
if (b >= 0.0) {
|
||||
lo = -MB_INTERVAL_MAX;
|
||||
hi = MB_INTERVAL_MAX;
|
||||
} else {
|
||||
lo = 1.0;
|
||||
hi = 0.0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
float t0 = -b / a;
|
||||
if (a > 0.0) {
|
||||
lo = t0;
|
||||
hi = MB_INTERVAL_MAX;
|
||||
} else {
|
||||
lo = -MB_INTERVAL_MAX;
|
||||
hi = t0;
|
||||
}
|
||||
}
|
||||
|
||||
struct MBResult {
|
||||
vec3 rgb;
|
||||
float purity;
|
||||
};
|
||||
|
||||
// Normalized MacLeod-Boynton purity solve in linear BT.2020. Purity 0 is white on the hue ray and purity 1 is the
|
||||
// first RGB gamut boundary; T = L + M is held constant so the operation changes chromaticity rather than intensity.
|
||||
MBResult mb_apply_bt2020(vec3 rgb, float purity_value) {
|
||||
MBResult outv;
|
||||
outv.rgb = rgb;
|
||||
outv.purity = 0.0;
|
||||
|
||||
vec3 lms = BT2020_TO_LMS * rgb;
|
||||
float t = lms.x + lms.y;
|
||||
if (t <= MB_T_MIN) return outv;
|
||||
|
||||
vec2 white = MB_WHITE;
|
||||
vec2 direction = mb_from_lms(lms) - white;
|
||||
if (dot(direction, direction) < MB_NEAR_WHITE_EPSILON) return outv;
|
||||
|
||||
vec3 rgb_white = LMS_TO_BT2020 * lms_from_mb_t(white, t);
|
||||
vec3 a = rgb - rgb_white;
|
||||
float t_lo = 0.0, t_hi = MB_INTERVAL_MAX, lo, hi;
|
||||
|
||||
interval_lower_zero(a.r, rgb_white.r, lo, hi); t_lo = max(t_lo, lo); t_hi = min(t_hi, hi);
|
||||
interval_lower_zero(a.g, rgb_white.g, lo, hi); t_lo = max(t_lo, lo); t_hi = min(t_hi, hi);
|
||||
interval_lower_zero(a.b, rgb_white.b, lo, hi); t_lo = max(t_lo, lo); t_hi = min(t_hi, hi);
|
||||
if (t_hi < t_lo) {
|
||||
outv.rgb = max(rgb, vec3(0.0));
|
||||
return outv;
|
||||
}
|
||||
|
||||
float t_max = max(0.0, t_hi);
|
||||
outv.purity = t_max > MB_EPSILON ? clamp(1.0 / t_max, 0.0, 1.0) : 0.0;
|
||||
float t_final = clamp(purity_value, 0.0, 1.0) * t_max;
|
||||
vec3 lms_final = lms_from_mb_t(white + t_final * direction, t);
|
||||
outv.rgb = max(LMS_TO_BT2020 * lms_final, vec3(0.0));
|
||||
return outv;
|
||||
}
|
||||
|
||||
vec3 correct_purity(vec3 target709, vec3 reference709, float strength) {
|
||||
vec3 target2020 = to_bt2020(target709);
|
||||
vec3 reference2020 = to_bt2020(reference709);
|
||||
float target_purity = mb_apply_bt2020(target2020, 1.0).purity;
|
||||
float reference_purity = mb_apply_bt2020(reference2020, 1.0).purity;
|
||||
float applied = mix(target_purity, reference_purity, clamp(strength, 0.0, 1.0));
|
||||
return to_bt709(mb_apply_bt2020(target2020, applied).rgb);
|
||||
}
|
||||
|
||||
// Transfer SDR donor hue and purity to the extended HDR result using the same MB construction as RenoDX TotK.
|
||||
vec3 correct_hue_and_purity(vec3 target709, vec3 reference709, float hue_strength, float purity_strength) {
|
||||
if (hue_strength <= 0.0 && purity_strength <= 0.0) return target709;
|
||||
if (hue_strength <= 0.0) return correct_purity(target709, reference709, purity_strength);
|
||||
|
||||
vec3 target2020 = to_bt2020(target709);
|
||||
vec3 reference2020 = to_bt2020(reference709);
|
||||
vec3 target_lms = BT2020_TO_LMS * target2020;
|
||||
float target_t = target_lms.x + target_lms.y;
|
||||
if (target_t <= MB_T_MIN) return target709;
|
||||
|
||||
float target_purity = mb_apply_bt2020(target2020, 1.0).purity;
|
||||
float reference_purity = mb_apply_bt2020(reference2020, 1.0).purity;
|
||||
float applied_purity = mix(target_purity, reference_purity, clamp(purity_strength, 0.0, 1.0));
|
||||
|
||||
vec3 reference_lms = BT2020_TO_LMS * reference2020;
|
||||
vec2 white = MB_WHITE;
|
||||
vec2 target_direction = mb_from_lms(target_lms) - white;
|
||||
vec2 reference_direction = mb_from_lms(reference_lms) - white;
|
||||
float target_len_sq = dot(target_direction, target_direction);
|
||||
float reference_len_sq = dot(reference_direction, reference_direction);
|
||||
|
||||
if (target_len_sq < MB_NEAR_WHITE_EPSILON && reference_len_sq < MB_NEAR_WHITE_EPSILON)
|
||||
return correct_purity(target709, reference709, purity_strength);
|
||||
|
||||
vec2 target_unit = target_len_sq > MB_NEAR_WHITE_EPSILON
|
||||
? target_direction * inversesqrt(target_len_sq) : vec2(0.0);
|
||||
vec2 reference_unit = reference_len_sq > MB_NEAR_WHITE_EPSILON
|
||||
? reference_direction * inversesqrt(reference_len_sq) : target_unit;
|
||||
if (target_len_sq <= MB_NEAR_WHITE_EPSILON) target_unit = reference_unit;
|
||||
|
||||
float hue_blend = clamp(hue_strength, 0.0, 1.0);
|
||||
vec2 blended_unit = mix(target_unit, reference_unit, hue_blend);
|
||||
float blended_len_sq = dot(blended_unit, blended_unit);
|
||||
if (blended_len_sq <= MB_NEAR_WHITE_EPSILON) {
|
||||
blended_unit = hue_blend >= 0.5 ? reference_unit : target_unit;
|
||||
blended_len_sq = dot(blended_unit, blended_unit);
|
||||
}
|
||||
blended_unit *= inversesqrt(max(blended_len_sq, MB_EPSILON));
|
||||
|
||||
float seed_len = sqrt(max(target_len_sq, 0.0));
|
||||
if (seed_len <= 1e-6) seed_len = sqrt(max(reference_len_sq, 0.0));
|
||||
seed_len = max(seed_len, 1e-6);
|
||||
|
||||
vec3 seed_lms = lms_from_mb_t(white + blended_unit * seed_len, target_t);
|
||||
vec3 seed2020 = LMS_TO_BT2020 * seed_lms;
|
||||
return to_bt709(mb_apply_bt2020(seed2020, applied_purity).rgb);
|
||||
}
|
||||
|
||||
float hue_transfer_gate(vec3 donor) {
|
||||
float hi = maxc(donor), lo = minc(donor);
|
||||
float chroma = div_safe(hi - lo, hi, 0.0);
|
||||
return smoothstep(0.02, 0.12, chroma);
|
||||
}
|
||||
|
||||
float neutwo(float x) { return x * inversesqrt(x * x + 1.0); }
|
||||
float neutwo(float x, float peak) { return peak * x * inversesqrt(x * x + peak * peak); }
|
||||
|
||||
float max_channel_neutwo_scale(vec3 c) {
|
||||
float top = maxc(abs(c));
|
||||
return top > 0.0 ? neutwo(top) / top : 1.0;
|
||||
}
|
||||
|
||||
vec3 saturation_grade(vec3 c, vec4 w, vec4 g) {
|
||||
float d = c.r * 0.6666667 + (c.g + c.b) * w.z - 1.0;
|
||||
float grade = g.y * (1.0 - d * d) + g.x;
|
||||
float m = maxc(c);
|
||||
return vec3(m) + (c - vec3(m)) * grade;
|
||||
}
|
||||
|
||||
vec3 per_channel_neutwo_bt2020(vec3 c709, float peak) {
|
||||
vec3 c = max(to_bt2020(c709), vec3(0.0));
|
||||
c = vec3(neutwo(c.r, peak), neutwo(c.g, peak), neutwo(c.b, peak));
|
||||
return to_bt709(c);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 x = min(texture(fp_t_tcb_8, uv.xy).rgb, vec3(10000.0)) + texture(fp_t_tcb_A, uv.xy).rgb;
|
||||
@@ -42,33 +301,30 @@ void main() {
|
||||
float game = support_buffer.hdr.x > 0.0 ? support_buffer.hdr.x : 1.0;
|
||||
float peak = support_buffer.hdr.y > 1.0 ? support_buffer.hdr.y : 1.0;
|
||||
|
||||
float lum = max(x.r * 0.2989 + x.g * w.x + x.b * w.y, 0.0);
|
||||
float sdr = 1.0 - exp(-lum);
|
||||
vec3 by_lum = lum > 0.0 ? x * (curve(lum) / lum) : x;
|
||||
vec3 c = max(mix(by_lum, curve3(x), sdr * sdr), vec3(0.0));
|
||||
// RenoDX's default Gamma Correction = 2.2 adjusts the peak in the opposite direction of its post-tonemap
|
||||
// appearance correction. At 1000/203 this raises the Neutwo peak from about 4.926 to about 5.33.
|
||||
peak = gamma22_to_srgb_linear(peak);
|
||||
|
||||
// the game's saturation grade, on the colour scaled into 0..1 by its largest channel
|
||||
float s = max(maxc(c), 1.0);
|
||||
vec3 n = c / s;
|
||||
float m = maxc(n);
|
||||
float d = n.r * 0.6666667 + (n.g + n.b) * w.z - 1.0;
|
||||
float grade = g.y * (1.0 - d * d) + g.x;
|
||||
c = s * ((n - m) * grade + m);
|
||||
|
||||
// the game's own SDR result: the same blend clamped to 0..1, graded
|
||||
vec3 sdr_c = clamp(mix(lum > 0.0 ? x * (sdr / lum) : x, vec3(1.0) - exp(-x), sdr * sdr), 0.0, 1.0);
|
||||
float sm = maxc(sdr_c), sd = sdr_c.r * 0.6666667 + (sdr_c.g + sdr_c.b) * w.z - 1.0;
|
||||
sdr_c = (sdr_c - sm) * (g.y * (1.0 - sd * sd) + g.x) + sm;
|
||||
// Extended HDR carrier plus the original bounded SDR rendering used as RenoDX's color donor.
|
||||
vec3 c = extended_vanilla_tonemap(x);
|
||||
vec3 donor = clamp(vanilla_tonemap(x), vec3(0.0), vec3(1.0));
|
||||
float hue = clamp(support_buffer.hdr.z, 0.0, 1.0);
|
||||
const vec3 Y = vec3(0.2126, 0.7152, 0.0722); // Rec. 709 luminance
|
||||
float yc = dot(c, Y), ys = dot(sdr_c, Y);
|
||||
if (hue > 0.0 && ys > 1e-5) c = mix(c, max(sdr_c, vec3(0.0)) * (yc / ys), hue * smoothstep(0.5, 1.5, maxc(c)));
|
||||
c = correct_hue_and_purity(c, donor, hue * hue_transfer_gate(donor), hue * PURITY_PER_HUE);
|
||||
|
||||
// RenoDX temporarily compresses the largest channel with neutral Neutwo while the original TotK saturation grade
|
||||
// runs, then divides the compression back out. This avoids feeding the SDR-authored grade arbitrarily large HDR RGB.
|
||||
float grade_scale = max_channel_neutwo_scale(c);
|
||||
c = saturation_grade(c * grade_scale, w, g) / grade_scale;
|
||||
|
||||
// RenoDX's default BT.709 clamp is a non-negative clamp. Final display mapping is per-channel Neutwo in BT.2020,
|
||||
// which allows bright colors to converge toward white instead of preserving max-channel RGB ratios.
|
||||
c = max(c, vec3(0.0));
|
||||
c = per_channel_neutwo_bt2020(c, peak);
|
||||
|
||||
// Fold RenoDX's default 2.2 intermediate gamma correction into this native linear path. RenoDX first maps the
|
||||
// linear result from an sRGB display response to a pure 2.2 response, then encodes/decodes the intermediate as 2.2;
|
||||
// those latter two operations cancel, leaving this corrected linear value for HDR output.
|
||||
c = srgb_linear_to_gamma22_linear(c);
|
||||
|
||||
// roll-off of the largest channel from half the peak to the peak
|
||||
float top = maxc(c), knee = 0.5 * peak;
|
||||
if (top > knee) {
|
||||
float r = peak - knee;
|
||||
c *= (knee + r * (1.0 - exp(-(top - knee) / r))) / top;
|
||||
}
|
||||
color = vec4(max(c, vec3(0.0)) * game, 0.0);
|
||||
}
|
||||
+143
-58
@@ -17,7 +17,17 @@
|
||||
|
||||
typedef __uint128_t u128;
|
||||
#define SI static inline __attribute__((always_inline))
|
||||
// The noinline FP helpers are the slow paths of inline fast paths, called from cold blocks inside the lifted
|
||||
// functions. preserve_most makes the helper save the caller-saved GPRs it clobbers, so a call site does not spill and
|
||||
// reload its live values around the call. The helpers are static, so the convention never crosses a module boundary.
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(preserve_most)
|
||||
#define SN static __attribute__((noinline, preserve_most))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SN
|
||||
#define SN static __attribute__((noinline))
|
||||
#endif
|
||||
#define SIMD_CAT2(a, b) a##_##b
|
||||
#define SIMD_CAT(a, b) SIMD_CAT2(a, b)
|
||||
|
||||
@@ -34,6 +44,45 @@ typedef u128 __attribute__((aligned(1), may_alias)) u128u;
|
||||
|
||||
// ---- registers: VREG = whole V register as a vector type; VQ = source with the upper half cleared when
|
||||
// Q=0; VW = write, zeroing the upper half when Q=0. Scalar views of lane 0: VS8..VS64, VSF32/VSF64.
|
||||
// The helpers below reach registers through VGET/VSET (whole register), VP (address), VPR (address of a copy to read)
|
||||
// and VPW (address to write), and take VCTX instead of Cpu *c.
|
||||
// RT_VLOCALS (a chunk generated with gen.py --v-locals K defines it): a function keeps some V registers in `u128 vr[32]`;
|
||||
// VMASK (a constant in the function) has a bit per register held there, the rest stay in c->v, and every write sets
|
||||
// the register's bit in *vdp (the dirty mask that lets the syncs at calls and exits skip clean registers). Each access
|
||||
// is a whole-vector load or store, so clang's SROA turns the used elements of vr into SSA vectors in XMM registers.
|
||||
#ifdef RT_VLOCALS
|
||||
#define VCTX Cpu *c, u128 *vr, unsigned VMASK, unsigned *vdp
|
||||
#define VP(n) ((VMASK >> (n) & 1u) ? &vr[n] : &c->v[n])
|
||||
#define VV(n) (*(vu64 *)VP(n))
|
||||
#define VDIRTY(n) (*vdp |= 1u << ((n) & 31))
|
||||
#define VGET(n) ((u128)VV(n))
|
||||
#define VSET(n, x) ({ u128 _vx = (u128)(x); VDIRTY(n); VV(n) = (vu64){(uint64_t)_vx, (uint64_t)(_vx >> 64)}; })
|
||||
#define VPR(n) (&(u128){VGET(n)})
|
||||
#define VPW(n) (VDIRTY(n), VP(n))
|
||||
#define VREG(T, n) ((T)VV(n))
|
||||
#define VQ(T, Q, n) ((T)((Q) ? VV(n) : VV(n) & (vu64){~0ull, 0}))
|
||||
#define VW(T, Q, d, e) do { T _w = (e); VDIRTY(d); VV(d) = (Q) ? (vu64)_w : (vu64)_w & (vu64){~0ull, 0}; } while (0)
|
||||
#define VLANE(n, VT, i) (((VT)VV(n))[i])
|
||||
#define VLSET(n, VT, i, x) do { VT _l = (VT)VV(n); _l[i] = (x); VDIRTY(n); VV(n) = (vu64)_l; } while (0)
|
||||
#define VS8(n) VLANE(n, vu8, 0)
|
||||
#define VS16(n) VLANE(n, vu16, 0)
|
||||
#define VS32(n) VLANE(n, vu32, 0)
|
||||
#define VS64(n) VLANE(n, vu64, 0)
|
||||
#define VSF32(n) VLANE(n, vf32, 0)
|
||||
#define VSF64(n) VLANE(n, vf64, 0)
|
||||
#define VHI64(n) VLANE(n, vu64, 1)
|
||||
// the generated syncs: copy a local register in from c->v, out to c->v, out only if it may be dirty (the mask folds
|
||||
// to a constant on most paths, and a clean register's store then disappears)
|
||||
#define VSYNC_IN(r) (*(vu64 *)&vr[r] = *(vu64 *)&c->v[r])
|
||||
#define VSYNC_OUT(r) (*(vu64 *)&c->v[r] = *(vu64 *)&vr[r])
|
||||
#define VSYNC_OUT_D(r) do { if (!__builtin_constant_p(*vdp >> (r) & 1) || (*vdp >> (r) & 1)) VSYNC_OUT(r); } while (0)
|
||||
#else
|
||||
#define VCTX Cpu *c
|
||||
#define VP(n) (&c->v[n])
|
||||
#define VGET(n) (c->v[n])
|
||||
#define VSET(n, x) (c->v[n] = (x))
|
||||
#define VPR(n) VP(n)
|
||||
#define VPW(n) VP(n)
|
||||
#define VREG(T, n) (*(T *)&c->v[n])
|
||||
#define VQ(T, Q, n) ((T)((Q) ? c->v[n] : (u128)(uint64_t)c->v[n]))
|
||||
#define VW(T, Q, d, e) do { T _w = (e); c->v[d] = (Q) ? (u128)_w : (u128)(uint64_t)(u128)_w; } while (0)
|
||||
@@ -44,6 +93,7 @@ typedef u128 __attribute__((aligned(1), may_alias)) u128u;
|
||||
#define VSF32(n) (*(saf32 *)&c->v[n])
|
||||
#define VSF64(n) (*(saf64 *)&c->v[n])
|
||||
#define VHI64(n) (((sa64 *)&c->v[n])[1])
|
||||
#endif
|
||||
#define LD128(a) (*(const u128u *)(uintptr_t)(a))
|
||||
#define ST128(a, v) (*(u128u *)(uintptr_t)(a) = (u128)(v))
|
||||
#define SHUF __builtin_shufflevector
|
||||
@@ -234,6 +284,11 @@ SI void simd_rm_leave(unsigned old) {
|
||||
// plain host FP gives the ARM result unless FPCR.RMode asks for directed rounding, which the slow paths handle.
|
||||
SI int simd_directed(const Cpu *c) { return __builtin_expect((c->fpcr & FPCR_RM) != 0, 0); }
|
||||
|
||||
// FP result check threshold of the thread (cpu.h rt_fpcr_threshold), for one lane and for a whole vector.
|
||||
SI float simd_th_s(const Cpu *c) { return c->fp_th_s[0]; }
|
||||
SI double simd_th_d(const Cpu *c) { return c->fp_th_d[0]; }
|
||||
SI vf32 simd_thv_s(const Cpu *c) { return *(const vf32 *)c->fp_th_s; }
|
||||
SI vf64 simd_thv_d(const Cpu *c) { return *(const vf64 *)c->fp_th_d; }
|
||||
#define F s
|
||||
#define T float
|
||||
#define U uint32_t
|
||||
@@ -384,18 +439,23 @@ SI float simd_h2s(Cpu *c, uint16_t h) {
|
||||
}
|
||||
|
||||
// ---- scalar FP instructions (FP data processing)
|
||||
#ifdef RT_VLOCALS
|
||||
#define FP_SETS(d, x) (VDIRTY(d), VV(d) = (vu64)(vu32){fb_s(x), 0, 0, 0})
|
||||
#define FP_SETD(d, x) (VDIRTY(d), VV(d) = (vu64){fb_d(x), 0})
|
||||
#else
|
||||
#define FP_SETS(d, x) (c->v[d] = fb_s(x))
|
||||
#define FP_SETD(d, x) (c->v[d] = fb_d(x))
|
||||
SI void fp_op_s(Cpu *c, int op, int d, int n, int m) { FP_SETS(d, op_s(c, op, VSF32(n), VSF32(m), 0)); }
|
||||
SI void fp_op_d(Cpu *c, int op, int d, int n, int m) { FP_SETD(d, op_d(c, op, VSF64(n), VSF64(m), 0)); }
|
||||
#endif
|
||||
SI void fp_op_s(VCTX, int op, int d, int n, int m) { FP_SETS(d, op_s(c, op, VSF32(n), VSF32(m), 0)); }
|
||||
SI void fp_op_d(VCTX, int op, int d, int n, int m) { FP_SETD(d, op_d(c, op, VSF64(n), VSF64(m), 0)); }
|
||||
// FMADD family: neg_a / neg_n negate the addend / first factor before the fused op
|
||||
SI void fp_fma_s(Cpu *c, int na, int nn, int d, int n, int m, int a) {
|
||||
SI void fp_fma_s(VCTX, int na, int nn, int d, int n, int m, int a) {
|
||||
float x = VSF32(a), y = VSF32(n);
|
||||
if (na) x = neg_s(x);
|
||||
if (nn) y = neg_s(y);
|
||||
FP_SETS(d, op_s(c, FOP_MADD, x, y, VSF32(m)));
|
||||
}
|
||||
SI void fp_fma_d(Cpu *c, int na, int nn, int d, int n, int m, int a) {
|
||||
SI void fp_fma_d(VCTX, int na, int nn, int d, int n, int m, int a) {
|
||||
double x = VSF64(a), y = VSF64(n);
|
||||
if (na) x = neg_d(x);
|
||||
if (nn) y = neg_d(y);
|
||||
@@ -561,28 +621,28 @@ SI uint64_t lop(int op, int sz, uint64_t a, uint64_t b, uint64_t d) {
|
||||
// Generic lane loop: ne lanes; result lane i (size szd) goes to lane offd+i of d (other lanes kept when keep,
|
||||
// else zero); a = n lane offn+i (size szn), b = m lane offm+i (size szm), or lane bidx of m when bidx >= 0,
|
||||
// or the constant bimm when m < 0; the accumulator is d's old lane offd+i.
|
||||
SI void sl_gen(Cpu *c, int op, int sz, int ne, int d, int szd, int offd, int keep, int n, int szn, int offn, int m,
|
||||
SI void sl_gen(VCTX, int op, int sz, int ne, int d, int szd, int offd, int keep, int n, int szn, int offn, int m,
|
||||
int szm, int offm, int bidx, uint64_t bimm) {
|
||||
u128 a = c->v[n], b = m >= 0 ? c->v[m] : 0, o = c->v[d], r = keep ? o : 0;
|
||||
u128 a = VGET(n), b = m >= 0 ? VGET(m) : 0, o = VGET(d), r = keep ? o : 0;
|
||||
for (int i = 0; i < ne; i++) {
|
||||
uint64_t y = m < 0 ? bimm : lget(&b, szm, bidx >= 0 ? bidx : offm + i);
|
||||
lset(&r, szd, offd + i, lop(op, sz, lget(&a, szn, offn + i), y, lget(&o, szd, offd + i)));
|
||||
}
|
||||
c->v[d] = r;
|
||||
VSET(d, r);
|
||||
}
|
||||
// SADDLP/UADDLP/SADALP/UADALP
|
||||
SI void sl_addlp(Cpu *c, int u, int acc, int Q, int sz, int d, int n) {
|
||||
u128 a = c->v[n], o = c->v[d], r = 0;
|
||||
SI void sl_addlp(VCTX, int u, int acc, int Q, int sz, int d, int n) {
|
||||
u128 a = VGET(n), o = VGET(d), r = 0;
|
||||
for (int i = 0; i < (4 << Q) >> sz; i++) {
|
||||
uint64_t x = lget(&a, sz, 2 * i), y = lget(&a, sz, 2 * i + 1);
|
||||
uint64_t s = u ? x + y : (uint64_t)(lsx(x, sz) + lsx(y, sz));
|
||||
lset(&r, sz + 1, i, s + (acc ? lget(&o, sz + 1, i) : 0));
|
||||
}
|
||||
c->v[d] = r;
|
||||
VSET(d, r);
|
||||
}
|
||||
// ADDV, SADDLV/UADDLV, SMAXV/UMAXV, SMINV/UMINV (op 0..3; u = unsigned)
|
||||
SI void sl_across(Cpu *c, int op, int u, int Q, int sz, int d, int n) {
|
||||
u128 a = c->v[n];
|
||||
SI void sl_across(VCTX, int op, int u, int Q, int sz, int d, int n) {
|
||||
u128 a = VGET(n);
|
||||
int ne = (8 << Q) >> sz;
|
||||
int64_t acc = u ? (int64_t)lget(&a, sz, 0) : lsx(lget(&a, sz, 0), sz);
|
||||
for (int i = 1; i < ne; i++) {
|
||||
@@ -591,12 +651,12 @@ SI void sl_across(Cpu *c, int op, int u, int Q, int sz, int d, int n) {
|
||||
else if (op == 2) acc = u ? ((uint64_t)x > (uint64_t)acc ? x : acc) : (x > acc ? x : acc);
|
||||
else acc = u ? ((uint64_t)x < (uint64_t)acc ? x : acc) : (x < acc ? x : acc);
|
||||
}
|
||||
c->v[d] = (uint64_t)acc & lmask(op == 1 ? sz + 1 : sz);
|
||||
VSET(d, (uint64_t)acc & lmask(op == 1 ? sz + 1 : sz));
|
||||
}
|
||||
// PMULL2/PMULL 1Q (64x64 -> 128 carry-less)
|
||||
SI void sl_pmull64(Cpu *c, int part, int d, int n, int m) {
|
||||
uint64_t hi, lo = pmul64(((sa64 *)&c->v[n])[part], ((sa64 *)&c->v[m])[part], &hi);
|
||||
c->v[d] = ((u128)hi << 64) | lo;
|
||||
SI void sl_pmull64(VCTX, int part, int d, int n, int m) {
|
||||
uint64_t hi, lo = pmul64(((sa64 *)VP(n))[part], ((sa64 *)VP(m))[part], &hi);
|
||||
VSET(d, ((u128)hi << 64) | lo);
|
||||
}
|
||||
|
||||
// ---- FP vector helpers: lanes of the 64-bit form are computed on a zero upper half
|
||||
@@ -609,9 +669,9 @@ SI vf64 vneg_d(vf64 v) { return (vf64)((vu64)v ^ 0x8000000000000000ull); }
|
||||
SI float pair_s(Cpu *c, int op, float a, float b) { return op_s(c, op, a, b, 0); }
|
||||
SI double pair_d(Cpu *c, int op, double a, double b) { return op_d(c, op, a, b, 0); }
|
||||
// FMAXV/FMINV/FMAXNMV/FMINNMV (4S): pairwise tree
|
||||
SI void sv_fred_s(Cpu *c, int op, int d, int n) {
|
||||
SI void sv_fred_s(VCTX, int op, int d, int n) {
|
||||
vf32 v = VREG(vf32, n);
|
||||
c->v[d] = fb_s(pair_s(c, op, pair_s(c, op, v[0], v[1]), pair_s(c, op, v[2], v[3])));
|
||||
VSET(d, fb_s(pair_s(c, op, pair_s(c, op, v[0], v[1]), pair_s(c, op, v[2], v[3]))));
|
||||
}
|
||||
// lane-wise FP conversions
|
||||
SI vu32 vtoint_s(Cpu *c, vf32 v, int rm, int fbits, int uns) {
|
||||
@@ -645,8 +705,8 @@ SI vf32 vrsqrte_s(Cpu *c, vf32 v) { for (int i = 0; i < 4; i++) v[i] = rsqrte_s(
|
||||
SI vf64 vrsqrte_d(Cpu *c, vf64 v) { for (int i = 0; i < 2; i++) v[i] = rsqrte_d(c, v[i]); return v; }
|
||||
|
||||
// FCVTL/FCVTL2 (h->s, s->d), FCVTN/FCVTN2 (s->h, d->s), FCVTXN/FCVTXN2
|
||||
SI void sv_fcvtl(Cpu *c, int sz, int part, int d, int n) {
|
||||
u128 a = c->v[n], r = 0;
|
||||
SI void sv_fcvtl(VCTX, int sz, int part, int d, int n) {
|
||||
u128 a = VGET(n), r = 0;
|
||||
if (sz == 0) {
|
||||
vf32 o;
|
||||
for (int i = 0; i < 4; i++) o[i] = simd_h2s(c, (uint16_t)lget(&a, 1, 4 * part + i));
|
||||
@@ -656,10 +716,10 @@ SI void sv_fcvtl(Cpu *c, int sz, int part, int d, int n) {
|
||||
for (int i = 0; i < 2; i++) o[i] = simd_s2d(c, fv_s((uint32_t)lget(&a, 2, 2 * part + i)));
|
||||
r = (u128)o;
|
||||
}
|
||||
c->v[d] = r;
|
||||
VSET(d, r);
|
||||
}
|
||||
SI void sv_fcvtn(Cpu *c, int sz, int part, int odd, int d, int n) {
|
||||
u128 a = c->v[n], r = part ? (uint64_t)c->v[d] : 0;
|
||||
SI void sv_fcvtn(VCTX, int sz, int part, int odd, int d, int n) {
|
||||
u128 a = VGET(n), r = part ? (uint64_t)VGET(d) : 0;
|
||||
if (sz == 0) {
|
||||
for (int i = 0; i < 4; i++) lset(&r, 1, 4 * part + i, simd_s2h(c, fv_s((uint32_t)lget(&a, 2, i))));
|
||||
} else {
|
||||
@@ -668,19 +728,19 @@ SI void sv_fcvtn(Cpu *c, int sz, int part, int odd, int d, int n) {
|
||||
lset(&r, 2, 2 * part + i, fb_s(odd ? simd_d2s_odd(c, x) : simd_d2s(c, x)));
|
||||
}
|
||||
}
|
||||
c->v[d] = r;
|
||||
VSET(d, r);
|
||||
}
|
||||
|
||||
// TBL / TBX with len+1 table registers
|
||||
SI void sv_tbl(Cpu *c, int Q, int len, int tbx, int d, int n, int m) {
|
||||
SI void sv_tbl(VCTX, int Q, int len, int tbx, int d, int n, int m) {
|
||||
uint8_t tab[64];
|
||||
for (int i = 0; i <= len; i++) memcpy(tab + 16 * i, &c->v[(n + i) & 31], 16);
|
||||
u128 idx = c->v[m], o = c->v[d], r = 0;
|
||||
for (int i = 0; i <= len; i++) memcpy(tab + 16 * i, VP((n + i) & 31), 16);
|
||||
u128 idx = VGET(m), o = VGET(d), r = 0;
|
||||
for (int i = 0; i < 8 << Q; i++) {
|
||||
unsigned k = (unsigned)lget(&idx, 0, i);
|
||||
lset(&r, 0, i, k < 16u * (len + 1) ? tab[k] : tbx ? lget(&o, 0, i) : 0);
|
||||
}
|
||||
c->v[d] = r;
|
||||
VSET(d, r);
|
||||
}
|
||||
|
||||
// ---- CRC32 / CRC32C (bytes = 1, 2, 4, 8)
|
||||
@@ -697,9 +757,9 @@ SI uint8_t aes_mul(uint8_t x, int k) { // k in {9, 11, 13, 14}
|
||||
uint8_t x2 = aes_xt(x), x4 = aes_xt(x2), x8 = aes_xt(x4);
|
||||
return (uint8_t)(x8 ^ (k & 4 ? x4 : 0) ^ (k & 2 ? x2 : 0) ^ (k & 1 ? x : 0));
|
||||
}
|
||||
SI void sv_aes(Cpu *c, int op, int d, int n) { // 0 AESE, 1 AESD, 2 AESMC, 3 AESIMC
|
||||
SI void sv_aes(VCTX, int op, int d, int n) { // 0 AESE, 1 AESD, 2 AESMC, 3 AESIMC
|
||||
uint8_t s[16], r[16];
|
||||
u128 v = op < 2 ? c->v[d] ^ c->v[n] : c->v[n];
|
||||
u128 v = op < 2 ? VGET(d) ^ VGET(n) : VGET(n);
|
||||
memcpy(s, &v, 16);
|
||||
if (op == 0) {
|
||||
for (int i = 0; i < 16; i++) r[i] = simd_aes_sbox[s[(i + 4 * (i & 3)) & 15]];
|
||||
@@ -716,14 +776,14 @@ SI void sv_aes(Cpu *c, int op, int d, int n) { // 0 AESE, 1 AESD, 2 AESMC, 3 AES
|
||||
}
|
||||
}
|
||||
memcpy(&v, r, 16);
|
||||
c->v[d] = v;
|
||||
VSET(d, v);
|
||||
}
|
||||
SI uint32_t rol32_(uint32_t x, int s) { return (x << s) | (x >> (32 - s)); }
|
||||
SI uint32_t ror32_(uint32_t x, int s) { return (x >> s) | (x << (32 - s)); }
|
||||
SI void sv_sha1hash(Cpu *c, int op, int d, int n, int m) { // 0 SHA1C, 1 SHA1P, 2 SHA1M
|
||||
uint32_t x[4], w[4], y = (uint32_t)c->v[n];
|
||||
memcpy(x, &c->v[d], 16);
|
||||
memcpy(w, &c->v[m], 16);
|
||||
SI void sv_sha1hash(VCTX, int op, int d, int n, int m) { // 0 SHA1C, 1 SHA1P, 2 SHA1M
|
||||
uint32_t x[4], w[4], y = (uint32_t)VGET(n);
|
||||
memcpy(x, VP(d), 16);
|
||||
memcpy(w, VP(m), 16);
|
||||
for (int e = 0; e < 4; e++) {
|
||||
uint32_t t = op == 0 ? (((x[2] ^ x[3]) & x[1]) ^ x[3]) : op == 1 ? (x[1] ^ x[2] ^ x[3])
|
||||
: ((x[1] & x[2]) | ((x[1] | x[2]) & x[3]));
|
||||
@@ -732,13 +792,13 @@ SI void sv_sha1hash(Cpu *c, int op, int d, int n, int m) { // 0 SHA1C, 1 SHA1P,
|
||||
uint32_t top = x[3];
|
||||
x[3] = x[2], x[2] = x[1], x[1] = x[0], x[0] = y, y = top;
|
||||
}
|
||||
memcpy(&c->v[d], x, 16);
|
||||
memcpy(VPW(d), x, 16);
|
||||
}
|
||||
SI void sv_sha256hash(Cpu *c, int part1, int d, int n, int m) { // SHA256H (part1), SHA256H2
|
||||
SI void sv_sha256hash(VCTX, int part1, int d, int n, int m) { // SHA256H (part1), SHA256H2
|
||||
uint32_t x[4], y[4], w[4];
|
||||
memcpy(part1 ? x : y, &c->v[d], 16);
|
||||
memcpy(part1 ? y : x, &c->v[n], 16);
|
||||
memcpy(w, &c->v[m], 16);
|
||||
memcpy(part1 ? x : y, VP(d), 16);
|
||||
memcpy(part1 ? y : x, VP(n), 16);
|
||||
memcpy(w, VP(m), 16);
|
||||
for (int e = 0; e < 4; e++) {
|
||||
uint32_t chs = ((y[1] ^ y[2]) & y[0]) ^ y[2];
|
||||
uint32_t maj = (x[0] & x[1]) | ((x[0] | x[1]) & x[2]);
|
||||
@@ -749,13 +809,13 @@ SI void sv_sha256hash(Cpu *c, int part1, int d, int n, int m) { // SHA256H (part
|
||||
y[3] = y[2], y[2] = y[1], y[1] = y[0], y[0] = x[3];
|
||||
x[3] = x[2], x[2] = x[1], x[1] = x[0], x[0] = t;
|
||||
}
|
||||
memcpy(&c->v[d], part1 ? x : y, 16);
|
||||
memcpy(VPW(d), part1 ? x : y, 16);
|
||||
}
|
||||
SI void sv_sha_misc(Cpu *c, int op, int d, int n, int m) { // 0 SHA1SU0, 1 SHA1SU1, 2 SHA256SU0, 3 SHA256SU1, 4 SHA1H
|
||||
SI void sv_sha_misc(VCTX, int op, int d, int n, int m) { // 0 SHA1SU0, 1 SHA1SU1, 2 SHA256SU0, 3 SHA256SU1, 4 SHA1H
|
||||
uint32_t a[4], b[4], k[4], r[4], t[4];
|
||||
memcpy(a, &c->v[d], 16);
|
||||
memcpy(b, &c->v[n], 16);
|
||||
memcpy(k, &c->v[m], 16);
|
||||
memcpy(a, VP(d), 16);
|
||||
memcpy(b, VP(n), 16);
|
||||
memcpy(k, VP(m), 16);
|
||||
switch (op) {
|
||||
case 0:
|
||||
t[0] = a[2], t[1] = a[3], t[2] = b[0], t[3] = b[1];
|
||||
@@ -779,10 +839,10 @@ SI void sv_sha_misc(Cpu *c, int op, int d, int n, int m) { // 0 SHA1SU0, 1 SHA1S
|
||||
break;
|
||||
}
|
||||
default:
|
||||
c->v[d] = rol32_(b[0], 30);
|
||||
VSET(d, rol32_(b[0], 30));
|
||||
return;
|
||||
}
|
||||
memcpy(&c->v[d], r, 16);
|
||||
memcpy(VPW(d), r, 16);
|
||||
}
|
||||
|
||||
// ---- loads / stores of lanes
|
||||
@@ -803,39 +863,64 @@ SI void simd_st(uint64_t a, int sz, uint64_t v) {
|
||||
}
|
||||
}
|
||||
// LDn/STn (multiple structures): selem interleaved registers, rpt repeats (LD1 with 2-4 registers)
|
||||
SI void sl_ldm(Cpu *c, int Q, int sz, int selem, int rpt, int t, uint64_t ea) {
|
||||
SI void sl_ldm(VCTX, int Q, int sz, int selem, int rpt, int t, uint64_t ea) {
|
||||
u128 r[4] = {0, 0, 0, 0};
|
||||
int ne = (8 << Q) >> sz;
|
||||
for (int k = 0; k < rpt; k++)
|
||||
for (int e = 0; e < ne; e++)
|
||||
for (int s = 0; s < selem; s++, ea += 1 << sz) lset(&r[k + s], sz, e, simd_ld(ea, sz));
|
||||
for (int i = 0; i < rpt + selem - 1; i++) c->v[(t + i) & 31] = r[i];
|
||||
for (int i = 0; i < rpt + selem - 1; i++) VSET((t + i) & 31, r[i]);
|
||||
}
|
||||
SI void sl_stm(Cpu *c, int Q, int sz, int selem, int rpt, int t, uint64_t ea) {
|
||||
SI void sl_stm(VCTX, int Q, int sz, int selem, int rpt, int t, uint64_t ea) {
|
||||
u128 r[4];
|
||||
int ne = (8 << Q) >> sz;
|
||||
for (int i = 0; i < rpt + selem - 1; i++) r[i] = c->v[(t + i) & 31];
|
||||
for (int i = 0; i < rpt + selem - 1; i++) r[i] = VGET((t + i) & 31);
|
||||
for (int k = 0; k < rpt; k++)
|
||||
for (int e = 0; e < ne; e++)
|
||||
for (int s = 0; s < selem; s++, ea += 1 << sz) simd_st(ea, sz, lget(&r[k + s], sz, e));
|
||||
}
|
||||
// single structure: lane idx of selem registers; LDnR replicates into every lane
|
||||
SI void sl_lds(Cpu *c, int sz, int selem, int idx, int t, uint64_t ea) {
|
||||
SI void sl_lds(VCTX, int sz, int selem, int idx, int t, uint64_t ea) {
|
||||
for (int s = 0; s < selem; s++) {
|
||||
u128 v = c->v[(t + s) & 31];
|
||||
u128 v = VGET((t + s) & 31);
|
||||
lset(&v, sz, idx, simd_ld(ea + (s << sz), sz));
|
||||
c->v[(t + s) & 31] = v;
|
||||
VSET((t + s) & 31, v);
|
||||
}
|
||||
}
|
||||
SI void sl_sts(Cpu *c, int sz, int selem, int idx, int t, uint64_t ea) {
|
||||
for (int s = 0; s < selem; s++) simd_st(ea + (s << sz), sz, lget(&c->v[(t + s) & 31], sz, idx));
|
||||
SI void sl_sts(VCTX, int sz, int selem, int idx, int t, uint64_t ea) {
|
||||
for (int s = 0; s < selem; s++) simd_st(ea + (s << sz), sz, lget(VPR((t + s) & 31), sz, idx));
|
||||
}
|
||||
SI void sl_ldr(Cpu *c, int Q, int sz, int selem, int t, uint64_t ea) {
|
||||
SI void sl_ldr(VCTX, int Q, int sz, int selem, int t, uint64_t ea) {
|
||||
uint64_t x[4];
|
||||
for (int s = 0; s < selem; s++) x[s] = simd_ld(ea + (s << sz), sz);
|
||||
for (int s = 0; s < selem; s++) {
|
||||
u128 v = 0;
|
||||
for (int e = 0; e < (8 << Q) >> sz; e++) lset(&v, sz, e, x[s]);
|
||||
c->v[(t + s) & 31] = v;
|
||||
VSET((t + s) & 31, v);
|
||||
}
|
||||
}
|
||||
|
||||
// RT_VLOCALS: the generated code calls the helpers above with c alone; they also take the locals
|
||||
#ifdef RT_VLOCALS
|
||||
#define fp_op_s(c, ...) fp_op_s(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define fp_op_d(c, ...) fp_op_d(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define fp_fma_s(c, ...) fp_fma_s(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define fp_fma_d(c, ...) fp_fma_d(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_gen(c, ...) sl_gen(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_addlp(c, ...) sl_addlp(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_across(c, ...) sl_across(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_pmull64(c, ...) sl_pmull64(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_fred_s(c, ...) sv_fred_s(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_fcvtl(c, ...) sv_fcvtl(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_fcvtn(c, ...) sv_fcvtn(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_tbl(c, ...) sv_tbl(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_aes(c, ...) sv_aes(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_sha1hash(c, ...) sv_sha1hash(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_sha256hash(c, ...) sv_sha256hash(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sv_sha_misc(c, ...) sv_sha_misc(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_ldm(c, ...) sl_ldm(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_stm(c, ...) sl_stm(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_lds(c, ...) sl_lds(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_sts(c, ...) sl_sts(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#define sl_ldr(c, ...) sl_ldr(c, vr, VMASK, vdp, __VA_ARGS__)
|
||||
#endif
|
||||
+44
-9
@@ -204,21 +204,34 @@ SN T FN(slow)(Cpu *c, int op, T a, T b, T d) {
|
||||
// The complement of FREDO for every op but RSQRTS, as one compare: |r| ordered and not the smallest normal (LLVM folds
|
||||
// it to fcmp one, a single ucomiss + jne for scalars and one vcmpps for vectors).
|
||||
#define FOK(r) ((__builtin_elementwise_abs(r) < FN(fv)(MINN)) | (__builtin_elementwise_abs(r) > FN(fv)(MINN)))
|
||||
// FOK against the thread's threshold (cpu.h rt_fpcr_threshold), the check of the fast paths: the same as FOK in
|
||||
// round-to-nearest, where the threshold is the smallest normal, and false for every result under a directed RMode,
|
||||
// where the threshold is NaN, so that RMode needs no test of its own. The threshold is a memory operand of the compare.
|
||||
#define FOKT(r, th) ((__builtin_elementwise_abs(r) < (th)) | (__builtin_elementwise_abs(r) > (th)))
|
||||
// A result FOKT rejected. A NaN result in round-to-nearest goes straight to fix: the host already ran the operation
|
||||
// on the operands FPCR.FZ flushes (MXCSR.DAZ), so slow would compute the same NaN and return fix of the flushed
|
||||
// operands, and fix's result for these ops is never tiny, so slow's FZ result flush would leave it alone. RSQRTS
|
||||
// keeps the slow path because its fix result can be tiny.
|
||||
SN T FN(redo)(Cpu *c, int op, T a, T b, T d, T r) {
|
||||
if (c->fpcr & (FPCR_FZ | FPCR_RM)) return FN(slow)(c, op, a, b, d);
|
||||
uint64_t fpcr = c->fpcr;
|
||||
if (op != FOP_RSQRTS && !(fpcr & FPCR_RM) && r != r) {
|
||||
if (fpcr & FPCR_FZ) a = FN(flush)(a), b = FN(flush)(b), d = FN(flush)(d);
|
||||
return FN(fix)(c, op, a, b, d);
|
||||
}
|
||||
if (fpcr & (FPCR_FZ | FPCR_RM)) return FN(slow)(c, op, a, b, d);
|
||||
return FBAD(op, r) ? FN(fix)(c, op, a, b, d) : r;
|
||||
}
|
||||
|
||||
// Scalar FP op (constant op folds the selection). RMode = nearest runs on the host, with or without FZ. A directed
|
||||
// RMode is rare, so it shares the result check's branch: the host result, computed in round-to-nearest, is then
|
||||
// thrown away and redo recomputes in the FPCR mode. Min and max do not round, so RMode does not matter to them.
|
||||
// RMode is rare, so it shares the result check (the FOKT threshold): the host result, computed in round-to-nearest,
|
||||
// is then thrown away and redo recomputes in the FPCR mode. Min and max do not round, so RMode does not matter to them.
|
||||
SI T FN(op)(Cpu *c, int op, T a, T b, T d) {
|
||||
if (FMINMAX(op)) {
|
||||
if (c->fpcr & FPCR_FZ) a = FN(flush)(a), b = FN(flush)(b);
|
||||
return FN(minmax)(c, op, a, b);
|
||||
}
|
||||
T r = FCALC(op, a, b, d, K, FMA_S);
|
||||
if (__builtin_expect((op == FOP_RSQRTS ? FREDO(op, r) : !FOK(r)) | simd_directed(c), 0))
|
||||
if (__builtin_expect(op == FOP_RSQRTS ? FREDO(op, r) | simd_directed(c) : !FOKT(r, SIMD_CAT(simd_th, F)(c)), 0))
|
||||
r = FN(redo)(c, op, a, b, d, r);
|
||||
return r;
|
||||
}
|
||||
@@ -228,6 +241,24 @@ SN VT FN(vslow)(Cpu *c, int op, VT a, VT b, VT d) {
|
||||
for (int i = 0; i < NL; i++) r[i] = FN(op)(c, op, a[i], b[i], d[i]);
|
||||
return r;
|
||||
}
|
||||
// Slow path of FN(vop) for a vector with flagged lanes. The operands come in c->fp_arg, stored by the caller just
|
||||
// before the call: passing three vectors by value costs every call site a stack copy of each (Win64 passes them by
|
||||
// reference), and the frames of the large lifted functions grow past a page (a ___chkstk_ms call at every entry). The
|
||||
// scratch is per thread and nothing runs between the store and the loads here. In round-to-nearest a lane that passed
|
||||
// the check equals what the scalar op returns for it (same host operation, same MXCSR), so only the flagged lanes go
|
||||
// through FN(op); the vector result is recomputed here rather than passed in, which keeps the call sites small. A
|
||||
// directed RMode reruns every lane.
|
||||
SN VT FN(vredo)(Cpu *c, int op) {
|
||||
VT a, b, d;
|
||||
memcpy(&a, &c->fp_arg[0], sizeof a);
|
||||
memcpy(&b, &c->fp_arg[1], sizeof b);
|
||||
memcpy(&d, &c->fp_arg[2], sizeof d);
|
||||
if (c->fpcr & FPCR_RM) return FN(vslow)(c, op, a, b, d);
|
||||
VT r = FCALC(op, a, b, d, VK, FMA_V);
|
||||
for (int i = 0; i < NL; i++)
|
||||
if (op == FOP_RSQRTS ? FREDO(op, r[i]) : !FOK(r[i])) r[i] = FN(op)(c, op, a[i], b[i], d[i]);
|
||||
return r;
|
||||
}
|
||||
|
||||
SI VTU FN(vsel)(VTS m, VTU x, VTU y) { return (x & (VTU)m) | (y & ~(VTU)m); }
|
||||
|
||||
@@ -239,8 +270,8 @@ SI VT FN(vflush)(VT a) {
|
||||
return (VT)FN(vsel)(den, u & SGN, u);
|
||||
}
|
||||
|
||||
// Vector FP op: native lanes; any lane FREDO flags (or a directed FPCR.RMode, checked in the same branch) reruns all
|
||||
// lanes through the scalar path. Min and max ignore RMode, as in FN(op).
|
||||
// Vector FP op: native lanes; a lane FREDO flags, or a directed FPCR.RMode (the FOKT threshold, or the RSQRTS test),
|
||||
// takes FN(vredo). Min and max ignore RMode, as in FN(op).
|
||||
SI VT FN(vop)(Cpu *c, int op, VT a, VT b, VT d) {
|
||||
VT r;
|
||||
if (FMINMAX(op)) {
|
||||
@@ -254,9 +285,13 @@ SI VT FN(vop)(Cpu *c, int op, VT a, VT b, VT d) {
|
||||
return r;
|
||||
}
|
||||
r = FCALC(op, a, b, d, VK, FMA_V);
|
||||
if (__builtin_expect((op == FOP_RSQRTS ? __builtin_reduce_or(FREDO(op, r)) != 0 : __builtin_reduce_and(FOK(r)) == 0)
|
||||
| simd_directed(c), 0))
|
||||
return FN(vslow)(c, op, a, b, d);
|
||||
if (__builtin_expect(op == FOP_RSQRTS ? (__builtin_reduce_or(FREDO(op, r)) != 0) | simd_directed(c)
|
||||
: __builtin_reduce_and(FOKT(r, SIMD_CAT(simd_thv, F)(c))) == 0, 0)) {
|
||||
memcpy(&c->fp_arg[0], &a, sizeof a);
|
||||
memcpy(&c->fp_arg[1], &b, sizeof b);
|
||||
memcpy(&c->fp_arg[2], &d, sizeof d);
|
||||
return FN(vredo)(c, op);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -453,6 +453,7 @@ static int test_virtual(pool_t *phys, pool_t *virt) {
|
||||
static tex_t make_tex(pool_t *pool, uint64_t off, int format, uint32_t w, uint32_t h, uint32_t levels, uint64_t serial) {
|
||||
tex_t t;
|
||||
memset(&t, 0, sizeof t);
|
||||
t.pool_flags = (uint16_t)pool->flags;
|
||||
t.magic = MAGIC('T', 'E', 'X', 0);
|
||||
t.d.target = 1, t.d.format = format, t.d.width = w, t.d.height = h, t.d.depth = 1, t.d.levels = levels;
|
||||
nvn_tex_layout(&t.d, &t.L);
|
||||
@@ -529,14 +530,21 @@ static int test_textures(pool_t *tpool, pool_t *phys) {
|
||||
vk_write_texels(&g, NULL, &all, gl[0], 256, 256 * 64);
|
||||
if (read_back(&g, 0, gl, 0, "physical-pool RGBA8 WriteTexels")) return 1;
|
||||
|
||||
// a slot of a finalized texture follows the live texture at the same storage (MNG hle_nvn.c)
|
||||
// a slot of a finalized texture follows the live texture of its texel format at the same storage (MNG hle_nvn.c);
|
||||
// a live texture of another format there holds another texture's texels and leaves the slot alone
|
||||
// (vk_texture.c slot_resolve)
|
||||
vk_texture_register(5, &b, NULL);
|
||||
vk_texture_release(&b);
|
||||
tex_t b2 = make_tex(tpool, 0x40000, 0x25, 16, 12, 1, 4);
|
||||
tex_t b2 = make_tex(tpool, 0x40000, 0x42, 16, 12, 1, 4);
|
||||
const VkTexImage *live = vk_texture_get(&b2);
|
||||
VkImage live_img = live ? live->image : VK_NULL_HANDLE;
|
||||
const VkTexImage *slot = vk_texture_by_id(5, NULL, NULL);
|
||||
GCHECK(live && slot && slot->image == live_img, "slot 5 does not follow the live texture at its storage");
|
||||
tex_t b3 = make_tex(tpool, 0x40000, 0x25, 32, 32, 1, 5);
|
||||
const VkTexImage *other = vk_texture_get(&b3);
|
||||
slot = vk_texture_by_id(5, NULL, NULL);
|
||||
GCHECK(other && slot && slot->image == live_img, "slot 5 follows a live texture of another format at its storage");
|
||||
vk_texture_release(&b3);
|
||||
samp_par sp;
|
||||
memset(&sp, 0, sizeof sp);
|
||||
sp.minf = NVN_MIN_FILTER_LINEAR_MIPMAP_LINEAR, sp.magf = NVN_MAG_FILTER_LINEAR, sp.ws = sp.wt = sp.wr = NVN_WRAP_MODE_REPEAT;
|
||||
@@ -544,7 +552,7 @@ static int test_textures(pool_t *tpool, pool_t *phys) {
|
||||
vk_sampler_register(0, &sp);
|
||||
VkSampler s0 = vk_sampler_by_id(0), s1 = vk_sampler_for(&sp);
|
||||
GCHECK(s0 && s0 == s1 && !vk_sampler_by_id(1), "sampler slots");
|
||||
g_gpu_checks += 7;
|
||||
g_gpu_checks += 8;
|
||||
vk_texture_release(&t), vk_texture_release(&b2), vk_texture_release(&g);
|
||||
for (int i = 0; i < 4; i++) free(lin[i]), free(bl[i]);
|
||||
free(gl[0]);
|
||||
|
||||
@@ -21,7 +21,7 @@ void rt_log(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
static_assert(UI_BIND_SHAKE - UI_BIND_A == ACTION_COUNT - 1 && B_SHAKE == ACTION_COUNT - 1, "UI_BIND_* follow the actions");
|
||||
static_assert(UI_BIND_DESC_MINUS - UI_BIND_DESC_A == B_MINUS, "UI_BIND_DESC_* follow the actions");
|
||||
static_assert(UI_KEY_PAGEDOWN - UI_KEY_SPACE == KEY_PAGEDOWN - KEY_SPACE, "UI_KEY_* follow the key ids");
|
||||
static_assert(UI_PAD_RPADDLE2 - UI_PAD_SOUTH == PAD_RPADDLE2 - PAD_SOUTH && PAD_RPADDLE2 == PAD_COUNT - 1,
|
||||
static_assert(UI_PAD_TOUCHPAD - UI_PAD_SOUTH == PAD_TOUCHPAD - PAD_SOUTH && PAD_TOUCHPAD == PAD_COUNT - 1,
|
||||
"UI_PAD_* follow the pad ids");
|
||||
|
||||
enum { CAPTURE_SECONDS = 5 };
|
||||
|
||||
+128
-5
@@ -58,6 +58,9 @@ extern const int rt_game_version;
|
||||
extern const char rt_port_version[];
|
||||
void cheats_frame(uint64_t frame); // cheats.c
|
||||
bool tab_cheats(float scale); // ui/cheats_tab.cpp; true: restart into the rebuild
|
||||
// audren.h pulls in cpu.h through host.h: the one call the Sound tab needs from it, as declared there.
|
||||
enum { AUDIO_DEVICE_NAME_MAX = 256 };
|
||||
int audio_output_devices(char (*names)[AUDIO_DEVICE_NAME_MAX], int max);
|
||||
int playtime_get(uint64_t *total_s, uint64_t *session_s); // playtime.c
|
||||
bool amiibo_check_font_rebuild(void); // ui/amiibo_page.cpp; check and clear font rebuild request
|
||||
}
|
||||
@@ -515,7 +518,35 @@ static void row_output_res(void) {
|
||||
snprintf(shown[i], sizeof shown[i], "%d × %d", w, h); // U+00D7, the multiplication sign
|
||||
names[i] = shown[i];
|
||||
}
|
||||
opt_choice_list("TOTK_OUTPUT_RES", UI_MENU_OUTPUT_RES, vals, names, N, UI_MENU_OUTPUT_RES_DESC);
|
||||
// A size of another shape needs that shape's folders (romfs.c overlay_init): the layout, and with Xbox or PC
|
||||
// prompts the prompts' one too. The setup writes them for the displays it saw (installer/steps.py Shapes); at a
|
||||
// shape without them the game draws 16:9 with bars or keeps the Switch prompts, so the row says so and offers to
|
||||
// start the generator for the next start (romfs_shape_prepare; a child process, the menu does not wait). The file
|
||||
// checks run again only when a setting or the started generation changes.
|
||||
static unsigned seen = ~0u;
|
||||
static int missing, started; // started: 0 not asked, 1 running, -1 failed to start
|
||||
static char asked[16];
|
||||
const char *now = cfg_value("TOTK_OUTPUT_RES");
|
||||
if (seen != cfg_version()) {
|
||||
seen = cfg_version();
|
||||
unsigned w = 0, h = 0;
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
|
||||
const char *want = input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout);
|
||||
missing = sscanf(now, "%ux%u", &w, &h) == 2 && romfs_shape_missing(w, h, want);
|
||||
}
|
||||
int here = started && !strcmp(asked, now); // the generation started for the value shown
|
||||
const char *note = !missing ? nullptr
|
||||
: here ? menu_text(started > 0 ? UI_MENU_OUTPUT_RES_PREPARING : UI_MENU_SHAPE_PREPARE_FAILED)
|
||||
: menu_text(UI_MENU_OUTPUT_RES_NO_LAYOUT);
|
||||
opt_choice_list("TOTK_OUTPUT_RES", UI_MENU_OUTPUT_RES, vals, names, N, UI_MENU_OUTPUT_RES_DESC, -1, note);
|
||||
if (!missing || here || !romfs_shape_can_prepare()) return;
|
||||
if (!opt_button("##shape_prepare", UI_MENU_SHAPE_PREPARE, UI_MENU_SHAPE_PREPARE_DESC)) return;
|
||||
unsigned w = 0, h = 0;
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
|
||||
sscanf(now, "%ux%u", &w, &h);
|
||||
snprintf(asked, sizeof asked, "%s", now);
|
||||
started = romfs_shape_prepare(w, h, input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout))
|
||||
? 1 : -1;
|
||||
}
|
||||
|
||||
static void row_render_scale(void) {
|
||||
@@ -552,6 +583,13 @@ static void row_shadow_range(void) {
|
||||
opt_choice_list("TOTK_SHADOW_RANGE", UI_MENU_SHADOW_RANGE, vals, names, 4, UI_MENU_SHADOW_RANGE_DESC);
|
||||
}
|
||||
|
||||
static void row_grass_range(void) {
|
||||
static const char *const vals[] = {"50", "100", "150", "200", "300", "400"};
|
||||
static const char *const names[] = {"31 m (0.5x)", "62 m (1x)", "94 m (1.5x)",
|
||||
"125 m (2x)", "188 m (3x)", "250 m (4x)"};
|
||||
opt_choice_list("TOTK_GRASS_RANGE", UI_MENU_GRASS_RANGE, vals, names, 6, UI_MENU_GRASS_RANGE_DESC);
|
||||
}
|
||||
|
||||
static void row_gpu(void) {
|
||||
const char *vals[MAX_GPUS + 1], *names[MAX_GPUS + 1];
|
||||
char idx[MAX_GPUS][4];
|
||||
@@ -683,6 +721,8 @@ static void tab_screen(float scale) {
|
||||
opt_choice_list("TOTK_ANISO", UI_MENU_ANISO, aniso, aniso_names, 5, UI_MENU_ANISO_DESC);
|
||||
row_shadow_scale();
|
||||
row_shadow_range();
|
||||
row_grass_range();
|
||||
opt_toggle("TOTK_LOD_STEADY", UI_MENU_LOD_STEADY, UI_MENU_LOD_STEADY_DESC);
|
||||
opt_slider("TOTK_PCSS", UI_MENU_PCSS, 0, 200, UI_MENU_PCSS_DESC, 10, "%.0f %%");
|
||||
opt_slider("TOTK_CONTACT_SHADOWS", UI_MENU_CONTACT_SHADOWS, 0, 100, UI_MENU_CONTACT_SHADOWS_DESC, 10, "%.0f %%");
|
||||
opt_toggle("TOTK_DLAA", UI_MENU_DLAA, UI_MENU_DLAA_DESC);
|
||||
@@ -694,6 +734,8 @@ static void tab_screen(float scale) {
|
||||
static const UiTextId chars[] = {UI_MENU_DLSS_CHARS_OFF, UI_MENU_DLSS_CHARS_LIGHT, UI_MENU_DLSS_CHARS_MEDIUM,
|
||||
UI_MENU_DLSS_CHARS_FULL};
|
||||
opt_choice("TOTK_DLSS_CHAR_MASK", UI_MENU_DLSS_CHARS, chars, 4, UI_MENU_DLSS_CHARS_DESC);
|
||||
static const UiTextId reflex[] = {UI_MENU_REFLEX_OFF, UI_MENU_REFLEX_ON, UI_MENU_REFLEX_BOOST};
|
||||
opt_choice("TOTK_REFLEX", UI_MENU_REFLEX, reflex, 3, UI_MENU_REFLEX_DESC);
|
||||
opt_toggle("TOTK_FXAA", UI_MENU_FXAA, UI_MENU_FXAA_DESC);
|
||||
rows_color();
|
||||
opt_group(UI_MENU_HDR_GROUP);
|
||||
@@ -730,11 +772,42 @@ static void tab_game(float scale) {
|
||||
opt_end();
|
||||
}
|
||||
|
||||
// The output device row: System default (TOTK_AUDIO_DEVICE unset) and the playback devices SDL lists, by name. The list
|
||||
// is read again when the tab comes into view and once a second while it shows, so a device plugged in or out appears
|
||||
// without reopening the menu. A chosen device that is unplugged keeps its name as the value; the mixer plays on the
|
||||
// system default meanwhile (audio_mixer.c output_worker).
|
||||
enum { MAX_AUDIO_DEVICES = 16 };
|
||||
static char g_audio_names[MAX_AUDIO_DEVICES][AUDIO_DEVICE_NAME_MAX];
|
||||
static int g_audio_n;
|
||||
|
||||
static void row_audio_device(void) {
|
||||
static int last_frame = -2;
|
||||
static double next_list;
|
||||
int frame = ImGui::GetFrameCount();
|
||||
double now = ImGui::GetTime();
|
||||
if (frame != last_frame + 1 || now >= next_list) {
|
||||
g_audio_n = audio_output_devices(g_audio_names, MAX_AUDIO_DEVICES);
|
||||
next_list = now + 1.0;
|
||||
}
|
||||
last_frame = frame;
|
||||
const char *vals[MAX_AUDIO_DEVICES + 1], *names[MAX_AUDIO_DEVICES + 1];
|
||||
vals[0] = "";
|
||||
names[0] = menu_text(UI_MENU_AUDIO_DEVICE_DEFAULT);
|
||||
for (int i = 0; i < g_audio_n; i++) vals[i + 1] = names[i + 1] = g_audio_names[i];
|
||||
int cur = strcmp(cfg_value("TOTK_AUDIO_DEVICE"), "default") ? -1 : 0; // "default" in totk.ini is the first row
|
||||
opt_choice_list("TOTK_AUDIO_DEVICE", UI_MENU_AUDIO_DEVICE, vals, names, g_audio_n + 1, UI_MENU_AUDIO_DEVICE_DESC,
|
||||
cur);
|
||||
}
|
||||
|
||||
static void tab_sound(float scale) {
|
||||
opt_begin("##sound", scale);
|
||||
opt_slider("TOTK_VOLUME", UI_MENU_VOLUME, 0, 100, UI_MENU_VOLUME_DESC, 5, "%.0f %%");
|
||||
opt_slider("TOTK_VOLUME_MUSIC", UI_MENU_VOLUME_MUSIC, 0, 100, UI_MENU_VOLUME_MUSIC_DESC, 5, "%.0f %%");
|
||||
opt_slider("TOTK_VOLUME_SFX", UI_MENU_VOLUME_SFX, 0, 100, UI_MENU_VOLUME_SFX_DESC, 5, "%.0f %%");
|
||||
opt_slider("TOTK_VOLUME_VOICE", UI_MENU_VOLUME_VOICE, 0, 100, UI_MENU_VOLUME_VOICE_DESC, 5, "%.0f %%");
|
||||
static const UiTextId channels[] = {UI_MENU_CHANNELS_AUTO, UI_MENU_CHANNELS_STEREO, UI_MENU_CHANNELS_51};
|
||||
opt_choice("TOTK_AUDIO_CHANNELS", UI_MENU_AUDIO_CHANNELS, channels, 3, UI_MENU_AUDIO_CHANNELS_DESC);
|
||||
row_audio_device();
|
||||
opt_end();
|
||||
}
|
||||
|
||||
@@ -797,8 +870,9 @@ static const char *prompts_note(bool *restart) {
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT"), *used = romfs_prompts();
|
||||
const char *want = input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout);
|
||||
if (want == used || (want && used && !strcmp(want, used))) return nullptr;
|
||||
// A game resolution of another shape needs a folder of its own for the prompts (<folder>-<w>x<h>). The setup writes
|
||||
// one for each size the Screen tab offers; at any other size the shape is the reason, not the setup.
|
||||
// A game resolution of another shape needs a folder of its own for the prompts (<folder>-<w>x<h>, one per shape).
|
||||
// The setup writes it for the shapes of the displays it saw and the prompts totk.ini had then; at another shape
|
||||
// the shape is the reason (row_output_res offers to make it), not a damaged install.
|
||||
int off = romfs_prompts_off(want);
|
||||
if (want && !romfs_prompts_ready(want) && off != ROMFS_PROMPTS_SHAPE) return menu_text(UI_MENU_PROMPTS_MISSING);
|
||||
switch (off) {
|
||||
@@ -850,6 +924,32 @@ static void restart_confirm(void) {
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
static void rows_gameplay_tweaks(void) {
|
||||
opt_group(UI_MENU_GROUP_GAMEPLAY_TWEAKS);
|
||||
opt_toggle("TOTK_GAMEPLAY_TWEAKS_ENABLED", UI_MENU_GAMEPLAY_TWEAKS_ENABLED, UI_MENU_GAMEPLAY_TWEAKS_ENABLED_DESC);
|
||||
if (!cfg_bool("TOTK_GAMEPLAY_TWEAKS_ENABLED")) return;
|
||||
|
||||
opt_toggle("TOTK_GAMEPLAY_ULTRAHAND_ROTATE", UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE, UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE_DESC);
|
||||
opt_toggle("TOTK_GAMEPLAY_ULTRAHAND_C_AXIS", UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS, UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS_DESC);
|
||||
opt_slider("TOTK_GAMEPLAY_ROTATION_SENSITIVITY", UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY, 0.25f, 4.0f,
|
||||
UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY_DESC, 0.05f, "%.2fx");
|
||||
opt_toggle("TOTK_GAMEPLAY_ULTRAHAND_DISTANCE", UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE, UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE_DESC);
|
||||
opt_slider("TOTK_GAMEPLAY_DISTANCE_SENSITIVITY", UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY, 0.25f, 4.0f,
|
||||
UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY_DESC, 0.05f, "%.2fx");
|
||||
|
||||
opt_toggle("TOTK_GAMEPLAY_WEAPON_WHEEL", UI_MENU_GAMEPLAY_WEAPON_WHEEL, UI_MENU_GAMEPLAY_WEAPON_WHEEL_DESC);
|
||||
opt_slider("TOTK_GAMEPLAY_WEAPON_SENSITIVITY", UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY, 0.25f, 4.0f,
|
||||
UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY_DESC, 0.05f, "%.2fx");
|
||||
opt_toggle("TOTK_GAMEPLAY_ITEM_WHEEL", UI_MENU_GAMEPLAY_ITEM_WHEEL, UI_MENU_GAMEPLAY_ITEM_WHEEL_DESC);
|
||||
opt_slider("TOTK_GAMEPLAY_ITEM_SENSITIVITY", UI_MENU_GAMEPLAY_ITEM_SENSITIVITY, 0.25f, 4.0f,
|
||||
UI_MENU_GAMEPLAY_ITEM_SENSITIVITY_DESC, 0.05f, "%.2fx");
|
||||
opt_toggle("TOTK_GAMEPLAY_ITEM_AD", UI_MENU_GAMEPLAY_ITEM_AD, UI_MENU_GAMEPLAY_ITEM_AD_DESC);
|
||||
|
||||
opt_toggle("TOTK_GAMEPLAY_MAP_ZOOM", UI_MENU_GAMEPLAY_MAP_ZOOM, UI_MENU_GAMEPLAY_MAP_ZOOM_DESC);
|
||||
opt_slider("TOTK_GAMEPLAY_MAP_ZOOM_SENSITIVITY", UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY, 0.25f, 4.0f,
|
||||
UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY_DESC, 0.05f, "%.2fx");
|
||||
}
|
||||
|
||||
static void tab_controls(float scale) {
|
||||
opt_begin("##controls", scale);
|
||||
static const UiTextId layout[] = {UI_MENU_PAD_LAYOUT_AUTO, UI_MENU_PAD_LAYOUT_NINTENDO, UI_MENU_PAD_LAYOUT_XBOX};
|
||||
@@ -860,6 +960,24 @@ static void tab_controls(float scale) {
|
||||
opt_choice("TOTK_PROMPTS", UI_MENU_PROMPTS, prompts, 3, UI_MENU_PROMPTS_DESC, note);
|
||||
bool ask = restart && opt_button("##restart", UI_MENU_RESTART, UI_MENU_RESTART_DESC);
|
||||
opt_toggle("TOTK_MOTION", UI_MENU_MOTION, UI_MENU_MOTION_DESC);
|
||||
opt_toggle("TOTK_GYRO_CALIBRATION", UI_MENU_GYRO_CALIBRATION, UI_MENU_GYRO_CALIBRATION_DESC);
|
||||
if (input_gyro_calibration_enabled()) {
|
||||
// The row exists only while the switch is on: with the bias not applied there is nothing to calibrate and no
|
||||
// state to show.
|
||||
char pad[128] = "";
|
||||
int st = input_motion_calib_state(pad, sizeof pad);
|
||||
char status[192] = "";
|
||||
if (st == MOTION_CALIB_COLLECTING)
|
||||
snprintf(status, sizeof status, "%s", menu_text(UI_MENU_GYRO_CALIBRATE_WAIT));
|
||||
else if (st == MOTION_CALIB_DONE)
|
||||
snprintf(status, sizeof status, menu_text(UI_MENU_GYRO_CALIBRATED), pad);
|
||||
else if (st == MOTION_CALIB_FAILED)
|
||||
snprintf(status, sizeof status, "%s", menu_text(UI_MENU_GYRO_CALIBRATE_FAILED));
|
||||
else if (st == MOTION_CALIB_MOVED)
|
||||
snprintf(status, sizeof status, "%s", menu_text(UI_MENU_GYRO_CALIBRATE_MOVED));
|
||||
if (opt_button("##gyro_calib", UI_MENU_GYRO_CALIBRATE, UI_MENU_GYRO_CALIBRATE_DESC, status))
|
||||
input_motion_calibrate();
|
||||
}
|
||||
opt_slider("TOTK_RUMBLE_STRENGTH", UI_MENU_RUMBLE_STRENGTH, 0, 300, UI_MENU_RUMBLE_STRENGTH_DESC, 10, "%.0f %%");
|
||||
opt_slider("TOTK_RUMBLE_CURVE", UI_MENU_RUMBLE_CURVE, 0.2f, 1.5f, UI_MENU_RUMBLE_CURVE_DESC, 0.05f, "%.2f");
|
||||
opt_toggle("TOTK_RUMBLE_TRIGGERS", UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC);
|
||||
@@ -867,8 +985,12 @@ static void tab_controls(float scale) {
|
||||
opt_choice("TOTK_MOUSE_MODE", UI_MENU_MOUSE_MODE, mouse_modes, 2, UI_MENU_MOUSE_MODE_DESC);
|
||||
opt_slider("TOTK_MOUSE_SENS", UI_MENU_MOUSE_SENS, 0, 10, UI_MENU_MOUSE_SENS_DESC, 0.1f, "%.1f");
|
||||
opt_toggle("TOTK_MENU_CURSOR", UI_MENU_MENU_CURSOR, UI_MENU_MENU_CURSOR_DESC);
|
||||
opt_toggle("TOTK_MAP_CLICK", UI_MENU_MAP_CLICK, UI_MENU_MAP_CLICK_DESC);
|
||||
opt_toggle("TOTK_DIALOGUE_CLICK", UI_MENU_DIALOGUE_CLICK, UI_MENU_DIALOGUE_CLICK_DESC);
|
||||
opt_toggle("TOTK_POINTER_IMAGE", UI_MENU_POINTER_IMAGE, UI_MENU_POINTER_IMAGE_DESC);
|
||||
row_walk_key();
|
||||
opt_slider("TOTK_WALK_SCALE", UI_MENU_WALK_SCALE, 0.2f, 0.9f, UI_MENU_WALK_SCALE_DESC, 0.01f, "%.2f");
|
||||
rows_gameplay_tweaks();
|
||||
// Analog sticks: one dead zone row per stick, falling back to TOTK_STICK_DEADZONE (both sticks) while unset. With
|
||||
// a gamepad connected each row shows its stick's deflection now, before the dead zone: a drifting stick's resting
|
||||
// value, to set it above.
|
||||
@@ -950,9 +1072,10 @@ static bool validation_layer_present(void) {
|
||||
|
||||
// Every setting the menu shows back to its default (the environment's keys stay), written to totk.ini.
|
||||
static void reset_all(void) {
|
||||
const char *keys[128];
|
||||
const char *keys[256]; // above the number of rows in cfg.c metas (128 on 2026-11-11)
|
||||
int n = 0;
|
||||
for (const CfgMeta *m; n < 128 && (m = cfg_meta_at(n)); n++) keys[n] = m->key;
|
||||
for (const CfgMeta *m; n < 256 && (m = cfg_meta_at(n)); n++) keys[n] = m->key;
|
||||
if (cfg_meta_at(n)) rt_log("menu: reset covers the first %d settings only; raise keys[] in reset_all", n);
|
||||
int done = cfg_reset(keys, n);
|
||||
opt_save_soon();
|
||||
rt_log("menu: reset %d settings to their defaults", done);
|
||||
|
||||
+288
-11
@@ -86,7 +86,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
"bars, or stretch them over the whole picture. Applies from the next movie.",
|
||||
[UI_MENU_MOVIE_ASPECT_KEEP] = "Black bars", [UI_MENU_MOVIE_ASPECT_STRETCH] = "Stretch",
|
||||
[UI_MENU_FOV] = "Field of view",
|
||||
[UI_MENU_FOV_DESC] = "How much of the world the camera shows, in percent of the game's own. Game version 1.4.3 only.",
|
||||
[UI_MENU_FOV_DESC] = "How much of the world the camera shows, in percent of the game's own. Game versions 1.1.0 and 1.4.3.",
|
||||
[UI_MENU_SHADOW_RES] = "Shadow map size",
|
||||
[UI_MENU_SHADOW_RES_DESC] = "Size of the sun's shadow map. The game's own size changes with the view, down to about 400 "
|
||||
"near the ground, so leaf shadows look blocky and jump; a fixed size keeps them still and "
|
||||
@@ -96,6 +96,8 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_ANISO] = "Texture filtering",
|
||||
[UI_MENU_ANISO_DESC] = "Anisotropic filtering of surface textures: ground, roads and walls seen at a shallow angle stay sharp into the distance instead of blurring. Game: the level the game asks for, as on the Switch.",
|
||||
[UI_MENU_ANISO_GAME] = "Game",
|
||||
[UI_MENU_LOD_STEADY] = "Steady detail under load",
|
||||
[UI_MENU_LOD_STEADY_DESC] = "Skips the game's setup for lowering model and texture detail when the frame rate drops, as the emulator mod Disable LOD Quality Reduction does. Game versions 1.2.1 and 1.4.3. Leave it off on weak PCs: there this drop keeps the frame rate up.",
|
||||
[UI_MENU_SHARPNESS] = "FSR sharpness",
|
||||
[UI_MENU_SHARPNESS_DESC] = "Sharpening after FSR scaling; 0 turns it off.",
|
||||
[UI_MENU_COLOR] = "Colour",
|
||||
@@ -141,6 +143,10 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SHADOW_RANGE_DESC] = "Moves the steps where shadows turn softer (the game's 20, 40, 80 and 160 m) further "
|
||||
"away. Spreads the shadow map over more ground: raise Shadow resolution with it. "
|
||||
"Takes effect at the next start.",
|
||||
[UI_MENU_GRASS_RANGE] = "Grass range",
|
||||
[UI_MENU_GRASS_RANGE_DESC] = "How far around the camera grass grows (the game's: 62.5 m). Higher keeps the "
|
||||
"grass in meadows further out instead of growing it in just in front of you; lower "
|
||||
"draws less of it. Takes effect at the next start.",
|
||||
[UI_MENU_DLAA] = "NVIDIA DLSS / DLAA",
|
||||
[UI_MENU_DLAA_DESC] = "NVIDIA DLSS for the 3D scene (NVIDIA RTX GPUs; " DLSS_FILE " next to " EXE_FILE "): smoother "
|
||||
"edges and less shimmer. The HUD is not touched. The mode below sets the resolution it works "
|
||||
@@ -166,6 +172,11 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DLSS_PERFORMANCE] = "Performance", [UI_MENU_DLSS_ULTRA] = "Ultra Performance",
|
||||
[UI_MENU_FXAA] = "Game anti-aliasing (FXAA)",
|
||||
[UI_MENU_FXAA_DESC] = "The game's own FXAA edge smoothing. It blurs fine detail a little; with DLAA on it is not needed.",
|
||||
[UI_MENU_REFLEX] = "NVIDIA Reflex Low Latency",
|
||||
[UI_MENU_REFLEX_DESC] = "Reduces system latency on NVIDIA GPUs using VK_NV_low_latency2. On + Boost keeps GPU clocks high in CPU-bound scenes.",
|
||||
[UI_MENU_REFLEX_OFF] = "Off",
|
||||
[UI_MENU_REFLEX_ON] = "On",
|
||||
[UI_MENU_REFLEX_BOOST] = "On + Boost",
|
||||
|
||||
[UI_MENU_FPS_LIMIT] = "Frame rate limit",
|
||||
[UI_MENU_FPS_LIMIT_DESC] = "The most frames per second the game draws. Above 60 is experimental and needs Game speed "
|
||||
@@ -218,8 +229,9 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODS_CHEATS] = "Cheats: %d. Switch them on the Cheats tab.",
|
||||
[UI_MENU_MODS_CHEATS_FILE] = "Cheats for this game version are read at start from cheats\\%s in this mod.",
|
||||
[UI_MENU_MODS_BAD_NAME] = "The folder name contains |, which the mod list uses between names. Rename the folder.",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "%u of its files are made for another game version and are left out. Look for a "
|
||||
"version of this mod made for your game version.",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "%u of its files carry another game version in their names. The game reads them only "
|
||||
"where something asks for those names. If the mod does nothing, look for a version "
|
||||
"of it made for your game version.",
|
||||
[UI_MENU_MODS_UNUSED] = "not used",
|
||||
[UI_MENU_MODS_FPS60] = "60 FPS patch",
|
||||
[UI_MENU_MODS_FPS60_DESC] = "The port's own patch for 60 frames per second. Set it with Frame rate limit on the "
|
||||
@@ -232,12 +244,30 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
"at 60 FPS.",
|
||||
|
||||
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Master volume of the game.",
|
||||
[UI_MENU_VOLUME_MUSIC] = "Music volume", [UI_MENU_VOLUME_MUSIC_DESC] = "Volume of background music.",
|
||||
[UI_MENU_VOLUME_SFX] = "SFX volume", [UI_MENU_VOLUME_SFX_DESC] = "Volume of sound effects.",
|
||||
[UI_MENU_VOLUME_VOICE] = "Voice volume", [UI_MENU_VOLUME_VOICE_DESC] = "Volume of character voices.",
|
||||
[UI_MENU_AUDIO_CHANNELS] = "Speakers",
|
||||
[UI_MENU_AUDIO_CHANNELS_DESC] = "Stereo or 5.1 surround output. Automatic picks 5.1 when the Windows speaker setup "
|
||||
"has six or more channels. Applies after a restart.",
|
||||
[UI_MENU_CHANNELS_AUTO] = "Automatic", [UI_MENU_CHANNELS_STEREO] = "Stereo", [UI_MENU_CHANNELS_51] = "5.1 surround",
|
||||
[UI_MENU_AUDIO_DEVICE] = "Output device",
|
||||
[UI_MENU_AUDIO_DEVICE_DESC] = "Where the sound plays. System default follows the Windows default device. A chosen "
|
||||
"device that is unplugged falls back to the system default until it is back. "
|
||||
"Applies at once.",
|
||||
[UI_MENU_AUDIO_DEVICE_DEFAULT] = "System default",
|
||||
|
||||
[UI_MENU_MOTION] = "Motion controls", [UI_MENU_MOTION_DESC] = "Aiming with the controller's gyroscope.",
|
||||
[UI_MENU_GYRO_CALIBRATION] = "Gyro bias calibration",
|
||||
[UI_MENU_GYRO_CALIBRATION_DESC] = "Subtracts the controller's resting drift, measured with the calibrate row "
|
||||
"below. The measured values stay saved when this is off.",
|
||||
[UI_MENU_GYRO_CALIBRATE] = "Calibrate gyro",
|
||||
[UI_MENU_GYRO_CALIBRATE_DESC] = "Measures the gyroscope's resting drift and removes it. Put the controller down or "
|
||||
"hold it still for two seconds.",
|
||||
[UI_MENU_GYRO_CALIBRATE_WAIT] = "Calibrating...",
|
||||
[UI_MENU_GYRO_CALIBRATED] = "%s, calibrated",
|
||||
[UI_MENU_GYRO_CALIBRATE_FAILED] = "Calibration failed",
|
||||
[UI_MENU_GYRO_CALIBRATE_MOVED] = "Controller moved: hold it still and try again",
|
||||
[UI_MENU_RUMBLE_STRENGTH] = "Vibration strength",
|
||||
[UI_MENU_RUMBLE_STRENGTH_DESC] = "How strong the controller vibrates.",
|
||||
[UI_MENU_RUMBLE_CURVE] = "Vibration curve",
|
||||
@@ -265,6 +295,11 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_PROMPTS_FAILED] = "prompt files damaged: run the setup again",
|
||||
[UI_MENU_PROMPTS_RESTART] = "prompts change after restart",
|
||||
[UI_MENU_PROMPTS_OFF_SHAPE] = "off at this game resolution (no layout made for it)",
|
||||
[UI_MENU_OUTPUT_RES_NO_LAYOUT] = "no layout made for this shape: run the setup again",
|
||||
[UI_MENU_OUTPUT_RES_PREPARING] = "layout being made in the background; used at the next start",
|
||||
[UI_MENU_SHAPE_PREPARE] = "Prepare the layout for this screen",
|
||||
[UI_MENU_SHAPE_PREPARE_DESC] = "Makes the interface layout and the chosen button prompts for this game resolution's shape in the background, with the setup's tools, as the setup does for the displays it saw. The game keeps running; it uses them from its next start.",
|
||||
[UI_MENU_SHAPE_PREPARE_FAILED] = "the setup's tools did not start: run the setup again",
|
||||
[UI_MENU_PROMPTS_OFF_MODS] = "off: a RomFS mod replaces their files",
|
||||
[UI_MENU_PROMPTS_OFF_PATCHES] = "off while TOTK_ROMFS_PATCHES is set",
|
||||
[UI_MENU_RESTART] = "Restart now",
|
||||
@@ -283,6 +318,12 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MOUSE_DIRECT] = "Direct",
|
||||
[UI_MENU_MENU_CURSOR] = "Mouse in the game's menus",
|
||||
[UI_MENU_MENU_CURSOR_DESC] = "In the game's own menus (title, inventory, shops, dialogue choices) the pointer shows: the item under it is selected, left click confirms, right click goes back. Only after the mouse or a key was used last, so a gamepad sees the menus unchanged (game 1.4.3).",
|
||||
[UI_MENU_MAP_CLICK] = "Left click on the map",
|
||||
[UI_MENU_MAP_CLICK_DESC] = "On the Purah Pad's map, the left mouse button presses A at the map's cursor instead of the button it is bound to (Y by default). Needs Mouse in the game's menus (game 1.4.3).",
|
||||
[UI_MENU_DIALOGUE_CLICK] = "Clicks in dialogue",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "While a dialogue box is open, left click presses B (it continues the text and skips its scroll) and right click presses A, instead of the buttons they are bound to (Y by default, which opens the dialogue log, and ZL). Dialogue choices keep the pointer: left click picks (game 1.4.3).",
|
||||
[UI_MENU_POINTER_IMAGE] = "Game pointer",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "While the cursor is not captured (the game's menus, this menu, after Esc), the window shows a gold arrowhead of its own instead of the system arrow, sized for the screen's scale.",
|
||||
[UI_MENU_MOUSE_SENS] = "Mouse camera sensitivity",
|
||||
[UI_MENU_MOUSE_SENS_DESC] = "How fast the mouse turns the camera.",
|
||||
[UI_MENU_WALK_KEY] = "Walk key",
|
||||
@@ -292,6 +333,33 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_WALK_SCALE] = "Walk scale",
|
||||
[UI_MENU_WALK_SCALE_DESC] = "The tilt the keyboard's sticks get while the walk key is held. Half is a walk, the "
|
||||
"full tilt a run.",
|
||||
[UI_MENU_GROUP_GAMEPLAY_TWEAKS] = "Gameplay tweaks",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED] = "Gameplay tweaks",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED_DESC] = "Mouse wheel controls for Ultrahand rotation and distance, item and weapon switching, and smooth map zoom.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE] = "Ultrahand wheel rotation",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE_DESC] = "Turn objects held by Ultrahand directly with the mouse wheel.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS] = "Ultrahand C rotation axis",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS_DESC] = "Hold C while scrolling to turn held objects around the alternate axis.",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY] = "Ultrahand rotation sensitivity",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY_DESC] = "How fast the mouse wheel turns held objects.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE] = "Ultrahand wheel distance",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE_DESC] = "Right-click + mouse wheel pushes or pulls held objects.",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY] = "Ultrahand distance sensitivity",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY_DESC] = "How fast the mouse wheel changes object distance.",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL] = "Weapon wheel selection",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL_DESC] = "Scroll mouse wheel in free roam to switch weapons. Confirm with E.",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY] = "Weapon wheel sensitivity",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY_DESC] = "Scroll steps needed to advance to the next weapon.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL] = "Quick menu wheel selection",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL_DESC] = "Scroll mouse wheel to browse items while a quick-selection menu is open.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY] = "Quick menu wheel sensitivity",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY_DESC] = "Scroll steps needed to advance through items in quick-selection menus.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD] = "Quick menu A / D navigation",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD_DESC] = "Press A / D to navigate left and right in quick-selection menus.",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM] = "Smooth map zoom",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_DESC] = "Smooth inertial zoom on the Purah Pad map using the mouse wheel.",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY] = "Map zoom sensitivity",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY_DESC] = "How fast the mouse wheel zooms the map.",
|
||||
[UI_MENU_STICK_SENS] = "Stick camera speed",
|
||||
[UI_MENU_STICK_SENS_DESC] = "Multiplies the game's own right-stick camera speed, top speed included, at each of the "
|
||||
"game's five camera sensitivities. The mouse keeps its own setting.",
|
||||
@@ -343,6 +411,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_DPAD_DOWN] = "D-pad down", [UI_PAD_ZL] = "Left trigger", [UI_PAD_ZR] = "Right trigger",
|
||||
[UI_PAD_LPADDLE1] = "Left back button", [UI_PAD_RPADDLE1] = "Right back button",
|
||||
[UI_PAD_LPADDLE2] = "Left back button 2", [UI_PAD_RPADDLE2] = "Right back button 2",
|
||||
[UI_PAD_TOUCHPAD] = "Touchpad click",
|
||||
[UI_PAD_CROSS] = "Cross", [UI_PAD_CIRCLE] = "Circle", [UI_PAD_SQUARE] = "Square", [UI_PAD_TRIANGLE] = "Triangle",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "Amiibo folder",
|
||||
@@ -568,7 +637,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
"растянуть их на всю картинку. Действует со следующего ролика.",
|
||||
[UI_MENU_MOVIE_ASPECT_KEEP] = "Чёрные полосы", [UI_MENU_MOVIE_ASPECT_STRETCH] = "Растянуть",
|
||||
[UI_MENU_FOV] = "Поле зрения",
|
||||
[UI_MENU_FOV_DESC] = "Сколько мира показывает камера, в процентах от игрового. Только для версии игры 1.4.3.",
|
||||
[UI_MENU_FOV_DESC] = "Сколько мира показывает камера, в процентах от игрового. Для версий игры 1.1.0 и 1.4.3.",
|
||||
[UI_MENU_SHADOW_RES] = "Размер карты теней",
|
||||
[UI_MENU_SHADOW_RES_DESC] = "Размер карты теней от солнца. Собственный размер игры меняется вместе с видом, у земли до "
|
||||
"примерно 400, поэтому тени листвы выглядят квадратными и дёргаются; постоянный размер делает "
|
||||
@@ -578,6 +647,8 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_ANISO] = "Фильтрация текстур",
|
||||
[UI_MENU_ANISO_DESC] = "Анизотропная фильтрация текстур поверхностей: земля, дороги и стены под острым углом остаются чёткими вдали, а не размываются. Игра: уровень, который запрашивает игра, как на Switch.",
|
||||
[UI_MENU_ANISO_GAME] = "Игра",
|
||||
[UI_MENU_LOD_STEADY] = "Стабильная детализация под нагрузкой",
|
||||
[UI_MENU_LOD_STEADY_DESC] = "Пропускает настройку игры, снижающую детализацию моделей и текстур при падении частоты кадров, как эмуляторный мод Disable LOD Quality Reduction. Только для версий игры 1.2.1 и 1.4.3. На слабых ПК не включайте: там это снижение и держит частоту кадров.",
|
||||
[UI_MENU_SHARPNESS] = "Резкость FSR",
|
||||
[UI_MENU_SHARPNESS_DESC] = "Повышение резкости после масштабирования FSR; 0 выключает его.",
|
||||
[UI_MENU_COLOR] = "Цвет",
|
||||
@@ -624,6 +695,10 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SHADOW_RANGE_DESC] = "Отодвигает границы, за которыми тени становятся мягче (в игре 20, 40, 80 и 160 м). "
|
||||
"Карта теней растягивается на большую площадь, поэтому вместе с этим поднимайте "
|
||||
"разрешение теней. Действует после перезапуска.",
|
||||
[UI_MENU_GRASS_RANGE] = "Дальность травы",
|
||||
[UI_MENU_GRASS_RANGE_DESC] = "Как далеко вокруг камеры растёт трава (в игре 62,5 м). Выше: трава на лугах видна "
|
||||
"дальше и не вырастает прямо перед вами; ниже: травы меньше. Действует после "
|
||||
"перезапуска.",
|
||||
[UI_MENU_DLAA] = "NVIDIA DLSS / DLAA",
|
||||
[UI_MENU_DLAA_DESC] = "NVIDIA DLSS для 3D-сцены (видеокарты NVIDIA RTX; " DLSS_FILE " рядом с " EXE_FILE "): ровнее "
|
||||
"края и меньше мерцания. Интерфейс не затрагивается. Режим ниже задаёт разрешение, с которым он "
|
||||
@@ -649,6 +724,11 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DLSS_PERFORMANCE] = "Производительность", [UI_MENU_DLSS_ULTRA] = "Макс. производительность",
|
||||
[UI_MENU_FXAA] = "Сглаживание игры (FXAA)",
|
||||
[UI_MENU_FXAA_DESC] = "Собственное сглаживание FXAA. Слегка размывает мелкие детали; с DLAA оно не нужно.",
|
||||
[UI_MENU_REFLEX] = "NVIDIA Reflex Low Latency",
|
||||
[UI_MENU_REFLEX_DESC] = "Снижает задержку системы на видеокартах NVIDIA с помощью VK_NV_low_latency2. «Вкл + Ускорение» удерживает высокие частоты GPU при упоре в процессор.",
|
||||
[UI_MENU_REFLEX_OFF] = "Выкл",
|
||||
[UI_MENU_REFLEX_ON] = "Вкл",
|
||||
[UI_MENU_REFLEX_BOOST] = "Вкл + Ускорение",
|
||||
|
||||
[UI_MENU_FPS_LIMIT] = "Ограничение частоты кадров",
|
||||
[UI_MENU_FPS_LIMIT_DESC] = "Наибольшее число кадров в секунду. Выше 60 — экспериментальный режим, нужна «Скорость "
|
||||
@@ -699,8 +779,9 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODS_CHEATS] = "Читов: %d. Они включаются на вкладке «Читы».",
|
||||
[UI_MENU_MODS_CHEATS_FILE] = "Читы для этой версии игры читаются при запуске из cheats\\%s в этом моде.",
|
||||
[UI_MENU_MODS_BAD_NAME] = "В имени папки есть символ |, которым список модов разделяет имена. Переименуйте папку.",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "Файлов для другой версии игры: %u, они пропущены. Поищите версию этого мода для "
|
||||
"вашей версии игры.",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "Файлов с другой версией игры в имени: %u. Игра читает их, только когда что-то "
|
||||
"запрашивает эти имена. Если мод не работает, поищите его версию для вашей версии "
|
||||
"игры.",
|
||||
[UI_MENU_MODS_UNUSED] = "не используется",
|
||||
[UI_MENU_MODS_FPS60] = "Патч 60 FPS",
|
||||
[UI_MENU_MODS_FPS60_DESC] = "Собственный патч порта для 60 кадров в секунду. Настраивается «Ограничением частоты "
|
||||
@@ -712,12 +793,30 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODS_QUICKMENU_DESC] = "Исправление порта: чёрный фон меню оружия, щитов и материалов при 60 FPS.",
|
||||
|
||||
[UI_MENU_VOLUME] = "Громкость", [UI_MENU_VOLUME_DESC] = "Общая громкость игры.",
|
||||
[UI_MENU_VOLUME_MUSIC] = "Громкость музыки", [UI_MENU_VOLUME_MUSIC_DESC] = "Громкость фоновой музыки.",
|
||||
[UI_MENU_VOLUME_SFX] = "Громкость эффектов", [UI_MENU_VOLUME_SFX_DESC] = "Громкость звуковых эффектов.",
|
||||
[UI_MENU_VOLUME_VOICE] = "Громкость голосов", [UI_MENU_VOLUME_VOICE_DESC] = "Громкость голосов персонажей.",
|
||||
[UI_MENU_AUDIO_CHANNELS] = "Динамики",
|
||||
[UI_MENU_AUDIO_CHANNELS_DESC] = "Стерео или объёмный звук 5.1. Автоматически выбирается 5.1, если в Windows "
|
||||
"настроено шесть каналов или больше. Применяется после перезапуска.",
|
||||
[UI_MENU_CHANNELS_AUTO] = "Автоматически", [UI_MENU_CHANNELS_STEREO] = "Стерео", [UI_MENU_CHANNELS_51] = "Объёмный 5.1",
|
||||
[UI_MENU_AUDIO_DEVICE] = "Устройство вывода",
|
||||
[UI_MENU_AUDIO_DEVICE_DESC] = "Куда выводится звук. Системное по умолчанию следует за устройством по умолчанию "
|
||||
"в Windows. Если выбранное устройство отключить, звук идёт на системное, пока оно "
|
||||
"не вернётся. Применяется сразу.",
|
||||
[UI_MENU_AUDIO_DEVICE_DEFAULT] = "Системное по умолчанию",
|
||||
|
||||
[UI_MENU_MOTION] = "Управление движением", [UI_MENU_MOTION_DESC] = "Прицеливание гироскопом контроллера.",
|
||||
[UI_MENU_GYRO_CALIBRATION] = "Калибровка смещения гироскопа",
|
||||
[UI_MENU_GYRO_CALIBRATION_DESC] = "Убирает покоящееся смещение контроллера, измеренное строкой калибровки ниже. "
|
||||
"Измеренные значения сохраняются и при выключенном состоянии.",
|
||||
[UI_MENU_GYRO_CALIBRATE] = "Калибровка гироскопа",
|
||||
[UI_MENU_GYRO_CALIBRATE_DESC] = "Измеряет смещение гироскопа в покое и убирает его. Положите контроллер или "
|
||||
"держите его неподвижно две секунды.",
|
||||
[UI_MENU_GYRO_CALIBRATE_WAIT] = "Калибровка...",
|
||||
[UI_MENU_GYRO_CALIBRATED] = "%s, откалиброван",
|
||||
[UI_MENU_GYRO_CALIBRATE_FAILED] = "Калибровка не удалась",
|
||||
[UI_MENU_GYRO_CALIBRATE_MOVED] = "Контроллер сдвинулся: держите его неподвижно и повторите",
|
||||
[UI_MENU_RUMBLE_STRENGTH] = "Сила вибрации",
|
||||
[UI_MENU_RUMBLE_STRENGTH_DESC] = "Насколько сильно вибрирует контроллер.",
|
||||
[UI_MENU_RUMBLE_CURVE] = "Кривая вибрации",
|
||||
@@ -745,6 +844,11 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_PROMPTS_FAILED] = "файлы подсказок повреждены: запустите установку снова",
|
||||
[UI_MENU_PROMPTS_RESTART] = "подсказки сменятся после перезапуска",
|
||||
[UI_MENU_PROMPTS_OFF_SHAPE] = "выкл. при этом разрешении игры (для него нет раскладки)",
|
||||
[UI_MENU_OUTPUT_RES_NO_LAYOUT] = "для этой формы нет раскладки: запустите установщик снова",
|
||||
[UI_MENU_OUTPUT_RES_PREPARING] = "раскладка создаётся в фоне; будет при следующем запуске",
|
||||
[UI_MENU_SHAPE_PREPARE] = "Подготовить раскладку для этого экрана",
|
||||
[UI_MENU_SHAPE_PREPARE_DESC] = "Создаёт в фоне раскладку интерфейса и выбранные подсказки кнопок для формы этого разрешения игры инструментами установщика, как установщик делает для мониторов, которые видел. Игра продолжает работать; раскладка будет со следующего запуска.",
|
||||
[UI_MENU_SHAPE_PREPARE_FAILED] = "инструменты установщика не запустились: запустите установщик снова",
|
||||
[UI_MENU_PROMPTS_OFF_MODS] = "выкл.: мод RomFS заменяет их файлы",
|
||||
[UI_MENU_PROMPTS_OFF_PATCHES] = "выкл., пока задан TOTK_ROMFS_PATCHES",
|
||||
[UI_MENU_RESTART] = "Перезапустить сейчас",
|
||||
@@ -763,6 +867,12 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MOUSE_DIRECT] = "Прямое",
|
||||
[UI_MENU_MENU_CURSOR] = "Мышь в меню игры",
|
||||
[UI_MENU_MENU_CURSOR_DESC] = "В меню самой игры (заставка, инвентарь, магазины, варианты ответа) появляется указатель: пункт под ним выбирается, левый щелчок подтверждает, правый возвращает назад. Только если последними использовались мышь или клавиатура, поэтому с геймпадом меню не меняются (версия игры 1.4.3).",
|
||||
[UI_MENU_MAP_CLICK] = "Левый щелчок на карте",
|
||||
[UI_MENU_MAP_CLICK_DESC] = "На карте игры левая кнопка мыши нажимает A у курсора карты, а не назначенную ей кнопку (по умолчанию Y). Нужна «Мышь в меню игры» (версия игры 1.4.3).",
|
||||
[UI_MENU_DIALOGUE_CLICK] = "Щелчки в диалоге",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "Пока открыто окно диалога, левый щелчок нажимает B (продолжает текст и пропускает его прокрутку), а правый — A, вместо назначенных им кнопок (по умолчанию Y, она открывает журнал диалога, и ZL). В вариантах ответа по-прежнему работает указатель: левый щелчок выбирает (версия игры 1.4.3).",
|
||||
[UI_MENU_POINTER_IMAGE] = "Игровой курсор",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "Пока курсор не захвачен (меню игры, это меню, после Esc), окно показывает собственный золотой наконечник вместо системной стрелки, по масштабу экрана.",
|
||||
[UI_MENU_MOUSE_SENS] = "Чувствительность мыши",
|
||||
[UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.",
|
||||
[UI_MENU_WALK_KEY] = "Клавиша шага",
|
||||
@@ -772,6 +882,33 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_WALK_SCALE] = "Сила шага",
|
||||
[UI_MENU_WALK_SCALE_DESC] = "Отклонение стиков клавиатуры при удержании клавиши шага. Половина — шаг, полное "
|
||||
"отклонение — бег.",
|
||||
[UI_MENU_GROUP_GAMEPLAY_TWEAKS] = "Геймплей",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED] = "Настройки геймплея",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED_DESC] = "Управление колесом мыши: вращение и дистанция предметов в Ультраруке, выбор оружия и предметов, плавный зум карты.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE] = "Вращение колесом (Ультрарука)",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE_DESC] = "Вращение удерживаемых Ультрарукой предметов колесом мыши без удержания R.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS] = "Ось C для вращения (Ультрарука)",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS_DESC] = "Удерживайте C при прокрутке колеса для вращения объекта вокруг третьей оси.",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY] = "Скорость вращения (Ультрарука)",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY_DESC] = "Как быстро колесо мыши поворачивает удерживаемый предмет.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE] = "Дистанция колесом (Ультрарука)",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE_DESC] = "Правая кнопка мыши + колесо приближает или отдаляет предмет.",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY] = "Скорость дистанции (Ультрарука)",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY_DESC] = "Как быстро колесо мыши меняет дистанцию до предмета.",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL] = "Выбор оружия колесом",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL_DESC] = "Прокрутите колесо в свободной игре для выбора оружия. Подтверждение клавишей E.",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY] = "Чувствительность выбора оружия",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY_DESC] = "Шаги колеса для переключения на следующее оружие.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL] = "Выбор в быстром меню колесом",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL_DESC] = "Прокрутка колеса листает предметы в открытом меню быстрого выбора.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY] = "Чувствительность быстрого меню",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY_DESC] = "Шаги колеса для перехода к следующему предмету в быстром меню.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD] = "Навигация A / D в быстром меню",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD_DESC] = "Клавиши A / D для выбора влево и вправо в меню быстрого выбора.",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM] = "Плавный зум карты",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_DESC] = "Плавное инерционное приближение карты Планшета путеводителя колесом мыши.",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY] = "Скорость зума карты",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY_DESC] = "Как быстро колесо мыши масштабирует карту.",
|
||||
[UI_MENU_STICK_SENS] = "Скорость камеры (стик)",
|
||||
[UI_MENU_STICK_SENS_DESC] = "Умножает скорость поворота камеры правым стиком, включая наибольшую, при каждой из пяти "
|
||||
"чувствительностей камеры в игре. На мышь не влияет.",
|
||||
@@ -827,6 +964,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_ZR] = "Правый курок",
|
||||
[UI_PAD_LPADDLE1] = "Левая задняя кнопка", [UI_PAD_RPADDLE1] = "Правая задняя кнопка",
|
||||
[UI_PAD_LPADDLE2] = "Левая задняя кнопка 2", [UI_PAD_RPADDLE2] = "Правая задняя кнопка 2",
|
||||
[UI_PAD_TOUCHPAD] = "Нажатие на тачпад",
|
||||
[UI_PAD_CROSS] = "Крест", [UI_PAD_CIRCLE] = "Круг", [UI_PAD_SQUARE] = "Квадрат", [UI_PAD_TRIANGLE] = "Треугольник",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "Папка amiibo",
|
||||
@@ -1029,8 +1167,9 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODS_CHEATS] = "Cheats: %d. Ligue-os na aba Cheats.",
|
||||
[UI_MENU_MODS_CHEATS_FILE] = "Os cheats desta versão do jogo são lidos ao iniciar de cheats\\%s neste mod.",
|
||||
[UI_MENU_MODS_BAD_NAME] = "O nome da pasta contém |, que a lista de mods usa entre os nomes. Renomeie a pasta.",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "%u dos seus arquivos são de outra versão do jogo e ficam de fora. Procure uma versão "
|
||||
"deste mod feita para a sua versão do jogo.",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "%u dos seus arquivos trazem outra versão do jogo no nome. O jogo só os lê quando algo "
|
||||
"pede esses nomes. Se o mod não fizer nada, procure uma versão dele feita para a sua "
|
||||
"versão do jogo.",
|
||||
[UI_MENU_MODS_UNUSED] = "não usado",
|
||||
[UI_MENU_MODS_FPS60] = "Patch de 60 FPS",
|
||||
[UI_MENU_MODS_FPS60_DESC] = "O patch do próprio port para 60 quadros por segundo. Ajuste em Limite de quadros na aba "
|
||||
@@ -1120,12 +1259,30 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODE_DOCKED] = "Modo TV", [UI_MENU_MODE_HANDHELD] = "Modo portátil",
|
||||
|
||||
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Volume geral do jogo.",
|
||||
[UI_MENU_VOLUME_MUSIC] = "Volume da música", [UI_MENU_VOLUME_MUSIC_DESC] = "Volume da música de fundo.",
|
||||
[UI_MENU_VOLUME_SFX] = "Volume dos efeitos", [UI_MENU_VOLUME_SFX_DESC] = "Volume dos efeitos sonoros.",
|
||||
[UI_MENU_VOLUME_VOICE] = "Volume das vozes", [UI_MENU_VOLUME_VOICE_DESC] = "Volume das vozes dos personagens.",
|
||||
[UI_MENU_AUDIO_CHANNELS] = "Alto-falantes",
|
||||
[UI_MENU_AUDIO_CHANNELS_DESC] = "Saída estéreo ou surround 5.1. Automático escolhe 5.1 quando a configuração de "
|
||||
"alto-falantes do Windows tem seis canais ou mais. Vale após reiniciar.",
|
||||
[UI_MENU_CHANNELS_AUTO] = "Automático", [UI_MENU_CHANNELS_STEREO] = "Estéreo", [UI_MENU_CHANNELS_51] = "Surround 5.1",
|
||||
[UI_MENU_AUDIO_DEVICE] = "Dispositivo de saída",
|
||||
[UI_MENU_AUDIO_DEVICE_DESC] = "Onde o som toca. Padrão do sistema segue o dispositivo padrão do Windows. Um "
|
||||
"dispositivo escolhido que for desconectado volta ao padrão do sistema até "
|
||||
"reaparecer. Vale na hora.",
|
||||
[UI_MENU_AUDIO_DEVICE_DEFAULT] = "Padrão do sistema",
|
||||
|
||||
[UI_MENU_MOTION] = "Controles de movimento", [UI_MENU_MOTION_DESC] = "Mirar com o giroscópio do controle.",
|
||||
[UI_MENU_GYRO_CALIBRATION] = "Calibração do desvio do giroscópio",
|
||||
[UI_MENU_GYRO_CALIBRATION_DESC] = "Remove o desvio de repouso do controle, medido pela linha de calibração "
|
||||
"abaixo. Os valores medidos ficam salvos mesmo com isto desligado.",
|
||||
[UI_MENU_GYRO_CALIBRATE] = "Calibrar giroscópio",
|
||||
[UI_MENU_GYRO_CALIBRATE_DESC] = "Mede o desvio de repouso do giroscópio e o remove. Apoie o controle ou "
|
||||
"segure-o parado por dois segundos.",
|
||||
[UI_MENU_GYRO_CALIBRATE_WAIT] = "Calibrando...",
|
||||
[UI_MENU_GYRO_CALIBRATED] = "%s, calibrado",
|
||||
[UI_MENU_GYRO_CALIBRATE_FAILED] = "Falha na calibração",
|
||||
[UI_MENU_GYRO_CALIBRATE_MOVED] = "O controle se moveu: segure-o parado e tente de novo",
|
||||
[UI_MENU_RUMBLE_STRENGTH] = "Intensidade da vibração",
|
||||
[UI_MENU_RUMBLE_STRENGTH_DESC] = "Quão forte o controle vibra.",
|
||||
[UI_MENU_RUMBLE_CURVE] = "Curva da vibração",
|
||||
@@ -1206,6 +1363,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_ZL] = "Gatilho esquerdo", [UI_PAD_ZR] = "Gatilho direito",
|
||||
[UI_PAD_LPADDLE1] = "Botão traseiro esquerdo", [UI_PAD_RPADDLE1] = "Botão traseiro direito",
|
||||
[UI_PAD_LPADDLE2] = "Botão traseiro esquerdo 2", [UI_PAD_RPADDLE2] = "Botão traseiro direito 2",
|
||||
[UI_PAD_TOUCHPAD] = "Clique do touchpad",
|
||||
[UI_PAD_CROSS] = "Cruz", [UI_PAD_CIRCLE] = "Círculo", [UI_PAD_SQUARE] = "Quadrado", [UI_PAD_TRIANGLE] = "Triângulo",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "Pasta de amiibo",
|
||||
@@ -1352,7 +1510,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_OV_FMT_FSR] = "AMD FSR 1, nitidez %d%%", [UI_MENU_OV_SCALE_NONE] = "nenhuma (1:1)",
|
||||
[UI_MENU_OV_SCALE_BILINEAR] = "bilinear",
|
||||
[UI_MENU_FOV] = "Campo de visão",
|
||||
[UI_MENU_FOV_DESC] = "Quanto do mundo a câmera mostra, em porcentagem do original do jogo. Só na versão 1.4.3 do "
|
||||
[UI_MENU_FOV_DESC] = "Quanto do mundo a câmera mostra, em porcentagem do original do jogo. Nas versões 1.1.0 e 1.4.3 do "
|
||||
"jogo.",
|
||||
[UI_MENU_SHADOW_RES] = "Tamanho do mapa de sombras",
|
||||
[UI_MENU_SHADOW_RES_DESC] = "Tamanho do mapa de sombras do sol. O tamanho do jogo muda com a vista, até cerca de "
|
||||
@@ -1366,6 +1524,10 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
"ângulo raso continuam nítidos ao longe em vez de borrar. Jogo: o nível que o jogo pede, "
|
||||
"como no Switch.",
|
||||
[UI_MENU_ANISO_GAME] = "Jogo",
|
||||
[UI_MENU_LOD_STEADY] = "Detalhe estável sob carga",
|
||||
[UI_MENU_LOD_STEADY_DESC] = "Pula a configuração do jogo que reduz o detalhe de modelos e texturas quando a taxa "
|
||||
"de quadros cai, como faz o mod de emulador Disable LOD Quality Reduction. Só nas "
|
||||
"versões 1.2.1 e 1.4.3 do jogo. Deixe desligado em PCs fracos: lá essa redução mantém a taxa de quadros.",
|
||||
[UI_MENU_COLOR] = "Cor",
|
||||
[UI_MENU_COLOR_PRESET] = "Perfil de cor",
|
||||
[UI_MENU_COLOR_PRESET_DESC] = "Define os quatro valores abaixo. Vívido: mais contraste e saturação, sombras um "
|
||||
@@ -1416,10 +1578,21 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MOUSE_DIRECT] = "Direta",
|
||||
[UI_MENU_MENU_CURSOR] = "Mouse nos menus do jogo",
|
||||
[UI_MENU_MENU_CURSOR_DESC] = "Nos menus do próprio jogo (título, inventário, lojas, escolhas de diálogo) o ponteiro aparece: o item sob ele fica selecionado, o clique esquerdo confirma e o direito volta. Só depois de usar o mouse ou uma tecla por último, então com um controle os menus ficam como antes (jogo 1.4.3).",
|
||||
[UI_MENU_MAP_CLICK] = "Clique esquerdo no mapa",
|
||||
[UI_MENU_MAP_CLICK_DESC] = "No mapa do jogo, o botão esquerdo do mouse aperta A no cursor do mapa, em vez do botão ao qual está atribuído (Y por padrão). Requer Mouse nos menus do jogo (jogo 1.4.3).",
|
||||
[UI_MENU_DIALOGUE_CLICK] = "Cliques no diálogo",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "Enquanto uma caixa de diálogo está aberta, o clique esquerdo aperta B (continua o texto e pula a rolagem) e o direito aperta A, em vez dos botões aos quais estão atribuídos (Y por padrão, que abre o registro do diálogo, e ZL). As escolhas de diálogo continuam com o ponteiro: o clique esquerdo escolhe (jogo 1.4.3).",
|
||||
[UI_MENU_POINTER_IMAGE] = "Ponteiro do jogo",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "Enquanto o cursor não está capturado (os menus do jogo, este menu, depois de Esc), a janela mostra uma ponta de flecha dourada própria em vez da seta do sistema, no tamanho da escala da tela.",
|
||||
[UI_MENU_PROMPTS_MISSING] = "faltam os arquivos dos ícones: execute a instalação de novo",
|
||||
[UI_MENU_PROMPTS_FAILED] = "arquivos dos ícones danificados: execute a instalação de novo",
|
||||
[UI_MENU_PROMPTS_RESTART] = "os ícones mudam após reiniciar",
|
||||
[UI_MENU_PROMPTS_OFF_SHAPE] = "desligados nesta resolução de jogo (sem layout feito para ela)",
|
||||
[UI_MENU_OUTPUT_RES_NO_LAYOUT] = "sem layout feito para este formato: rode o instalador de novo",
|
||||
[UI_MENU_OUTPUT_RES_PREPARING] = "layout sendo feito em segundo plano; usado na próxima vez que o jogo abrir",
|
||||
[UI_MENU_SHAPE_PREPARE] = "Preparar o layout para esta tela",
|
||||
[UI_MENU_SHAPE_PREPARE_DESC] = "Faz em segundo plano o layout da interface e os botões escolhidos para o formato desta resolução de jogo, com as ferramentas do instalador, como o instalador faz para os monitores que viu. O jogo continua rodando; ele os usa a partir da próxima vez que abrir.",
|
||||
[UI_MENU_SHAPE_PREPARE_FAILED] = "as ferramentas do instalador não abriram: rode o instalador de novo",
|
||||
[UI_MENU_PROMPTS_OFF_MODS] = "desligados: um mod de RomFS substitui os arquivos deles",
|
||||
[UI_MENU_PROMPTS_OFF_PATCHES] = "desligados enquanto TOTK_ROMFS_PATCHES está definido",
|
||||
[UI_MENU_RESTART] = "Reiniciar agora",
|
||||
@@ -1439,6 +1612,33 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_WALK_SCALE] = "Intensidade do andar",
|
||||
[UI_MENU_WALK_SCALE_DESC] = "A inclinação dos analógicos do teclado enquanto a tecla de andar está segura. Metade "
|
||||
"é andar, a inclinação total é correr.",
|
||||
[UI_MENU_GROUP_GAMEPLAY_TWEAKS] = "Ajustes de jogabilidade",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED] = "Ajustes de jogabilidade",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED_DESC] = "Controles com a roda do mouse para rotação e distância na Ultramão, seleção de armas e itens, e zoom suave no mapa.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE] = "Rotação com roda (Ultramão)",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE_DESC] = "Gira objetos segurados pela Ultramão diretamente com a roda do mouse.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS] = "Eixo de rotação C (Ultramão)",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS_DESC] = "Segure C ao rolar a roda do mouse para girar o objeto no terceiro eixo.",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY] = "Sensibilidade de rotação (Ultramão)",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY_DESC] = "Define a velocidade de rotação do objeto com a roda do mouse.",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE] = "Distância com roda (Ultramão)",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE_DESC] = "Botão direito do mouse + roda aproxima ou afasta o objeto.",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY] = "Sensibilidade de distância (Ultramão)",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY_DESC] = "Define a velocidade de ajuste de distância com a roda do mouse.",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL] = "Seleção de armas com a roda",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL_DESC] = "Role a roda do mouse no modo livre para trocar de arma. Confirme com E.",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY] = "Sensibilidade de seleção de armas",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY_DESC] = "Passos da roda necessários para avançar para a próxima arma.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL] = "Seleção do menu rápido com a roda",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL_DESC] = "Role a roda do mouse para navegar por itens com o menu rápido aberto.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY] = "Sensibilidade do menu rápido",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY_DESC] = "Passos da roda necessários para avançar itens nos menus rápidos.",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD] = "Navegação A / D no menu rápido",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD_DESC] = "Teclas A / D para navegar para esquerda e direita nos menus rápidos.",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM] = "Zoom suave no mapa",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_DESC] = "Zoom inercial suave no mapa do Purah Pad usando a roda do mouse.",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY] = "Sensibilidade do zoom no mapa",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY_DESC] = "Define a velocidade de zoom no mapa com a roda do mouse.",
|
||||
[UI_MENU_OV_SCALE_DOWN] = "bilinear (o FSR só amplia)",
|
||||
[UI_MENU_HDR_HUE] = "Correção de matiz dos realces",
|
||||
[UI_MENU_HDR_HUE_DESC] = "Cores fortes como fogo e faíscas vão para o branco como na imagem SDR do próprio jogo e "
|
||||
@@ -1451,6 +1651,10 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SHADOW_RANGE_DESC] = "Afasta os degraus em que as sombras ficam mais suaves (20, 40, 80 e 160 m no "
|
||||
"jogo). Espalha o mapa de sombras por mais terreno: aumente a Resolução das sombras "
|
||||
"junto. Vale no próximo início.",
|
||||
[UI_MENU_GRASS_RANGE] = "Alcance da grama",
|
||||
[UI_MENU_GRASS_RANGE_DESC] = "Até onde a grama cresce ao redor da câmera (62,5 m no jogo). Mais alto mantém a "
|
||||
"grama dos campos mais longe em vez de ela surgir logo à sua frente; mais baixo "
|
||||
"desenha menos grama. Vale no próximo início.",
|
||||
[UI_MENU_CONTACT_SHADOWS] = "Sombras de contato",
|
||||
[UI_MENU_CONTACT_SHADOWS_DESC] = "Pequenas sombras do sol que os mapas de sombra não pegam: nos pés, sob pedras, "
|
||||
"na grama e em dobras. Traçadas na tela depois da iluminação. Vale no próximo "
|
||||
@@ -1486,6 +1690,11 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_FXAA] = "Antisserrilhado do jogo (FXAA)",
|
||||
[UI_MENU_FXAA_DESC] = "A suavização de bordas FXAA do próprio jogo. Borra um pouco os detalhes finos; com o DLAA "
|
||||
"ligado não é necessária.",
|
||||
[UI_MENU_REFLEX] = "NVIDIA Reflex Low Latency",
|
||||
[UI_MENU_REFLEX_DESC] = "Reduz a latência do sistema em GPUs NVIDIA usando VK_NV_low_latency2. Ligado + Boost mantém os clocks da GPU altos quando limitado pela CPU.",
|
||||
[UI_MENU_REFLEX_OFF] = "Desligado",
|
||||
[UI_MENU_REFLEX_ON] = "Ligado",
|
||||
[UI_MENU_REFLEX_BOOST] = "Ligado + Boost",
|
||||
[UI_MENU_TAB_CHEATS] = "Cheats",
|
||||
[UI_MENU_CHEATS_NONE] = "Nenhum cheat para esta versão do jogo. Os cheats de um mod são um arquivo de cheats do "
|
||||
"Atmosphere na pasta cheats dele, com o nome da build do jogo: mods\\<mod>\\cheats\\%s. "
|
||||
@@ -1552,7 +1761,8 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODS_CHEATS] = "金手指:%d 个。在“金手指”标签页中开关。",
|
||||
[UI_MENU_MODS_CHEATS_FILE] = "此游戏版本的金手指在启动时从此模组的 cheats\\%s 读取。",
|
||||
[UI_MENU_MODS_BAD_NAME] = "文件夹名称含有 |,模组列表用它分隔名称。请重命名该文件夹。",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "它有 %u 个文件是为其他游戏版本制作的,已被跳过。请寻找适用于你的游戏版本的此模组。",
|
||||
[UI_MENU_MODS_OTHER_VERSION] = "它有 %u 个文件的文件名带有其他游戏版本号。只有在有内容请求这些文件名时,游戏才会读取它们。"
|
||||
"如果模组不起作用,请寻找适用于你的游戏版本的此模组。",
|
||||
[UI_MENU_MODS_UNUSED] = "未使用",
|
||||
[UI_MENU_MODS_FPS60] = "60 FPS 补丁",
|
||||
[UI_MENU_MODS_FPS60_DESC] = "移植版自带的 60 帧补丁。在“游戏”页的帧率上限中设置。",
|
||||
@@ -1624,7 +1834,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MOVIE_ASPECT_STRETCH] = "拉伸",
|
||||
[UI_MENU_FOV] = "视野",
|
||||
[UI_MENU_FOV_DESC] = "镜头能看到多大范围,以游戏自身视野的百分比表示。"
|
||||
"仅限游戏版本 1.4.3。",
|
||||
"支持游戏版本 1.1.0 和 1.4.3。",
|
||||
[UI_MENU_SHARPNESS] = "FSR 锐度",
|
||||
[UI_MENU_SHARPNESS_DESC] = "FSR 缩放后的锐化强度;0 为关闭。",
|
||||
[UI_MENU_COLOR] = "色彩",
|
||||
@@ -1680,11 +1890,29 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
"这样被打断的读取可能会永久卡住。",
|
||||
[UI_MENU_VOLUME] = "音量",
|
||||
[UI_MENU_VOLUME_DESC] = "游戏的主音量。",
|
||||
[UI_MENU_VOLUME_MUSIC] = "音乐音量",
|
||||
[UI_MENU_VOLUME_MUSIC_DESC] = "背景音乐的音量。",
|
||||
[UI_MENU_VOLUME_SFX] = "音效音量",
|
||||
[UI_MENU_VOLUME_SFX_DESC] = "声音特效的音量。",
|
||||
[UI_MENU_VOLUME_VOICE] = "语音音量",
|
||||
[UI_MENU_VOLUME_VOICE_DESC] = "角色语音的音量。",
|
||||
[UI_MENU_AUDIO_CHANNELS] = "扬声器",
|
||||
[UI_MENU_AUDIO_CHANNELS_DESC] = "立体声或 5.1 环绕声输出。选择自动时,若 Windows 扬声器设置有六个或更多声道则使用 5.1。重启后生效。",
|
||||
[UI_MENU_CHANNELS_AUTO] = "自动", [UI_MENU_CHANNELS_STEREO] = "立体声", [UI_MENU_CHANNELS_51] = "5.1 环绕声",
|
||||
[UI_MENU_AUDIO_DEVICE] = "输出设备",
|
||||
[UI_MENU_AUDIO_DEVICE_DESC] = "声音从哪个设备播放。系统默认跟随 Windows 的默认设备。所选设备被拔出时改用系统默认,"
|
||||
"设备重新连接后恢复。立即生效。",
|
||||
[UI_MENU_AUDIO_DEVICE_DEFAULT] = "系统默认",
|
||||
[UI_MENU_MOTION] = "体感操作",
|
||||
[UI_MENU_MOTION_DESC] = "用手柄的陀螺仪瞄准。",
|
||||
[UI_MENU_GYRO_CALIBRATION] = "陀螺仪偏置校准",
|
||||
[UI_MENU_GYRO_CALIBRATION_DESC] = "减去下面校准行测得的手柄静止偏移。关闭时测量值仍然保留。",
|
||||
[UI_MENU_GYRO_CALIBRATE] = "校准陀螺仪",
|
||||
[UI_MENU_GYRO_CALIBRATE_DESC] = "测量并消除陀螺仪的静止偏移。请放下手柄或保持静止两秒。",
|
||||
[UI_MENU_GYRO_CALIBRATE_WAIT] = "校准中...",
|
||||
[UI_MENU_GYRO_CALIBRATED] = "%s,已校准",
|
||||
[UI_MENU_GYRO_CALIBRATE_FAILED] = "校准失败",
|
||||
[UI_MENU_GYRO_CALIBRATE_MOVED] = "手柄移动了:请保持静止后重试",
|
||||
[UI_MENU_RUMBLE_STRENGTH] = "振动强度",
|
||||
[UI_MENU_RUMBLE_STRENGTH_DESC] = "手柄振动的强弱。",
|
||||
[UI_MENU_RUMBLE_CURVE] = "振动曲线",
|
||||
@@ -1815,6 +2043,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_RPADDLE1] = "右背键",
|
||||
[UI_PAD_LPADDLE2] = "左背键 2",
|
||||
[UI_PAD_RPADDLE2] = "右背键 2",
|
||||
[UI_PAD_TOUCHPAD] = "触摸板按下",
|
||||
[UI_PAD_CROSS] = "叉键",
|
||||
[UI_PAD_CIRCLE] = "圆圈键",
|
||||
[UI_PAD_SQUARE] = "方块键",
|
||||
@@ -2021,6 +2250,9 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_ANISO] = "纹理过滤",
|
||||
[UI_MENU_ANISO_DESC] = "表面纹理的各向异性过滤:以小角度看到的地面、道路和墙壁在远处依然清晰,而不会模糊。游戏:使用游戏请求的级别,与 Switch 上相同。",
|
||||
[UI_MENU_ANISO_GAME] = "游戏",
|
||||
[UI_MENU_LOD_STEADY] = "负载下保持细节",
|
||||
[UI_MENU_LOD_STEADY_DESC] = "跳过游戏在帧率下降时降低模型和纹理细节的设置,与模拟器模组 Disable LOD Quality "
|
||||
"Reduction 的作用相同。仅适用于游戏版本 1.2.1 和 1.4.3。低配电脑请勿开启:在那里正是这种降低维持了帧率。",
|
||||
[UI_MENU_HDR_GROUP] = "HDR",
|
||||
[UI_MENU_HDR] = "HDR 输出",
|
||||
[UI_MENU_HDR_DESC] = "在 HDR 显示器上呈现明亮的高光。需要在 Windows 中开启 HDR(“使用 HDR”),或使用带色彩管理的 Wayland 合成器;否则画面保持 "
|
||||
@@ -2045,10 +2277,21 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MOUSE_DIRECT] = "直接",
|
||||
[UI_MENU_MENU_CURSOR] = "在游戏菜单中使用鼠标",
|
||||
[UI_MENU_MENU_CURSOR_DESC] = "在游戏自身的菜单中(标题、背包、商店、对话选项)显示指针:指针下的项目被选中,左键确认,右键返回。仅在最后使用的是鼠标或键盘时生效,因此使用手柄时菜单保持不变(游戏 1.4.3)。",
|
||||
[UI_MENU_MAP_CLICK] = "在地图上左键单击",
|
||||
[UI_MENU_MAP_CLICK_DESC] = "在游戏地图上,鼠标左键在地图光标处按下 A 键,而不是按下它所绑定的按键(默认为 Y)。需要开启“在游戏菜单中使用鼠标”(游戏 1.4.3)。",
|
||||
[UI_MENU_DIALOGUE_CLICK] = "对话中的鼠标点击",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "对话框打开时,鼠标左键按下 B 键(继续对话并跳过文字滚动),右键按下 A 键,而不是它们所绑定的按键(默认为 Y,会打开对话记录;以及 ZL)。对话选项仍使用指针:左键选择(游戏 1.4.3)。",
|
||||
[UI_MENU_POINTER_IMAGE] = "游戏指针",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "光标未被捕获时(游戏菜单、本菜单、按 Esc 之后),窗口显示自带的金色箭头,而不是系统箭头,大小随屏幕缩放。",
|
||||
[UI_MENU_PROMPTS_MISSING] = "缺少按键提示文件:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_FAILED] = "按键提示文件已损坏:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_RESTART] = "按键提示重启后生效",
|
||||
[UI_MENU_PROMPTS_OFF_SHAPE] = "此游戏分辨率下关闭(未为其制作布局)",
|
||||
[UI_MENU_OUTPUT_RES_NO_LAYOUT] = "未为此比例制作布局:请重新运行安装程序",
|
||||
[UI_MENU_OUTPUT_RES_PREPARING] = "布局正在后台制作;下次启动时使用",
|
||||
[UI_MENU_SHAPE_PREPARE] = "为此屏幕准备布局",
|
||||
[UI_MENU_SHAPE_PREPARE_DESC] = "使用安装程序的工具,在后台为此游戏分辨率的比例制作界面布局和所选按键提示,与安装程序为其检测到的显示器所做的相同。游戏继续运行;下次启动时生效。",
|
||||
[UI_MENU_SHAPE_PREPARE_FAILED] = "安装程序的工具未能启动:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_OFF_MODS] = "已关闭:RomFS 模组替换了它们的文件",
|
||||
[UI_MENU_PROMPTS_OFF_PATCHES] = "设置了 TOTK_ROMFS_PATCHES 时关闭",
|
||||
[UI_MENU_RESTART] = "立即重启",
|
||||
@@ -2063,6 +2306,33 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_WALK_KEY_TAKEN] = "同时为 %s",
|
||||
[UI_MENU_WALK_SCALE] = "步行幅度",
|
||||
[UI_MENU_WALK_SCALE_DESC] = "按住步行键时键盘摇杆的推动幅度。一半为走路,推满为奔跑。",
|
||||
[UI_MENU_GROUP_GAMEPLAY_TWEAKS] = "游戏操作微调",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED] = "启用操作微调",
|
||||
[UI_MENU_GAMEPLAY_TWEAKS_ENABLED_DESC] = "使用鼠标滚轮控制究极手物体旋转与距离、武器与道具切换以及地图平滑缩放。",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE] = "究极手滚轮旋转",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE_DESC] = "究极手抓取物体时直接使用鼠标滚轮旋转物体,无需按住 R 键。",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS] = "究极手 C 轴旋转",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS_DESC] = "滚动滚轮时按住 C 键可绕第三轴旋转物体。",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY] = "究极手旋转灵敏度",
|
||||
[UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY_DESC] = "鼠标滚轮旋转物体的灵敏度倍率。",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE] = "究极手滚轮推拉距离",
|
||||
[UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE_DESC] = "按住鼠标右键滚动滚轮可推远或拉近物体。",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY] = "究极手距离灵敏度",
|
||||
[UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY_DESC] = "鼠标滚轮推拉物体距离的灵敏度倍率。",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL] = "自由状态滚轮切换武器",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_WHEEL_DESC] = "在自由行动时滚动鼠标滚轮切换武器,按 E 键确认。",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY] = "武器切换滚轮灵敏度",
|
||||
[UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY_DESC] = "滚轮切换下一个武器所需的滚动步数灵敏度。",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL] = "快捷菜单滚轮选择",
|
||||
[UI_MENU_GAMEPLAY_ITEM_WHEEL_DESC] = "快捷菜单打开时通过鼠标滚轮快速切换选择物品。",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY] = "快捷菜单滚轮灵敏度",
|
||||
[UI_MENU_GAMEPLAY_ITEM_SENSITIVITY_DESC] = "在快捷菜单中切换下一个物品所需的滚轮灵敏度。",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD] = "快捷菜单 A / D 键切换",
|
||||
[UI_MENU_GAMEPLAY_ITEM_AD_DESC] = "快捷菜单打开时按 A / D 键向左或向右切换选择物品。",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM] = "地图平滑缩放",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_DESC] = "在普尔亚平板地图上使用鼠标滚轮进行平滑惯性缩放。",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY] = "地图缩放灵敏度",
|
||||
[UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY_DESC] = "鼠标滚轮缩放地图的灵敏度倍率。",
|
||||
[UI_MENU_OV_SCALE_DOWN] = "双线性(FSR 只能放大)",
|
||||
[UI_MENU_HDR_HUE] = "高光色调校正",
|
||||
[UI_MENU_HDR_HUE_DESC] = "火焰、火花等明亮色彩像游戏自身的 SDR 画面一样趋向白色,与它们发出的光一致;0 保持完全饱和。",
|
||||
@@ -2070,6 +2340,8 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SHADOW_SCALE_DESC] = "将太阳阴影贴图的每条边绘制为游戏 960x960 的若干倍:阴影边缘和树叶阴影更清晰。下次启动时生效。",
|
||||
[UI_MENU_SHADOW_RANGE] = "阴影级联范围",
|
||||
[UI_MENU_SHADOW_RANGE_DESC] = "把阴影变柔和的分界(游戏中为 20、40、80 和 160 米)推得更远。阴影贴图会覆盖更大的地面,请同时提高阴影分辨率。下次启动时生效。",
|
||||
[UI_MENU_GRASS_RANGE] = "草地范围",
|
||||
[UI_MENU_GRASS_RANGE_DESC] = "镜头周围长草的距离(游戏中为 62.5 米)。调高后草地延伸得更远,不会在你面前才长出来;调低则少画一些草。下次启动时生效。",
|
||||
[UI_MENU_CONTACT_SHADOWS] = "接触阴影",
|
||||
[UI_MENU_CONTACT_SHADOWS_DESC] = "阴影贴图遗漏的细小太阳阴影:脚下、石头下、草丛和褶皱中。在光照之后于屏幕空间追踪。下次启动时生效。",
|
||||
[UI_MENU_PCSS] = "柔和阴影",
|
||||
@@ -2096,6 +2368,11 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DLSS_CHARS_FULL] = "强",
|
||||
[UI_MENU_FXAA] = "游戏抗锯齿(FXAA)",
|
||||
[UI_MENU_FXAA_DESC] = "游戏自身的 FXAA 边缘平滑。会让细节略微模糊;开启 DLAA 时不需要。",
|
||||
[UI_MENU_REFLEX] = "NVIDIA Reflex 低延迟",
|
||||
[UI_MENU_REFLEX_DESC] = "在支持 VK_NV_low_latency2 的 NVIDIA 显卡上降低系统延迟。开 + 增强 (On + Boost) 会在 CPU 瓶颈时保持 GPU 高频率。",
|
||||
[UI_MENU_REFLEX_OFF] = "关",
|
||||
[UI_MENU_REFLEX_ON] = "开",
|
||||
[UI_MENU_REFLEX_BOOST] = "开 + 增强",
|
||||
[UI_MENU_TAB_CHEATS] = "金手指",
|
||||
[UI_MENU_CHEATS_NONE] = "此游戏版本没有金手指。模组的金手指是它的 cheats 文件夹中以游戏构建命名的 Atmosphere "
|
||||
"金手指文件:mods\\<模组>\\cheats\\%s。重启游戏后才会读取。对于修改游戏代码的金手指,"
|
||||
|
||||
+34
-3
@@ -42,6 +42,7 @@ typedef enum {
|
||||
UI_MENU_FOV, UI_MENU_FOV_DESC,
|
||||
UI_MENU_SHADOW_RES, UI_MENU_SHADOW_RES_DESC, UI_MENU_SHADOW_RES_GAME,
|
||||
UI_MENU_ANISO, UI_MENU_ANISO_DESC, UI_MENU_ANISO_GAME,
|
||||
UI_MENU_LOD_STEADY, UI_MENU_LOD_STEADY_DESC,
|
||||
UI_MENU_SHARPNESS, UI_MENU_SHARPNESS_DESC,
|
||||
UI_MENU_COLOR, // group heading over the colour rows
|
||||
UI_MENU_COLOR_PRESET, UI_MENU_COLOR_PRESET_DESC, UI_MENU_COLOR_DEFAULT, UI_MENU_COLOR_VIVID, UI_MENU_COLOR_CLARITY,
|
||||
@@ -53,12 +54,14 @@ typedef enum {
|
||||
UI_MENU_HDR_UI, UI_MENU_HDR_UI_DESC, UI_MENU_HDR_HUE, UI_MENU_HDR_HUE_DESC,
|
||||
UI_MENU_SHADOW_SCALE, UI_MENU_SHADOW_SCALE_DESC,
|
||||
UI_MENU_SHADOW_RANGE, UI_MENU_SHADOW_RANGE_DESC,
|
||||
UI_MENU_GRASS_RANGE, UI_MENU_GRASS_RANGE_DESC,
|
||||
UI_MENU_CONTACT_SHADOWS, UI_MENU_CONTACT_SHADOWS_DESC,
|
||||
UI_MENU_PCSS, UI_MENU_PCSS_DESC,
|
||||
UI_MENU_DLAA, UI_MENU_DLAA_DESC, UI_MENU_DLSS, UI_MENU_DLSS_DESC, UI_MENU_DLSS_DLAA, UI_MENU_DLSS_QUALITY,
|
||||
UI_MENU_DLSS_BALANCED, UI_MENU_DLSS_PERFORMANCE, UI_MENU_DLSS_ULTRA, UI_MENU_DLSS_PRESET, UI_MENU_DLSS_PRESET_DESC,
|
||||
UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J, UI_MENU_DLSS_CHARS, UI_MENU_DLSS_CHARS_DESC,
|
||||
UI_MENU_DLSS_CHARS_OFF, UI_MENU_DLSS_CHARS_LIGHT, UI_MENU_DLSS_CHARS_MEDIUM, UI_MENU_DLSS_CHARS_FULL, UI_MENU_FXAA, UI_MENU_FXAA_DESC,
|
||||
UI_MENU_REFLEX, UI_MENU_REFLEX_DESC, UI_MENU_REFLEX_OFF, UI_MENU_REFLEX_ON, UI_MENU_REFLEX_BOOST,
|
||||
|
||||
// Game
|
||||
UI_MENU_FPS_LIMIT, UI_MENU_FPS_LIMIT_DESC, UI_MENU_FPS_30, UI_MENU_FPS_40, UI_MENU_FPS_45, UI_MENU_FPS_60, UI_MENU_FPS_90,
|
||||
@@ -88,7 +91,7 @@ typedef enum {
|
||||
UI_MENU_MODS_EXEFS_OTHER,
|
||||
UI_MENU_MODS_EXEFS_ON, // printf: its ExeFS patch files in use
|
||||
UI_MENU_MODS_REPLACES_BUILTIN, // printf: its ExeFS patch files in use, the port's own patch sets they turn off
|
||||
UI_MENU_MODS_OTHER_VERSION, // printf: files made for another game version, left out
|
||||
UI_MENU_MODS_OTHER_VERSION, // printf: files named for another game version, read only when asked for by name
|
||||
UI_MENU_MODS_UNUSED, // under the switch of a mod the port cannot use
|
||||
UI_MENU_MODS_CHEATS, // printf: its cheats as read at start
|
||||
UI_MENU_MODS_CHEATS_FILE, // printf: <build id>.txt, when none were read
|
||||
@@ -97,10 +100,17 @@ typedef enum {
|
||||
|
||||
// Sound
|
||||
UI_MENU_VOLUME, UI_MENU_VOLUME_DESC,
|
||||
UI_MENU_VOLUME_MUSIC, UI_MENU_VOLUME_MUSIC_DESC,
|
||||
UI_MENU_VOLUME_SFX, UI_MENU_VOLUME_SFX_DESC,
|
||||
UI_MENU_VOLUME_VOICE, UI_MENU_VOLUME_VOICE_DESC,
|
||||
UI_MENU_AUDIO_CHANNELS, UI_MENU_AUDIO_CHANNELS_DESC, UI_MENU_CHANNELS_AUTO, UI_MENU_CHANNELS_STEREO, UI_MENU_CHANNELS_51,
|
||||
UI_MENU_AUDIO_DEVICE, UI_MENU_AUDIO_DEVICE_DESC, UI_MENU_AUDIO_DEVICE_DEFAULT,
|
||||
|
||||
// Controls
|
||||
UI_MENU_MOTION, UI_MENU_MOTION_DESC,
|
||||
UI_MENU_GYRO_CALIBRATION, UI_MENU_GYRO_CALIBRATION_DESC,
|
||||
UI_MENU_GYRO_CALIBRATE, UI_MENU_GYRO_CALIBRATE_DESC, UI_MENU_GYRO_CALIBRATE_WAIT,
|
||||
UI_MENU_GYRO_CALIBRATED, UI_MENU_GYRO_CALIBRATE_FAILED, UI_MENU_GYRO_CALIBRATE_MOVED,
|
||||
UI_MENU_RUMBLE_STRENGTH, UI_MENU_RUMBLE_STRENGTH_DESC,
|
||||
UI_MENU_RUMBLE_CURVE, UI_MENU_RUMBLE_CURVE_DESC,
|
||||
UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC,
|
||||
@@ -109,6 +119,8 @@ typedef enum {
|
||||
UI_MENU_PROMPTS, UI_MENU_PROMPTS_DESC, UI_MENU_PROMPTS_NINTENDO, UI_MENU_PROMPTS_XBOX, UI_MENU_PROMPTS_PC,
|
||||
// the notes under the prompts: their files are missing or damaged, they change after restart, or why they are off
|
||||
UI_MENU_PROMPTS_MISSING, UI_MENU_PROMPTS_FAILED, UI_MENU_PROMPTS_RESTART, UI_MENU_PROMPTS_OFF_SHAPE,
|
||||
UI_MENU_OUTPUT_RES_NO_LAYOUT, UI_MENU_OUTPUT_RES_PREPARING, UI_MENU_SHAPE_PREPARE, UI_MENU_SHAPE_PREPARE_DESC,
|
||||
UI_MENU_SHAPE_PREPARE_FAILED,
|
||||
UI_MENU_PROMPTS_OFF_MODS, UI_MENU_PROMPTS_OFF_PATCHES,
|
||||
// "Restart now" under the prompts while they change after restart, and its confirmation (Cancel: UI_MENU_RESET_NO)
|
||||
UI_MENU_RESTART, UI_MENU_RESTART_DESC, UI_MENU_RESTART_CONFIRM, UI_MENU_RESTART_YES, UI_MENU_RESTART_SAVING,
|
||||
@@ -116,9 +128,28 @@ typedef enum {
|
||||
UI_MENU_STICK_DEADZONE_NOW, UI_MENU_STICK_SENS, UI_MENU_STICK_SENS_DESC,
|
||||
UI_MENU_MOUSE_MODE, UI_MENU_MOUSE_MODE_DESC, UI_MENU_MOUSE_STICK, UI_MENU_MOUSE_DIRECT,
|
||||
UI_MENU_MENU_CURSOR, UI_MENU_MENU_CURSOR_DESC,
|
||||
UI_MENU_MAP_CLICK, UI_MENU_MAP_CLICK_DESC,
|
||||
UI_MENU_DIALOGUE_CLICK, UI_MENU_DIALOGUE_CLICK_DESC,
|
||||
UI_MENU_POINTER_IMAGE, UI_MENU_POINTER_IMAGE_DESC,
|
||||
UI_MENU_MOUSE_SENS, UI_MENU_MOUSE_SENS_DESC,
|
||||
UI_MENU_WALK_KEY, UI_MENU_WALK_KEY_DESC, UI_MENU_WALK_KEY_TAKEN, UI_MENU_WALK_SCALE, UI_MENU_WALK_SCALE_DESC,
|
||||
|
||||
// Controls tab: Gameplay tweaks
|
||||
UI_MENU_GROUP_GAMEPLAY_TWEAKS,
|
||||
UI_MENU_GAMEPLAY_TWEAKS_ENABLED, UI_MENU_GAMEPLAY_TWEAKS_ENABLED_DESC,
|
||||
UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE, UI_MENU_GAMEPLAY_ULTRAHAND_ROTATE_DESC,
|
||||
UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS, UI_MENU_GAMEPLAY_ULTRAHAND_C_AXIS_DESC,
|
||||
UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY, UI_MENU_GAMEPLAY_ROTATION_SENSITIVITY_DESC,
|
||||
UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE, UI_MENU_GAMEPLAY_ULTRAHAND_DISTANCE_DESC,
|
||||
UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY, UI_MENU_GAMEPLAY_DISTANCE_SENSITIVITY_DESC,
|
||||
UI_MENU_GAMEPLAY_WEAPON_WHEEL, UI_MENU_GAMEPLAY_WEAPON_WHEEL_DESC,
|
||||
UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY, UI_MENU_GAMEPLAY_WEAPON_SENSITIVITY_DESC,
|
||||
UI_MENU_GAMEPLAY_ITEM_WHEEL, UI_MENU_GAMEPLAY_ITEM_WHEEL_DESC,
|
||||
UI_MENU_GAMEPLAY_ITEM_SENSITIVITY, UI_MENU_GAMEPLAY_ITEM_SENSITIVITY_DESC,
|
||||
UI_MENU_GAMEPLAY_ITEM_AD, UI_MENU_GAMEPLAY_ITEM_AD_DESC,
|
||||
UI_MENU_GAMEPLAY_MAP_ZOOM, UI_MENU_GAMEPLAY_MAP_ZOOM_DESC,
|
||||
UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY, UI_MENU_GAMEPLAY_MAP_ZOOM_SENSITIVITY_DESC,
|
||||
|
||||
// Controls tab: the remapping rows (ui/binds_page.cpp)
|
||||
UI_BINDS_HELP, UI_BINDS_COL_KEY1, UI_BINDS_COL_KEY2, UI_BINDS_COL_PAD,
|
||||
UI_BINDS_GROUP_BUTTONS, UI_BINDS_GROUP_MOVE, UI_BINDS_GROUP_CAMERA,
|
||||
@@ -143,10 +174,10 @@ typedef enum {
|
||||
UI_KEY_ENTER, UI_KEY_BACKSPACE, UI_KEY_RSHIFT, UI_KEY_RCTRL, UI_KEY_LALT, UI_KEY_CAPSLOCK, UI_KEY_INSERT,
|
||||
UI_KEY_DELETE, UI_KEY_HOME, UI_KEY_END, UI_KEY_PAGEUP, UI_KEY_PAGEDOWN,
|
||||
UI_KEY_NUM_FMT, // "Num %s": a numpad key
|
||||
// gamepad buttons, in pad id order PAD_SOUTH .. PAD_RPADDLE2, then the PlayStation face labels
|
||||
// gamepad buttons, in pad id order PAD_SOUTH .. PAD_TOUCHPAD, then the PlayStation face labels
|
||||
UI_PAD_SOUTH, UI_PAD_EAST, UI_PAD_WEST, UI_PAD_NORTH, UI_PAD_LSTICK, UI_PAD_RSTICK, UI_PAD_L, UI_PAD_R,
|
||||
UI_PAD_START, UI_PAD_BACK, UI_PAD_DPAD_LEFT, UI_PAD_DPAD_UP, UI_PAD_DPAD_RIGHT, UI_PAD_DPAD_DOWN, UI_PAD_ZL,
|
||||
UI_PAD_ZR, UI_PAD_LPADDLE1, UI_PAD_RPADDLE1, UI_PAD_LPADDLE2, UI_PAD_RPADDLE2,
|
||||
UI_PAD_ZR, UI_PAD_LPADDLE1, UI_PAD_RPADDLE1, UI_PAD_LPADDLE2, UI_PAD_RPADDLE2, UI_PAD_TOUCHPAD,
|
||||
UI_PAD_CROSS, UI_PAD_CIRCLE, UI_PAD_SQUARE, UI_PAD_TRIANGLE,
|
||||
|
||||
// Amiibo tab (ui/amiibo_page.cpp): the dump folder and its files, the emulated NFC reader and its state, the
|
||||
|
||||
+10
-1
@@ -36,7 +36,8 @@ typedef struct VkCtx {
|
||||
has_nv_checkpoints, // VK_NV_device_diagnostic_checkpoints (TOTK_PASS_CRUMBS=1, vk_crumbs.c)
|
||||
has_astc_ldr, // textureCompressionASTC_LDR (enabled when reported)
|
||||
has_calibrated, // VK_KHR/EXT_calibrated_timestamps (GPU idle split in the perf line)
|
||||
has_hdr_metadata; // VK_EXT_hdr_metadata (vk_hdr.c vk_hdr_metadata)
|
||||
has_hdr_metadata, // VK_EXT_hdr_metadata (vk_hdr.c vk_hdr_metadata)
|
||||
has_nv_reflex; // VK_NV_low_latency2 (NVIDIA Reflex Low Latency)
|
||||
// Feedback loops (maxwell.md 1.9, vk_exec_draw.c feedback_prepare): a draw samples a target of its open pass that
|
||||
// an earlier draw of the pass wrote. TOTK_FEEDBACK=0: VK_FEEDBACK_OFF (sampled in GENERAL without a barrier, the
|
||||
// old behaviour); VK_FEEDBACK_LAYOUT with VK_EXT_attachment_feedback_loop_layout and dynamicRenderingLocalRead
|
||||
@@ -60,6 +61,7 @@ typedef struct {
|
||||
int amd_sc; // AMD's Windows driver branch for RDNA 1 and 2 ("AMD proprietary shader compiler")
|
||||
int mesa; // a Mesa driver the game runs on: RADV, ANV or NVK
|
||||
int intel_igpu_win; // Intel's Windows driver on an integrated GPU (UHD, Iris Xe, Core Ultra graphics)
|
||||
int demote; // shaderDemoteToHelperInvocation enabled: modules may use OpDemoteToHelperInvocation
|
||||
} VkCaps;
|
||||
extern VkCaps vk_caps;
|
||||
void vk_caps_driver(VkPhysicalDevice p); // first, before vkCreateDevice: vk_caps.amd, amd_sc, mesa, intel_igpu_win
|
||||
@@ -147,6 +149,10 @@ void vk_present_blit(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int
|
||||
int vk_fsr_record(VkCommandBuffer cb, unsigned slot, VkImage src, VkFormat fmt, int sw, int sh, const int crop[4],
|
||||
VkImage dst, const int out[4]);
|
||||
void vk_fsr_release(void); // before the device goes away
|
||||
void vk_reflex_submit_frame(uint64_t id); // this thread's submissions belong to frame id (0: the game's current one)
|
||||
uint64_t vk_reflex_submit_id(void);
|
||||
void vk_reflex_present_frame(uint64_t id); // the present thread, before the blit of frame id
|
||||
int vk_has_reflex(void);
|
||||
// Colour adjustment on the present (vk_color.c): with TOTK_COLOR_* away from their defaults, records a pass that writes
|
||||
// src's crop rectangle {x, y, w, h}, adjusted, into an RGBA16F image of that size in GENERAL and returns it (the caller
|
||||
// scales that one instead, crop {0, 0, w, h}); VK_NULL_HANDLE = nothing recorded. src is in GENERAL, fmt its format.
|
||||
@@ -415,6 +421,9 @@ int vk_mem_span_live(const VkMemSpan *sp);
|
||||
// from then on are freed once the timeline reaches it.
|
||||
void vk_mem_note_fence(uint64_t timeline_value);
|
||||
void vk_mem_fault_log(void); // vk_device_fault_report: the deferred-free state, lock-free
|
||||
// vk_device_fault_report: the last descriptor pool events (vk_exec_draw.c journal: CbRes made, pools handed out and
|
||||
// reset), lock-free.
|
||||
void vk_exec_pool_journal_log(void);
|
||||
void vk_mem_collect(void); // frees what has completed
|
||||
// After a failed allocation, on a thread that may hold the texture lock and the upload lock (cmd_lock) but no VMA
|
||||
// lock: frees the headroom blocks and the completed upload batches and deferred objects, and requests the release
|
||||
|
||||
+11
-8
@@ -33,7 +33,7 @@
|
||||
|
||||
#define WEAK __attribute__((weak))
|
||||
|
||||
typedef struct { VkImage image; VkFormat format; int w, h, has_crop, crop[4]; uint64_t frame, at, queued, value; } PresentJob;
|
||||
typedef struct { VkImage image; VkFormat format; int w, h, has_crop, crop[4]; uint64_t frame, at, queued, value, pid; } PresentJob; // pid: the frame's present ID (vk_reflex_frame)
|
||||
|
||||
static PlatMutex pl = PLAT_MUTEX_INIT;
|
||||
static PlatCond pcv = PLAT_COND_INIT; // job queued, job taken, job submitted
|
||||
@@ -60,6 +60,8 @@ static void present_main(void *arg) {
|
||||
plat_cond_broadcast(&pcv);
|
||||
plat_mutex_unlock(&pl);
|
||||
if (flight_on) vk_thumbs_frame(j.frame);
|
||||
vk_reflex_present_frame(j.pid); // the present of this blit, and the submission after it, are the frame's
|
||||
vk_reflex_submit_frame(j.pid);
|
||||
vk_present_blit(j.image, VK_IMAGE_LAYOUT_GENERAL, j.format, j.w, j.h, j.has_crop ? j.crop : NULL);
|
||||
uint64_t f = vk_sync_submit(NULL, 0); // a timeline value after the blit: deferred destruction waits for the blit too
|
||||
if (j.value && f != j.value)
|
||||
@@ -99,7 +101,7 @@ void vk_present_drain(void) {
|
||||
// The present after the frame count: resolves the image and hands the blit to the present thread. queued: when the game
|
||||
// presented; value: the timeline value queued for this present (asynchronous replay), 0 for the next one (synchronous).
|
||||
static void present_image(const tex_t *t, const int crop[4], uint64_t at_ns, uint64_t queued, uint64_t frame,
|
||||
uint64_t value) {
|
||||
uint64_t value, uint64_t pid) {
|
||||
static volatile int32_t n_skipped;
|
||||
vk_exec_frame_log(t, frame);
|
||||
vk_dlaa_frame();
|
||||
@@ -120,7 +122,7 @@ static void present_image(const tex_t *t, const int crop[4], uint64_t at_ns, uin
|
||||
return;
|
||||
}
|
||||
PresentJob j = {.image = img->image, .format = img->format, .w = (int)img->width, .h = (int)img->height, .frame = frame,
|
||||
.at = at_ns, .queued = queued, .value = value};
|
||||
.at = at_ns, .queued = queued, .value = value, .pid = pid};
|
||||
vk_hdr_present_source(img, &j.image, &j.format); // TOTK_HDR: the float picture the game copied into it, same size
|
||||
if (crop) {
|
||||
j.has_crop = 1;
|
||||
@@ -144,7 +146,7 @@ static void present_image(const tex_t *t, const int crop[4], uint64_t at_ns, uin
|
||||
enum { RI_SUBMIT, RI_PRESENT, RI_RELEASE };
|
||||
typedef struct {
|
||||
int kind, n, has_crop, crop[4];
|
||||
uint64_t value, submit_no, at, queued;
|
||||
uint64_t value, submit_no, at, queued, pid; // pid: the game's frame when it queued the item (present ID)
|
||||
uint64_t *h;
|
||||
const tex_t *tex; // RI_RELEASE: a copy the item owns (the game may reuse the object's memory)
|
||||
} ReplayItem;
|
||||
@@ -223,6 +225,7 @@ static void replay_main(void *arg) {
|
||||
plat_cond_broadcast(&rcv);
|
||||
plat_mutex_unlock(&rl);
|
||||
if (it.kind == RI_SUBMIT) {
|
||||
vk_reflex_submit_frame(it.pid); // the replay thread submits the frame the game was on when it queued it
|
||||
uint64_t f = submit_sync(it.h, it.n);
|
||||
if (f != it.value)
|
||||
rt_fatal("vk: replayed submission signalled %llu, queued as %llu", (unsigned long long)f,
|
||||
@@ -234,7 +237,7 @@ static void replay_main(void *arg) {
|
||||
free((void *)it.tex);
|
||||
} else {
|
||||
uint64_t frame = __atomic_add_fetch(&gfx_counters.frames, 1, __ATOMIC_RELAXED);
|
||||
present_image(it.tex, it.has_crop ? it.crop : NULL, it.at, it.queued, frame, it.value);
|
||||
present_image(it.tex, it.has_crop ? it.crop : NULL, it.at, it.queued, frame, it.value, it.pid);
|
||||
}
|
||||
plat_mutex_lock(&rl);
|
||||
if (it.kind != RI_RELEASE) r_value_done = it.value;
|
||||
@@ -345,7 +348,7 @@ static void vk_be_present(const tex_t *t, const int crop[4], uint64_t at_ns) {
|
||||
if (!gfx_replay_async()) {
|
||||
uint64_t frame = __atomic_add_fetch(&gfx_counters.frames, 1, __ATOMIC_RELAXED);
|
||||
perf_present(frame); // before vk_exec_frame_log, which resets the frame's exec counts the flight recorder reads
|
||||
present_image(t, crop, at_ns, kern_now_ns(), frame, 0);
|
||||
present_image(t, crop, at_ns, kern_now_ns(), frame, 0, vk_reflex_frame());
|
||||
return;
|
||||
}
|
||||
// Frame bound: the replay thread handled the previous present before this one is queued.
|
||||
@@ -361,7 +364,7 @@ static void vk_be_present(const tex_t *t, const int crop[4], uint64_t at_ns) {
|
||||
uint64_t frame = ++game_frames;
|
||||
perf_present(frame);
|
||||
if (frame % 1800 == 0) replay_log(frame, 0);
|
||||
ReplayItem it = {.kind = RI_PRESENT, .tex = t, .at = at_ns, .queued = kern_now_ns()};
|
||||
ReplayItem it = {.kind = RI_PRESENT, .tex = t, .at = at_ns, .queued = kern_now_ns(), .pid = vk_reflex_frame()};
|
||||
if (crop) {
|
||||
it.has_crop = 1;
|
||||
for (int i = 0; i < 4; i++) it.crop[i] = crop[i];
|
||||
@@ -408,7 +411,7 @@ static void vk_be_program_release(const prog_t *p) { replay_drain(DR_PROG_RELEAS
|
||||
static uint64_t vk_be_submit(const uint64_t *handles, int n) {
|
||||
if (!gfx_replay_async()) return submit_sync(handles, n);
|
||||
vk_sync_start();
|
||||
ReplayItem it = {.kind = RI_SUBMIT, .n = n, .submit_no = nvn_submit_count()};
|
||||
ReplayItem it = {.kind = RI_SUBMIT, .n = n, .submit_no = nvn_submit_count(), .pid = vk_reflex_frame()};
|
||||
if (n > 0) {
|
||||
it.h = malloc(sizeof *it.h * (size_t)n);
|
||||
if (!it.h) rt_fatal("vk: out of memory (replay queue)");
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
// (is_gbuffer), lights it in half resolution, and then composites the lighting into that scene colour in one pass
|
||||
// whose only target is the scene colour, with a D16 depth that sorts pixels into material classes (is_composite).
|
||||
// When the pass after the composite begins, or a dispatch or copy comes first, runtime/shaders/contact_shadow.comp
|
||||
// marches each pixel a short way toward the sun through the linear depth and darkens the scene colour where the ray
|
||||
// passes behind nearby geometry: the small shadows at feet, under stones and in grass that the shadow maps are too
|
||||
// coarse for. Transparent surfaces, the sky and post-processing come after, untouched.
|
||||
// marches each pixel of a surface facing the sun (normal from the linear depth) a short way toward the sun through the
|
||||
// linear depth and darkens the scene colour where the ray passes behind nearby geometry: the small shadows at feet,
|
||||
// under stones and in grass that the shadow maps are too coarse for. Surfaces turned away from the sun are left alone:
|
||||
// they get no direct light to take away, and the colour the composite wrote already holds their ambient light and fog.
|
||||
// Transparent surfaces, the sky and post-processing come after, untouched.
|
||||
//
|
||||
// vk_contact_plan decides that in replay order and vk_contact_exec records it: a chunked replay's scan
|
||||
// plans the march (vk_exec.c scan_contact) and the chunk that holds its op records it.
|
||||
|
||||
+26
-2
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "memx.h"
|
||||
#include "vk.h"
|
||||
#include "platform/platform.h"
|
||||
#include "vk_dlaa.h"
|
||||
@@ -283,6 +284,7 @@ typedef struct {
|
||||
VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT fbl;
|
||||
VkPhysicalDeviceDynamicRenderingLocalReadFeaturesKHR lr;
|
||||
VkPhysicalDeviceAddressBindingReportFeaturesEXT abr;
|
||||
VkPhysicalDevicePresentIdFeaturesKHR pid;
|
||||
} FeatureChain;
|
||||
|
||||
static int create_device(void) {
|
||||
@@ -290,7 +292,7 @@ static int create_device(void) {
|
||||
vkEnumerateDeviceExtensionProperties(g_vk.phys, NULL, &ne, NULL);
|
||||
VkExtensionProperties *ep = calloc(ne ? ne : 1, sizeof *ep);
|
||||
vkEnumerateDeviceExtensionProperties(g_vk.phys, NULL, &ne, ep);
|
||||
const char *ext[48];
|
||||
const char *ext[52];
|
||||
uint32_t n_ext = 0;
|
||||
for (size_t i = 0; i < sizeof k_required_ext / sizeof *k_required_ext; i++) ext[n_ext++] = k_required_ext[i];
|
||||
|
||||
@@ -334,7 +336,7 @@ static int create_device(void) {
|
||||
CHAIN(fbl, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT);
|
||||
CHAIN(lr, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_LOCAL_READ_FEATURES_KHR);
|
||||
}
|
||||
vk_dlaa_device_exts(ep, ne, ext, &n_ext, 40); // NGX's; the eight slots after it stay for the seven below
|
||||
vk_dlaa_device_exts(ep, ne, ext, &n_ext, 40); // NGX's; the twelve slots after it stay for the nine below
|
||||
if (has_ext(ep, ne, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME)) { g_vk.has_memory_budget = 1; ext[n_ext++] = VK_EXT_MEMORY_BUDGET_EXTENSION_NAME; }
|
||||
// GPU timestamps on the CPU clock (vk_sync.c): the perf line splits GPU idle time into waiting for a submission or not.
|
||||
if (has_ext(ep, ne, VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME)) { g_vk.has_calibrated = 2; ext[n_ext++] = VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME; }
|
||||
@@ -351,6 +353,18 @@ static int create_device(void) {
|
||||
g_vk.has_nv_checkpoints = 1;
|
||||
ext[n_ext++] = VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME;
|
||||
}
|
||||
// NVIDIA Reflex Low Latency (VK_NV_low_latency2 requires VK_KHR_present_id)
|
||||
const char *rv = cfg_value("TOTK_REFLEX");
|
||||
if (rv && strcmp(rv, "off") != 0 && strcmp(rv, "0") != 0) {
|
||||
if (has_ext(ep, ne, VK_KHR_PRESENT_ID_EXTENSION_NAME) && has_ext(ep, ne, "VK_NV_low_latency2")) {
|
||||
g_vk.has_nv_reflex = 1;
|
||||
ext[n_ext++] = VK_KHR_PRESENT_ID_EXTENSION_NAME;
|
||||
ext[n_ext++] = "VK_NV_low_latency2";
|
||||
CHAIN(pid, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR);
|
||||
} else {
|
||||
rt_log("Reflex: VK_NV_low_latency2 not available");
|
||||
}
|
||||
}
|
||||
// Graphics pipeline library: chained last so it can be dropped again when vk_caps_gpl declines it.
|
||||
void **gpl_link = NULL;
|
||||
if (has_ext(ep, ne, VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME) && has_ext(ep, ne, VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME)) {
|
||||
@@ -387,11 +401,19 @@ static int create_device(void) {
|
||||
else if (!h->textureCompressionBC) miss = "textureCompressionBC";
|
||||
if (miss) { rt_log("vk: required feature missing on %s: %s", g_vk.props.deviceName, miss); free(c); return 0; }
|
||||
if (!c->fault.deviceFault) g_vk.has_device_fault = 0; // vkGetDeviceFaultInfoEXT needs the feature, not just the extension
|
||||
// Vulkan 1.3 requires the feature, and the chain goes to vkCreateDevice as the driver filled it, so it is enabled
|
||||
// wherever reported; vk_pipeline.c spirv_demote emits OpDemoteToHelperInvocation only when it is.
|
||||
vk_caps.demote = c->f13.shaderDemoteToHelperInvocation;
|
||||
rt_log("vk: GPU address map for device faults: %s",
|
||||
has_abr && c->abr.reportAddressBinding ? "on (VK_EXT_device_address_binding_report; TOTK_ADDR_REPORT=0 turns it off)"
|
||||
: !ab_want ? "off (TOTK_ADDR_REPORT=0 or no VK_EXT_debug_utils)"
|
||||
: "unavailable (no VK_EXT_device_address_binding_report)");
|
||||
g_vk.has_buffer_device_address = c->f12.bufferDeviceAddress;
|
||||
// VkPresentIdKHR on a present needs the presentId feature, not just the extension
|
||||
if (g_vk.has_nv_reflex && !c->pid.presentId) {
|
||||
g_vk.has_nv_reflex = 0;
|
||||
rt_log("Reflex: VK_NV_low_latency2 not available (no presentId feature)");
|
||||
}
|
||||
g_vk.has_astc_ldr = h->textureCompressionASTC_LDR;
|
||||
{
|
||||
const char *e = cfg_get("TOTK_FEEDBACK");
|
||||
@@ -479,6 +501,7 @@ long vk_validation_errors_total(void) { return g_errors_total + (g_ready ? g_vk.
|
||||
|
||||
int vk_init(void) {
|
||||
plat_mutex_lock(&g_lock);
|
||||
vk_memx_init();
|
||||
if (!g_ready) {
|
||||
memset(&g_vk, 0, sizeof g_vk);
|
||||
if (create_instance() && pick_device() && create_device())
|
||||
@@ -523,6 +546,7 @@ void vk_device_fault_report(VkResult r) {
|
||||
vk_crumbs_report();
|
||||
vk_pass_marks_report();
|
||||
vk_mem_fault_log();
|
||||
vk_exec_pool_journal_log();
|
||||
VkCtx *c = vk_ctx();
|
||||
PFN_vkGetDeviceFaultInfoEXT get =
|
||||
c && c->has_device_fault ? (PFN_vkGetDeviceFaultInfoEXT)vkGetDeviceProcAddr(c->device, "vkGetDeviceFaultInfoEXT")
|
||||
|
||||
+67
-10
@@ -294,6 +294,7 @@ static struct {
|
||||
unsigned cfg_seen; // cfg_version when preset was read
|
||||
uint64_t last_eval_ns; // plat_now_ns of the previous evaluation (FrameTimeDeltaInMsec)
|
||||
} D = {.mv_ok = -1, .cfg_seen = ~0u};
|
||||
#define DLSS_SIZES (sizeof D.sizes / sizeof D.sizes[0])
|
||||
|
||||
const VkTexImage *vk_dlaa_swap_img;
|
||||
VkImageView vk_dlaa_swap_view;
|
||||
@@ -941,6 +942,18 @@ static int perf_quality(uint32_t w, uint32_t ow) {
|
||||
return k >= 0.66 ? 2 : k >= 0.57 ? 1 : k >= 0.49 ? 0 : 3;
|
||||
}
|
||||
|
||||
// A target of the scene's shape (resolution.c's scene size, within 5 %; the dynamic resolution tiers keep it). In the
|
||||
// inventory the game renders the items' icons as the slots fill in, each through a G-buffer and a light target of its
|
||||
// own with a D32F depth, square (432x432 or 426x426 at a 3840x2160 scene) and with no wider G-buffer before it in the
|
||||
// frame; DLSS armed on that, scaled it to the output and wrote it over the menu, so a weapon filled the screen on the
|
||||
// frames an icon was drawn.
|
||||
static int scene_shaped(const VkExecTarget *c) {
|
||||
unsigned o[2], s[2];
|
||||
res_sizes(o, s);
|
||||
uint64_t a = (uint64_t)c->width * s[1], b = (uint64_t)c->height * s[0];
|
||||
return a * 20 >= b * 19 && b * 20 >= a * 19;
|
||||
}
|
||||
|
||||
// dst: the target DLSS's picture goes to, NULL for the light target itself (DLAA in place).
|
||||
static void evaluate(VkExec *ex, const VkExecTarget *dst) {
|
||||
const VkExecTarget *t = &D.color, *z = &D.depth;
|
||||
@@ -949,7 +962,7 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
|
||||
VkCommandBuffer cb = ex->cb;
|
||||
vk_exec_barrier(ex); // what drew the scene is done (no pass is open here)
|
||||
if (D.preset_dirty) { // another model: features are created with it, so every size gets a new one
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (size_t i = 0; i < DLSS_SIZES; i++)
|
||||
if (D.sizes[i].out) free_size(&D.sizes[i]);
|
||||
D.last = NULL, D.preset_dirty = 0;
|
||||
}
|
||||
@@ -1080,10 +1093,40 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
|
||||
(unsigned long long)D.why[2], (unsigned long long)R.made, (unsigned long long)R.missed);
|
||||
}
|
||||
|
||||
// More than half the scene size resolution.c set, on each side (the dynamic resolution tiers go down to 80 %). Around
|
||||
// the quick weapon menu the only G-buffer before the scene's end is at times the half-size one (1920x1080 at a
|
||||
// 3840x2160 scene), and the half-size RGBA16F effects target with its D32F depth armed; DLSS scaled the effects to the
|
||||
// output in place of the scene, which showed dark and blurred for that frame.
|
||||
static int scene_large(const VkExecTarget *c) {
|
||||
unsigned o[2], s[2];
|
||||
res_sizes(o, s);
|
||||
return c->width * 2 > s[0] && c->height * 2 > s[1];
|
||||
}
|
||||
|
||||
static int scene_color(VkFormat f) {
|
||||
return f == VK_FORMAT_B10G11R11_UFLOAT_PACK32 || f == VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
}
|
||||
|
||||
// The bloom chain's first pass: at most a quarter of the scene's width, into level 0 of a scene colour target. At some
|
||||
// views (seen in the yard of Lookout Landing) the game draws a full-screen pass without depth into the light target,
|
||||
// then a half-size scene colour target and its mips, and only then the light target with the scene depth. Level 1 of
|
||||
// those mips is a quarter of the scene's width; taken for the bloom it ended the scene before anything was armed, DLSS
|
||||
// skipped those frames, and the picture flickered between anti-aliased frames and plain ones as the view changed.
|
||||
// The pass also has the scene's shape (resolution.c's scene size, within 5 %) and no depth. In rain by a waterfall the
|
||||
// game drew two transparents into the light target with the scene depth before its sky lookups (25x25 and 256x256
|
||||
// RGBA16F) and its quarter-size particles (960x540 RGBA16F with a depth of their own), which then ended the armed
|
||||
// scene: DLSS ran before the mist and most transparents, which were drawn over its picture unprocessed, on runs of
|
||||
// frames, and the mist in the distance darkened or brightened for a frame wherever a frame in between came out whole.
|
||||
static int bloom_start(const VkExec *ex, uint32_t scene_w) {
|
||||
const VkExecTarget *c = &ex->color[0];
|
||||
if (!ex->pass_w || ex->pass_w * 4 > scene_w || !c->image || !scene_color(c->format) || c->level || ex->depth.image)
|
||||
return 0;
|
||||
unsigned o[2], s[2];
|
||||
res_sizes(o, s);
|
||||
uint64_t a = (uint64_t)ex->pass_w * s[1], b = (uint64_t)ex->pass_h * s[0];
|
||||
return a * 20 >= b * 19 && b * 20 >= a * 19;
|
||||
}
|
||||
|
||||
int vk_dlaa_plan(const VkExec *ex, VkExecJob *j) {
|
||||
const VkExecTarget *c = &ex->color[0], *z = &ex->depth;
|
||||
if (!dl_active() || D.done) return 0;
|
||||
@@ -1115,8 +1158,7 @@ int vk_dlaa_plan(const VkExec *ex, VkExecJob *j) {
|
||||
if (D.gbuf && !D.armed && !D.ended && !z->image && ex->pass_ncolor == 1 && c->image && scene_color(c->format) &&
|
||||
c->width >= D.gbuf_w && !c->level)
|
||||
D.nodepth = c->image;
|
||||
if (D.nodepth && !D.armed && !D.ended && ex->pass_w && ex->pass_w * 4 <= D.gbuf_w && c->image &&
|
||||
scene_color(c->format)) {
|
||||
if (D.nodepth && !D.armed && !D.ended && bloom_start(ex, D.gbuf_w)) {
|
||||
D.end_fence = ex->fence, D.end_pos = ex->pos;
|
||||
__atomic_store_n(&D.ended, 1, __ATOMIC_RELEASE);
|
||||
}
|
||||
@@ -1129,9 +1171,9 @@ int vk_dlaa_plan(const VkExec *ex, VkExecJob *j) {
|
||||
// first pair to arm; DLSS then scaled the effects into the light target, which filled the lens with garbage in the
|
||||
// DLAA mode.
|
||||
if (D.gbuf && !D.ended && ex->pass_ncolor == 1 && c->image && scene_color(c->format) && z->image && z->format == VK_FORMAT_D32_SFLOAT &&
|
||||
c->width == z->width && c->height == z->height && c->width >= DLAA_SCENE_MIN_W && c->width >= D.gbuf_w &&
|
||||
c->width == z->width && c->height == z->height && c->width >= DLAA_SCENE_MIN_W && c->width >= D.gbuf_w && scene_shaped(c) &&
|
||||
(!D.armed || (c->width >= D.color.width && c->height >= D.color.height)) &&
|
||||
c->samples <= 1 && !c->is3d) {
|
||||
c->samples <= 1 && !c->is3d && scene_large(c)) {
|
||||
int first = !D.armed;
|
||||
D.color = *c, D.depth = *z, D.armed = 1, D.nodepth = VK_NULL_HANDLE;
|
||||
if (!first) return 0;
|
||||
@@ -1140,11 +1182,11 @@ int vk_dlaa_plan(const VkExec *ex, VkExecJob *j) {
|
||||
}
|
||||
if (!D.armed) return 0;
|
||||
if (!D.ended) {
|
||||
// The bloom chain's first pass ends the scene: a pass at most a quarter of the scene's width into a scene
|
||||
// colour target. With the camera rune or the scope open the game draws a 160-wide depth-only pass and 160x90
|
||||
// RG16F and RGBA8 passes right after the lighting, then more geometry and the transparents; DLSS ended the
|
||||
// scene at those, the next G-buffer pass disarmed it and the scaling pass found nothing to evaluate.
|
||||
if (!ex->pass_w || ex->pass_w * 4 > D.color.width || !c->image || !scene_color(c->format)) return 0;
|
||||
// The bloom chain's first pass ends the scene (bloom_start). With the camera rune or the scope open the game
|
||||
// draws a 160-wide depth-only pass and 160x90 RG16F and RGBA8 passes right after the lighting, then more
|
||||
// geometry and the transparents; DLSS ended the scene at those, the next G-buffer pass disarmed it and the
|
||||
// scaling pass found nothing to evaluate.
|
||||
if (!bloom_start(ex, D.color.width)) return 0;
|
||||
D.end_fence = ex->fence, D.end_pos = ex->pos;
|
||||
__atomic_store_n(&D.ended, 1, __ATOMIC_RELEASE);
|
||||
unsigned o[2], s[2];
|
||||
@@ -1305,6 +1347,21 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) {
|
||||
}
|
||||
if (fxaa && !D.up) return 0; // nothing to skip: no shader lookup per draw at the defaults
|
||||
if (!fs) return 0;
|
||||
// 1.2.1 scales the light target to the output with an upscaler of its own (12 texelFetch taps around the source
|
||||
// pixel, fragment shader e6f7ae35b8479ef3 with this build's translator), not with the FXAA one, in a pass without
|
||||
// depth. It addresses its source in the scene's pixels (constant bank 3), so DLSS's output-sized picture swapped in
|
||||
// (tex_info) showed only its top-left part, the scene's share of the output (two thirds at DLSS quality), over
|
||||
// the whole screen (#1106). DLSS already wrote its picture into that pass's target
|
||||
// (evaluate), so on 1.2.1 a draw there that samples the light target is skipped instead; the HUD drawn later into
|
||||
// the same target samples other textures and stays. On 1.4.3 a tonemap can be the draw that scales (the comment
|
||||
// above struct D), and it keeps the swap.
|
||||
if (D.up && !RT_V143 && !ex->depth.image && vk_dlaa_swap_img && ex->pass_w > vk_dlaa_swap_img->width + 1 &&
|
||||
vk_exec_draw_samples(ex, fs, vk_dlaa_swap_img)) {
|
||||
static int logged;
|
||||
if (!logged) logged = 1, rt_log("dlaa: DLSS replaces the game's scaling draw (fragment shader %016llx)",
|
||||
(unsigned long long)spirv_hash(fs));
|
||||
return 1;
|
||||
}
|
||||
uint64_t h = spirv_hash(fs);
|
||||
int known = 0;
|
||||
for (size_t i = 0; i < sizeof FXAA_FS / sizeof FXAA_FS[0]; i++) known |= h == FXAA_FS[i];
|
||||
|
||||
+51
-4
@@ -136,6 +136,7 @@ static void state_reset(VkExec *ex) {
|
||||
vk_pipe_state_defaults(&ex->pipe);
|
||||
ex->barrier_at = -1;
|
||||
ex->oq_open = -1;
|
||||
vk_exec_dirty_all(ex);
|
||||
}
|
||||
|
||||
// ---- render targets
|
||||
@@ -410,6 +411,8 @@ void vk_exec_noatt_dims(const VkExec *ex, uint32_t *w, uint32_t *h) {
|
||||
static void resolve_rt_as(VkExec *ex, int peek) {
|
||||
if (ex->rt_resolved) return;
|
||||
ex->rt_resolved = 1;
|
||||
int32_t fmt0[8], ds0[2] = {ex->pipe.depth_fmt, ex->pipe.samples};
|
||||
memcpy(fmt0, ex->pipe.color_fmt, sizeof fmt0);
|
||||
const p_set_rt *r = &ex->rt;
|
||||
int n = r->n < 0 ? 0 : r->n > 8 ? 8 : r->n;
|
||||
uint32_t w = UINT32_MAX, h = UINT32_MAX, layers = UINT32_MAX, samples = 0, scale = 1;
|
||||
@@ -451,6 +454,8 @@ static void resolve_rt_as(VkExec *ex, int peek) {
|
||||
ex->pass_ncolor = (uint32_t)n;
|
||||
ex->pass_samples = samples ? samples : 1;
|
||||
ex->pipe.samples = (uint8_t)ex->pass_samples;
|
||||
if (memcmp(fmt0, ex->pipe.color_fmt, sizeof fmt0) || ds0[0] != ex->pipe.depth_fmt || ds0[1] != ex->pipe.samples)
|
||||
ex->pipe_gen++; // the pipeline's target formats changed
|
||||
}
|
||||
|
||||
static void resolve_rt(VkExec *ex) { resolve_rt_as(ex, 0); }
|
||||
@@ -528,15 +533,38 @@ static void tfr_note(const VkExecTarget *t, uint64_t stamp) {
|
||||
plat_mutex_lock(&tfr_lock);
|
||||
TargetFrames *e = tfr_find(t);
|
||||
if (!e) {
|
||||
e = tfr_set(t);
|
||||
// the way rendered longest ago, indexed from the set's start: the ways past the last set are RP's words
|
||||
TargetFrames *s = tfr_set(t);
|
||||
e = s;
|
||||
for (int i = 1; i < TFR_WAYS; i++)
|
||||
if (e[i].last < e->last) e = &e[i];
|
||||
if (s[i].last < e->last) e = &s[i];
|
||||
*e = (TargetFrames){t->image, t->level, t->base_layer, 0, 0};
|
||||
}
|
||||
if (e->last != stamp) e->prev = e->last, e->last = stamp;
|
||||
plat_mutex_unlock(&tfr_lock);
|
||||
}
|
||||
|
||||
// --probe-vkexec: a new target noted into a full set takes the way rendered longest ago, and the set after it keeps
|
||||
// its entries. The ways are stamped so that a search stepping from the way it picked last would leave the set. 1 when
|
||||
// it holds; the two sets are cleared afterwards.
|
||||
int vk_exec_tfr_check(void) {
|
||||
VkExecTarget t[TFR_WAYS + 1];
|
||||
for (int n = 0, k = 1; n <= TFR_WAYS; k++) {
|
||||
t[n] = (VkExecTarget){.image = (VkImage)(uintptr_t)k};
|
||||
n += tfr_set(&t[n]) == tfr[0];
|
||||
}
|
||||
static const uint64_t last[TFR_WAYS] = {8, 7, 100, 6, 100, 100, 5, 100};
|
||||
TargetFrames next[TFR_WAYS];
|
||||
for (int i = 0; i < TFR_WAYS; i++) tfr[0][i] = (TargetFrames){t[i].image, 0, 0, last[i], 0};
|
||||
memcpy(next, tfr[1], sizeof next);
|
||||
tfr_note(&t[TFR_WAYS], 200);
|
||||
plat_mutex_lock(&tfr_lock);
|
||||
int ok = tfr_find(&t[TFR_WAYS]) == &tfr[0][6] && !memcmp(next, tfr[1], sizeof next);
|
||||
plat_mutex_unlock(&tfr_lock);
|
||||
memset(tfr, 0, sizeof tfr[0] * 2);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int tfr_recent(const VkExecTarget *t, uint64_t stamp) {
|
||||
plat_mutex_lock(&tfr_lock);
|
||||
const TargetFrames *e = tfr_find(t);
|
||||
@@ -626,6 +654,7 @@ static void barrier_to(VkExec *ex, const VkImage *want, const VkImageAspectFlags
|
||||
for (int i = 0; i < nwant; i++)
|
||||
if (!has_image(ex->fbl_img, ex->nfbl, want[i]))
|
||||
ib[n++] = layout_barrier(want[i], wasp[i], VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT);
|
||||
if (n || nwant != ex->nfbl) ex->fbl_serial++; // the images in the feedback layout changed
|
||||
for (int i = 0; i < nwant; i++) ex->fbl_img[i] = want[i], ex->fbl_aspect[i] = wasp[i];
|
||||
ex->nfbl = nwant;
|
||||
if (ex->barrier_at == ex->recorded && !n) return;
|
||||
@@ -903,6 +932,13 @@ static void maybe_split(VkExec *ex) {
|
||||
n_parts++;
|
||||
}
|
||||
|
||||
// --probe-vkexec: a split every `draws` draws between passes, parts of at least `us` (0: no minimum); the parts made
|
||||
// so far.
|
||||
uint64_t vk_exec_split_set(int draws, int us) {
|
||||
split_n = draws, split_ns = us > 0 ? (uint64_t)us * 1000 : 0;
|
||||
return n_parts;
|
||||
}
|
||||
|
||||
// The fixed-function state ops: writes into ex alone, applied by the replay and the state scan. 0: not one of them.
|
||||
static int state_op(VkExec *ex, uint32_t op, const void *a) {
|
||||
switch (op) {
|
||||
@@ -944,8 +980,16 @@ static int state_op(VkExec *ex, uint32_t op, const void *a) {
|
||||
memcpy(ex->blend_color, ((const p_blend_color *)a)->rgba, sizeof ex->blend_color);
|
||||
ex->dirty |= VK_EXEC_DIRTY_BLEND_CONST;
|
||||
break;
|
||||
case OP_DEPTH_CLAMP: ex->pipe.depth_clamp = ((const p_flag *)a)->value != 0; break;
|
||||
case OP_RASTER_DISCARD: ex->pipe.raster_discard = ((const p_flag *)a)->value != 0; break;
|
||||
case OP_DEPTH_CLAMP: {
|
||||
uint8_t v = ((const p_flag *)a)->value != 0;
|
||||
if (ex->pipe.depth_clamp != v) ex->pipe.depth_clamp = v, ex->pipe_gen++;
|
||||
break;
|
||||
}
|
||||
case OP_RASTER_DISCARD: {
|
||||
uint8_t v = ((const p_flag *)a)->value != 0;
|
||||
if (ex->pipe.raster_discard != v) ex->pipe.raster_discard = v, ex->pipe_gen++;
|
||||
break;
|
||||
}
|
||||
case OP_PRIM_RESTART: ex->prim_restart = *(const p_prim_restart *)a; break;
|
||||
case OP_COPY_STRIDE: ex->copy_stride = ((const p_copy_stride *)a)->stride; break;
|
||||
case OP_SET_TEX_POOL: ex->tex_pool = ((const p_set_pool *)a)->pool, ex->tex_serial++; break;
|
||||
@@ -1147,6 +1191,7 @@ static void *grow_n(void *p, uint32_t *cap, size_t elem) {
|
||||
|
||||
static void copy_state(VkExec *dst, const VkExec *src) {
|
||||
memcpy((char *)dst + VK_EXEC_STATE_BEGIN, (const char *)src + VK_EXEC_STATE_BEGIN, VK_EXEC_STATE_END - VK_EXEC_STATE_BEGIN);
|
||||
vk_exec_dirty_all(dst); // the bound state was replaced: no draw memo may take it for what it held
|
||||
}
|
||||
|
||||
static int draw_op(uint32_t op) { return op == OP_DRAW || op == OP_DRAW_IDX || op == OP_DRAW_IDX_IND; }
|
||||
@@ -1313,6 +1358,7 @@ static void chunk_record(Rec *r, int k) {
|
||||
const Chunk *next = k + 1 < __atomic_load_n(&SC.nch, __ATOMIC_ACQUIRE) ? &SC.ch[k + 1] : NULL;
|
||||
ex->cb = rec_cb(r, RP.fence);
|
||||
ex->fence = RP.fence, ex->recorded = 0, ex->in_pass = 0, ex->nviews = 0, ex->barrier_at = -1, ex->nfbl = 0;
|
||||
ex->fbl_serial++;
|
||||
ex->part_start = 0;
|
||||
x_cur = ex;
|
||||
chunk_k = k;
|
||||
@@ -1678,6 +1724,7 @@ int vk_exec_record(VkCommandBuffer cb, const uint64_t *handles, int n, uint64_t
|
||||
ex->nviews = 0;
|
||||
ex->barrier_at = -1;
|
||||
ex->nfbl = 0; // the previous command buffer ended with a full barrier: every image is in GENERAL
|
||||
ex->fbl_serial++;
|
||||
ex->fr.submits++;
|
||||
ex->split_draws = ex->part_start = 0;
|
||||
ex->part_t0 = kern_now_ns();
|
||||
|
||||
+30
-1
@@ -1,3 +1,14 @@
|
||||
// What the bind ops changed in a context's bound slots since its last prepared draw (VkExec.dirt, TOTK_BIND_INC in
|
||||
// vk_exec_draw.c): a bit per slot, per NVN stage, set only when the bytes an op writes differ from those it replaces.
|
||||
typedef struct {
|
||||
uint32_t prog; // the program pointer or its stage mask
|
||||
uint32_t ubo[6]; // uniform slots 0..17 (OP_BIND_UBO index)
|
||||
uint32_t ssbo[6]; // storage slots 0..15
|
||||
uint64_t tex[6][2]; // texture handles 0..127
|
||||
uint32_t img[6]; // image handles 0..31
|
||||
uint32_t vbuf; // vertex buffer ranges 0..15
|
||||
} VkExecDirty;
|
||||
|
||||
// The op-stream replay of the Vulkan back end. vk_exec.c walks the command
|
||||
// handles of a submission, keeps render targets, passes, clears and fixed-function state; draws, binds and dispatches
|
||||
// (vk_exec_draw.c) and copies, counters, events and conditional rendering (vk_exec_xfer.c) plug in through the two
|
||||
@@ -110,7 +121,7 @@ typedef struct VkExec {
|
||||
const dpool_t *tex_pool, *samp_pool; // OP_SET_TEX_POOL, OP_SET_SAMP_POOL
|
||||
// Pipeline inputs. vk_exec.c writes depth_clamp (OP_DEPTH_CLAMP), raster_discard (OP_RASTER_DISCARD) and, at pass
|
||||
// begin, color_fmt, depth_fmt and samples; vk_exec_draw.c owns every other field (shaders, prim, y_flip, state
|
||||
// objects, vertex input).
|
||||
// objects, vertex input). Every write that changes it bumps pipe_gen.
|
||||
VkPipeState pipe;
|
||||
|
||||
// ---- vk_exec_draw.c slots (draws, binds, dispatch): left empty by vk_exec.c
|
||||
@@ -148,6 +159,14 @@ typedef struct VkExec {
|
||||
const void *fb_fs; // feedback_scan's memo: fragment shader, texture bind serial, pass serial
|
||||
uint32_t fb_serial, fb_pass, fb_sampled;
|
||||
uint32_t tex_serial, pass_serial; // bumped by every texture or image bind and pass begin
|
||||
// TOTK_BIND_INC (vk_exec_draw.c): the slots the bind ops changed since this context's last prepared draw, cleared
|
||||
// by that draw; vk_exec_draw_new_cb and copy_state set every bit. pipe_gen: bumped by every write that changes
|
||||
// pipe (the state object and vertex input binds, OP_DEPTH_CLAMP, OP_RASTER_DISCARD, the target formats of
|
||||
// resolve_rt, copy_state); an equal value says pipe holds what it held then. fbl_serial: bumped whenever the images
|
||||
// in the feedback layout (fbl_img, nfbl) may have changed. Outside the copied state: each context counts its own.
|
||||
VkExecDirty dirt;
|
||||
uint64_t pipe_gen;
|
||||
uint32_t fbl_serial;
|
||||
|
||||
// ---- vk_exec_xfer.c: the occlusion query of the open pass and the queries closed since the last report or reset
|
||||
int oq_open; // slot of the active query, -1 none
|
||||
@@ -195,6 +214,15 @@ void vk_exec_inline_end(int reopen);
|
||||
// vk_exec_draw.c: forget what the command buffer being recorded has bound (pipeline, sets, dynamic state, vertex
|
||||
// buffers): the replay continues in a new one (vk_sync_split).
|
||||
void vk_exec_draw_new_cb(VkExec *ex);
|
||||
// Everything a context's next draw reads may differ from its last prepared draw's (VkExec.dirt, pipe_gen, fbl_serial):
|
||||
// its bound state was replaced or its command buffer state lost.
|
||||
static inline void vk_exec_dirty_all(VkExec *ex) {
|
||||
__builtin_memset(&ex->dirt, 0xff, sizeof ex->dirt);
|
||||
ex->pipe_gen++, ex->fbl_serial++;
|
||||
}
|
||||
// vk_exec_draw.c: the fragment stage of the draw being recorded samples img through one of its bound combined
|
||||
// textures (OP_BIND_TEX, the handles tex_info swaps; vk_dlaa.c vk_dlaa_skip_draw). Takes the texture lock.
|
||||
int vk_exec_draw_samples(VkExec *ex, const GfxShader *fs, const VkTexImage *img);
|
||||
// The recording threads of the chunked replay as this run read TOTK_REPLAY_WORKERS (0 off), -1 before the first
|
||||
// submission read it (the settings menu shows it).
|
||||
int vk_exec_replay_workers(void);
|
||||
@@ -219,6 +247,7 @@ void vk_exec_noatt_dims(const VkExec *ex, uint32_t *w, uint32_t *h); // pass s
|
||||
int vk_exec_targets_recent(VkExec *ex, int any);
|
||||
// The current pass's targets with their formats, extents and the frames they were last rendered in (diagnostics).
|
||||
void vk_exec_targets_describe(VkExec *ex, char *buf, size_t cap);
|
||||
int vk_exec_tfr_check(void); // --probe-vkexec: a new target replaces a way of its own set; 1 when it does
|
||||
|
||||
extern VkExecFrame vk_exec_frame;
|
||||
void vk_exec_frame_written(const tex_t *t); // vk_texture_gpu_written: t rendered or copied into
|
||||
|
||||
+927
-82
File diff suppressed because it is too large.
Load diff
@@ -455,6 +455,86 @@ static int test_marks(const GfxBackend *b, pool_t *pool, tex_t *color, prog_t *g
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---- set batch part: SB_SUBMITS submissions in a row, none waited for, each of SB_PASSES passes of SB_DRAWS draws
|
||||
// whose viewport, and so the support buffer of every set, changes from draw to draw: each draw writes a new
|
||||
// allocated set (set 1 with independent layouts), which TOTK_BIND_INC takes from batches (vk_exec_draw.c
|
||||
// alloc_set_batched). A split after every 3 draws between passes (vk_exec.c maybe_split), the recorder on (its
|
||||
// default), and empty submissions from a second thread as the present thread makes them. A set bound after its pool
|
||||
// was reset is a validation error ("Invalid VkDescriptorSet", with TOTK_VK_VALIDATION=1); a pool with two owners is
|
||||
// a line of vk_exec_draw.c's descriptor pool journal. On a GTX 1050 Ti it was a lost device. Skipped where no draw allocates its sets in batches.
|
||||
#define SB_SUBMITS 60
|
||||
#define SB_PASSES 4
|
||||
#define SB_DRAWS 6
|
||||
|
||||
uint64_t vk_exec_split_set(int draws, int us); // vk_exec.c
|
||||
void vk_exec_draw_counts(uint64_t *batches, int *stale, uint64_t *journal); // vk_exec_draw.c
|
||||
int vk_exec_pool_journal_selftest(void); // vk_exec_draw.c
|
||||
|
||||
static volatile int sb_stop;
|
||||
static volatile int32_t sb_empty;
|
||||
static int sb_batches, sb_parts, sb_skipped, sb_validated;
|
||||
|
||||
static void sb_present(void *arg) {
|
||||
(void)arg;
|
||||
while (!__atomic_load_n(&sb_stop, __ATOMIC_ACQUIRE)) {
|
||||
vk_sync_submit(NULL, 0);
|
||||
plat_inc32(&sb_empty);
|
||||
plat_sleep_ns(200000);
|
||||
}
|
||||
}
|
||||
|
||||
static int test_batches(const GfxBackend *b, prog_t *prog, const pool_t *pool, tex_t *color) {
|
||||
static _Alignas(8) uint8_t stream[16384];
|
||||
uint64_t batches0, journal0;
|
||||
int stale0;
|
||||
vk_exec_draw_counts(&batches0, &stale0, &journal0);
|
||||
long errors0 = vk_validation_errors_total();
|
||||
uint64_t parts0 = vk_exec_split_set(3, 0);
|
||||
sb_stop = 0;
|
||||
PlatThread *t = plat_thread_new(sb_present, NULL, "probe present");
|
||||
CHECK(t, "no thread for the empty submissions");
|
||||
uint64_t f = 0;
|
||||
for (int s = 0; s < SB_SUBMITS; s++) {
|
||||
uint8_t *q = draw_prefix(stream, prog, pool, color);
|
||||
for (int p = 0; p < SB_PASSES; p++) {
|
||||
for (int d = 0; d < SB_DRAWS; d++) {
|
||||
p_viewports vp;
|
||||
memset(&vp, 0, sizeof vp);
|
||||
vp.n = 1, vp.v[0][2] = (float)(TEX_W - (s * SB_PASSES * SB_DRAWS + p * SB_DRAWS + d) % 97), vp.v[0][3] = TEX_H;
|
||||
vp.v[0][5] = 1.0f;
|
||||
q = put(q, OP_VIEWPORTS, &vp, sizeof vp);
|
||||
const p_draw dr = {NVN_DRAW_PRIMITIVE_TRIANGLES, 0, 3, 0, 0};
|
||||
q = put(q, OP_DRAW, &dr, sizeof dr);
|
||||
}
|
||||
const p_barrier bar = {0, 0};
|
||||
q = put(q, OP_BARRIER, &bar, sizeof bar);
|
||||
}
|
||||
q = put(q, OP_END, NULL, 0);
|
||||
CHECK(q <= stream + sizeof stream, "set batch op stream overflow");
|
||||
uint64_t handle = (uint64_t)(uintptr_t)stream;
|
||||
f = b->submit(&handle, 1); // the replay records it before submit returns: the stream is free again
|
||||
}
|
||||
__atomic_store_n(&sb_stop, 1, __ATOMIC_RELEASE);
|
||||
plat_thread_join(t);
|
||||
CHECK(b->fence_wait(f, 20000000000ull), "fence_wait of the last set batch submission timed out");
|
||||
b->finish();
|
||||
int split_us = cfg_int("TOTK_SPLIT_US");
|
||||
sb_parts = (int)(vk_exec_split_set(cfg_int("TOTK_SPLIT_DRAWS") > 0 ? cfg_int("TOTK_SPLIT_DRAWS") : 0, split_us) - parts0);
|
||||
uint64_t batches, journal;
|
||||
int stale;
|
||||
vk_exec_draw_counts(&batches, &stale, &journal);
|
||||
long errors = vk_validation_errors_total() - errors0;
|
||||
CHECK(!errors && stale == stale0, "%ld validation errors and %d doubly owned descriptor pool lines (vk_exec: ...) over %d "
|
||||
"submissions of batched sets", errors, stale - stale0, SB_SUBMITS);
|
||||
// Each submission that drew made a CbRes and took at least one pool, and the pools of the earlier ones were reset.
|
||||
CHECK(journal - journal0 >= 2 * SB_SUBMITS, "the descriptor pool journal took %llu events over %d submissions",
|
||||
(unsigned long long)(journal - journal0), SB_SUBMITS);
|
||||
sb_batches = (int)(batches - batches0), sb_validated = vk_ctx()->validation != 0;
|
||||
sb_skipped = !sb_batches;
|
||||
CHECK(sb_skipped || sb_parts >= SB_SUBMITS, "%d parts over %d submissions: the replay did not split", sb_parts, SB_SUBMITS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_draw(const GfxBackend *b, uint8_t *guest, int *n_drawn, int *n_tries, int *n_cs) {
|
||||
char root[PLAT_PATH_MAX * 2], path[PLAT_PATH_MAX * 2 + 64];
|
||||
CHECK(probe_census_dir(root, sizeof root), "no build/v%d/shaders/jobs.json above the exe (run tools/shader_census.py)",
|
||||
@@ -602,6 +682,9 @@ static int test_draw(const GfxBackend *b, uint8_t *guest, int *n_drawn, int *n_t
|
||||
ind_dispatches++;
|
||||
}
|
||||
if (test_marks(b, &pool, &color, hit, cs_prog)) return 1;
|
||||
if (test_batches(b, hit, &pool, &color)) return 1;
|
||||
int conflicts = vk_exec_pool_journal_selftest();
|
||||
CHECK(conflicts == 2, "the descriptor pool owner check found %d of 2 conflicts", conflicts);
|
||||
b->texture_release(&color);
|
||||
b->pool_fini(&pool);
|
||||
free(pairs), free(cs), free(e), free(jobs);
|
||||
@@ -966,6 +1049,8 @@ int probe_vkexec(void) {
|
||||
layouts_equal = 0;
|
||||
main_tid = plat_thread_id();
|
||||
const GfxBackend *b = &gfx_vulkan_backend;
|
||||
CHECK(vk_exec_tfr_check(), "a target noted into a full set of the target history did not take that set's oldest way");
|
||||
printf("probe-vkexec: target history part passed (a new target replaces the oldest way of its own set)\n");
|
||||
uint64_t heap = 0;
|
||||
CHECK(mem_set_heap_size(16ull << 20, &heap) == 0 && heap, "SetHeapSize 16 MiB");
|
||||
// Out-of-memory waits (oom.c): the first two staging buffers, the first texture image and the first draw-data chunk
|
||||
@@ -1041,9 +1126,25 @@ int probe_vkexec(void) {
|
||||
else
|
||||
printf("probe-vkexec: pass marks part passed (pass, dispatch, pass in one submission: the GPU's last started and "
|
||||
"finished mark is the last pass, ring records exact); the report reads:\n%s\n", marks_text);
|
||||
if (sb_skipped)
|
||||
printf("probe-vkexec: set batch part skipped (no draw allocated its descriptor sets in batches: TOTK_BIND_INC off "
|
||||
"or every set pushed)\n");
|
||||
else
|
||||
printf("probe-vkexec: set batch part passed (%d submissions of %d draws, each writing a new set: %d batches, %d "
|
||||
"parts, %d empty submissions from a second thread, no stale pool, %s)\n",
|
||||
SB_SUBMITS, SB_PASSES * SB_DRAWS, sb_batches, sb_parts, sb_empty,
|
||||
sb_validated ? "0 validation errors" : "validation layer off: TOTK_VK_VALIDATION=1 checks the binds");
|
||||
printf("probe-vkexec: empty pool part passed (a zero-byte pool at the start of another: no Vulkan objects, lookups "
|
||||
"there find the other pool before and after its Finalize)\n");
|
||||
printf("probe-vkexec: out-of-memory part passed (2 failed staging buffers waited for, 1 failed texture image retried, "
|
||||
"1 failed draw-data chunk waited for)\n");
|
||||
printf("probe-vkexec: pool owner part passed (a pool handed to a second CbRes and reset by one that no longer held it: "
|
||||
"2 conflicts logged with the journal)\n");
|
||||
// The device loss report on a working device, as a device loss calls it: breadcrumbs, pass marks, deferred frees and
|
||||
// the descriptor pool journal must come out without a crash. Last: the report runs once per process.
|
||||
printf("probe-vkexec: device loss report follows (a test: the device is not lost)\n");
|
||||
fflush(stdout);
|
||||
vk_device_fault_report(VK_ERROR_DEVICE_LOST);
|
||||
printf("probe-vkexec: device loss report part passed\n");
|
||||
return 0;
|
||||
}
|
||||
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user