// The Insert menu. Drawn with Dear ImGui over the window's image at the last step of a present (menu_record; vk_imgui.h, in the // game's style: vk_ui.h), so it costs nothing while closed and it never touches the game's picture, nor what frame interpolation // sees. The FPS counter and the start-up screen are drawn the same way. F1 always opens and closes it, Insert too by default. // Up and Down choose, Left and Right change, Esc closes; the game gets no keyboard input while it is open. // (hookshot) A gamepad's Home button, or Select and Start together, opens it too; the D-pad chooses and changes, the button // the Switch's A is bound to changes too (and opens a page), the one B is bound to goes back (vk_menu_keys.h). The game gets no gamepad input while it is open either. // Its Controls page binds the Switch's buttons to gamepad inputs and keys. // (hookshot) The mouse is free while it is open (the window lets it go: WM_APP + 8, host/display.c and // host/posix/display_sdl.c): the row under the cursor is selected, a click on a tab shows it, on a value's left or right // half changes it down or up, on a toggle flips it, on a slider's track sets it (or drag it); the wheel scrolls the rows // (never a value, wherever the cursor is); a right click is Esc. On the Cheats page and its lists a click is Enter (on a // choice's or an amount's left or right half, Left or Right) and a right click goes back. The drawing records each control's // place and the mouse is tested against that (vk_menu_hit.h). // (hookshot) The rows that take a restart (Row::restart) are tagged "After restart" while their value is not the one the game // started with, and the Graphics tab's help lists them. Closing the menu then asks whether to restart now (menu_restart.h): // Later keeps the saved settings for the next start and is not asked again until they change; Restart now saves and // closes the window as the player would, and the game starts again (WM_APP + 9: host/hos_relaunch.c). // (Triforce, 11-10) The menu is drawn as the game's own Options screen (SystemOption_00 of its layout archive): the System // screens' header with the options' categories across it as the pause menu has its own (Display, Graphics, Audio, Controls, // System; L and R, Q and E), the rows on the game's plates in its list column, the caption plate at the right, the guides at // the foot, in the game's fonts and with its button icons (vk_ui.h, vk_game_tex.h, vk_imgui.cpp: all read from the player's // game files at run time). The Debug tab is always shown (11-15, the owner: "make debug on by default and remove the alt+g // shortcut"; Alt+G unlocked it before). The Menu size row is gone: the game's menus have one size. The FPS counter is a HUD counter (the // HUD's own digits, no plate). tests/ui_preview.cpp draws all of it into pictures without the game. #include #include #include #include #include #include #include #include #include #include // ((Triforce) the name pages' read of the game's files) #include #include "vk_dlssg.h" #include "vk_pace.h" // (Triforce: who holds the frames, for the rows that hand them to another limiter) #include "vk_bugshot.h" // (Triforce: a bug capture's picture, taken before the overlays are drawn) #include "vk_paths.h" #include "vk_menu.h" #include "vk_menu_hit.h" #include "vk_draw.h" // (pipeline_cache_save: Restart now keeps what was built) #include "oot_cheat_items.h" #include "debug_names.h" // ((Triforce) the Debug tab's name pages: their lists, and oot_debug_link.h's lines) #include "debug_tab_layout.h" // ((Triforce) the Debug tab's cells' widths) #include "debug_pending.h" // ((Triforce) the Inventory's change waiting for the game) #include "vk_progress.h" // (StartupView, version_text: the start-up screen) #if __has_include("vk_startup_draw.h") // (the shader-screen branch's file: with it the start-up screen is its drawing) #include "vk_startup_draw.h" // (the start-up screen's drawing: draw_startup_screen) #endif #include "vk_ui.h" #include "vk_menu_keys.h" // (which gamepad buttons confirm and go back: those A and B are bound to) // (how it looks: Dear ImGui, vk_imgui.h) #include "vk_dlss.h" #include "vk_fsr3.h" // (the Upscaler row: whether AMD FSR 3.1 runs on this GPU) #include "vk_fsr3fi.h" // (the Frame generation row: whether FSR 3.1 makes the frame) #include "vk_fsr4.h" #include "vk_temporal.h" #include "vk_fsr3_inputs.h" // (Triforce: the render size while AMD FSR 3.1 draws, for the performance overlay) #include "perf_stats.h" // (Triforce: the performance overlay's frame times) #include "perf_machine.h" // (Triforce: and the machine's numbers, sampled on a thread of their own) #include "vk_renodx.h" // (renodx_built: the RenoDX rows only in a build with its shaders) #include "vk_reflex.h" #include "vk_antilag.h" #include "upscaler_rows.h" #include "aa_rows.h" // (Triforce, the Anti-aliasing row: its choices, and when it does not apply) #include "vk_aa.h" // (...RX_VK_AA over it, and whether the game's pass was there to replace) #include "tex_detail.h" // (the Texture detail row: the levels' names, RX_VK_TEX_DETAIL) #include "fps_cap.h" // (the Game frame rate cap row's Monitor's rate) #include "ultrawide_rows.h" // ((Triforce) the Ultrawide row's shapes, and its old Monitor's shape read before options_version 6) #include "present_mode.h" // (the VSync row: what its choice comes to on this driver) #include "game_language.h" // (the Game language row: what language.txt chooses and offers) #include "menu_restart.h" #include "mod_cheat_rows.h" // (Triforce: the System tab's rows for the cheats of the mods' cheat files) #include "menu_sound_events.h" // (Triforce: the options' own sounds: which one a tick asks for, and their queue to the host) #include "vk_mods.h" // (Triforce: the Mods page's engine, GameBanana's list and the installs) #include "vk_salesman.h" // (Triforce: the Happy Mask Salesman beside the cards) #include "imgui_internal.h" // (RegisterUserTexture: the mods' pictures) #include "ini_merge.h" // ((Triforce, handoff ยง9) the options file's lines merged by key with a change made outside the game) #include "file_whole.h" // (and the file written whole: file_writers::write_whole) #include "vk_work.h" // (after the others: counts the commands that do GPU work, for full_barrier) #ifndef HOOKSHOT_VERSION // (nx2/build.py gives it to this file: nx2/version.py) #define HOOKSHOT_VERSION "unknown" #endif namespace mkwvk { HWND app_window(); int texture_detail_auto(); // (vk_texture.cpp: what the video memory gives this card, -1 before the first texture) int display_refresh_mhz(); // (vk_main.cpp: the window's display, mHz; 0 when not known) int swapchain_present_mode(); // (vk_main.cpp: the swapchain's present mode, present_mode.h's numbers; -1 none) // ((Triforce) the performance overlay on Full: the rendering GPU's LUID (vk_main.cpp), the GPU's time in the recordings and their // uploads so far (vk_replay.cpp), the textures uploaded so far (vk_texture.cpp), whether frame generation makes frames now // (vk_framegen.cpp)) bool gpu_device_luid(uint8_t out[8]); int64_t gpu_time_busy_ns(); void texture_stats(int64_t* uploads, int64_t* astc_gpu, int64_t* bytes_uploaded); bool framegen_on(); Options opts; namespace { // (Triforce) The tabs across the Options screen's header, as the pause menu's categories: a kind of option each. Debug is the // last, always shown (debug_shown) enum MenuTab { TAB_DISPLAY = 0, TAB_GRAPHICS = 1, TAB_AUDIO = 2, TAB_CONTROLS = 3, TAB_SYSTEM = 4, TAB_DEBUG = 5, // (the OoT debug tools of #785 and the developer's rows, a tab of their own) TAB_COUNT = 6, TAB_MOTION = TAB_COUNT, // (hookshot: not a tab of the strip, the Motion page that the Controls tab's Motion row // opens: one past the strip's tabs, so a tab added before TAB_COUNT moves it along) TAB_PAGE = TAB_MOTION + 1 // (hookshot: the Controls page's rows, above its grid; no tab shows them) }; struct Row { MenuTab tab; const char* name; int* value; int lo, hi, step; const char* (*text)(int v); const char* help; // (shown under the list while the row is selected: what the row is, the same whatever its value) // (a line about the value chosen, under the help, or nullptr: hint(v, -1) is the one to show now for v, hint(v, 0), // hint(v, 1), ... every one v can have (those that depend on the other rows or on the GPU), until nullptr, so the // menu keeps the height of the tallest: measure_help) const char* (*hint)(int v, int variant) = nullptr; bool restart = false; // (read once, at the start: a change applies after a restart) bool preset_exempt = false; // (a change here leaves the Quality preset alone: the controls, the window, the counter, // frame generation) signed char cheat = -1; // (a debug tool, on the Debug tab with the tools on: its index in the cheat_ tables, -1 none) bool heading = false; // (a section's title on its tab, not a row: the selection steps over it) }; /// A row's hints from a table, the value lo first (nullptr: none for that value) const char* hint_in(const char* const* t, int n, int lo, int v, int variant) { return variant <= 0 && v - lo >= 0 && v - lo < n ? t[v - lo] : nullptr; } #define MENU_HINTS(fn, lo, ...) \ const char* fn(int v, int variant) { \ static const char* const t[] = {__VA_ARGS__}; \ return hint_in(t, (int)(sizeof t / sizeof t[0]), lo, v, variant); \ } const char* tx_framegen(int v) { // (Triforce: the last is AMD's frame generation library, vk_fsr4.h fsr4fg. A saved AMD FSR 4 on a PC where the library // cannot make the frames shows what runs there, 2x: framegen_rows.h shown) static const char* t[] = {"Off", "Auto", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "AMD FSR 4"}; return t[std::clamp(framegen_rows::shown(v, fsr4fg::offered_known()), 0, (int)framegen_rows::kRowMax)]; // ((Triforce) as known: menu_ahead) } const char* tx_onoff(int v) { return v ? "On" : "Off"; } const char* tx_dlssg(int v) { return v == 1 ? "2x" : v == 2 ? "3x" : v == 3 ? "4x" : "Off"; } /// (what runs in this session, or why not: vk_dlssg.cpp. Variant 0 stands for the longest line, for the menu's height) const char* hn_dlssg(int v, int variant) { if (variant > 0) return nullptr; if (variant == 0) return "Not on this graphics card or driver: it needs an RTX 40 or 50 card."; if (!v) return "Off."; return mkwvk::dlssg::asked() ? mkwvk::dlssg::status() : "Starts with the next start of the game."; } /// (Triforce) The Reflex frame limit row: what holds the frames now. Variant 0 stands for the longest line /// (Triforce) RivaTuner Statistics Server, where it holds the frames, is the limiter whatever this row says (vk_pace.cpp) const char* hn_reflex_limit(int v, int variant) { static const char* const off = "The game's own wait holds every frame, or RivaTuner where it is the game's limiter."; static const char* const none = "DLSS frame generation does not run in this session: the game's own wait holds every frame."; static const char* const rtss = "RivaTuner Statistics Server holds the frames now, and Reflex is given no limit."; if (variant > 0) return nullptr; if (variant == 0) return none; if (v && mkwvk::pace::owner() == mkwvk::pace::RTSS) return rtss; return !v ? off : mkwvk::dlssg::active() ? "Reflex holds the frames while they are generated." : none; } const char* tx_menu_shortcut(int v) { static const char* const names[] = {"Insert or F1", "F1 only"}; // (F1 is never turned off: the menu is always one key away) return names[v ? 1 : 0]; } const char* tx_hdr(int v) { return v == 1 ? "Expanded" : v == 2 ? "Native" : "Off"; } // ((Triforce, 11-16) "Native", the owner's word) const char* tx_nits(int v) { static char b[24]; snprintf(b, sizeof b, "%d nits", v); return b; } static_assert(fps_cap::kMonitor == 6, "the Game frame rate cap row's last value is Monitor's rate"); const char* tx_fps_cap(int v) { static const char* const t[] = {"60 (the console's)", "90", "120", "144", "165", "240"}; if (v < 0) return v == -1 ? "45" : v == -2 ? "40" : "30"; // (Triforce: the limits under 60, host/nn_vi.c fps_max) if (v >= fps_cap::kMonitor) { // (Triforce: Monitor's rate, with what this display gives now: fps_cap.h, as the host asks it) static char b[32]; const int cap = fps_cap::of_display(display_refresh_mhz()); if (!cap) return "Monitor's rate"; snprintf(b, sizeof b, "Monitor's rate (%d)", cap); return b; } return t[v]; } // (Triforce) The Steady frame rate row (host/pace_steady.h's PACE_STEADY_*) const char* tx_steady_fps(int v) { return v == 1 ? "Any rate" : v == 2 ? "Refresh steps" : "Off"; } // (Triforce) The VSync row (opts.vsync; present_mode.h has what On and Off ask for): the line under its help says what the // choice came to on this driver, by the present mode of the swapchain there is, or which switch decides for the run. // Variants (every one): each mode the value can come to, then the two switches const char* hn_vsync(int v, int variant) { static const char* const on[] = { "Each frame waits for the screen's next refresh: no tearing.", "The newest finished frame at each refresh of the screen: no tearing, and nothing held back.", "This driver has no tear-free mode that does not hold the frame rate down: frames are shown at once, as with Off.", }; static const char* const off[] = { "This graphics driver cannot show frames at once here: as On.", "This graphics driver cannot show frames at once here: as On.", "Each frame is shown the moment it is ready: a little less delay, and the picture can tear.", }; static const char* const fifo_env = "Set for this run by RX_VK_FIFO: each frame waits for the screen's next refresh."; static const char* const immediate_env = "RX_VK_IMMEDIATE asks for frames shown at once in this run, whatever is chosen here."; if (variant < 0) { static const bool fifo = getenv("RX_VK_FIFO") != nullptr, immediate = getenv("RX_VK_IMMEDIATE") != nullptr; if (fifo || immediate) return fifo ? fifo_env : immediate_env; const int mode = swapchain_present_mode(); if (mode < present_mode::kFifo || mode > present_mode::kImmediate) return nullptr; // (no swapchain: nothing to say) return (v ? on : off)[mode]; } if (variant <= present_mode::kImmediate) return (v ? on : off)[variant]; return variant == 3 ? fifo_env : variant == 4 ? immediate_env : nullptr; } // (hookshot) Motion controls: the choice, and whether a connected controller has a gyroscope (host/pad_sdl.c). Either can be // chosen whatever is connected: a pad plugged in later is read when it comes const char* tx_gyro(int v) { const int status = host && host->gyro_status ? host->gyro_status() : -1; if (status == 2) return v ? "On (gyro found)" : "Off (gyro found)"; if (status == 1) return v ? "On (no gyro on this pad)" : "Off (no gyro on this pad)"; if (status == 0) return v ? "On (no controller)" : "Off (no controller)"; return v ? "On" : "Off"; } const char* tx_mousecam(int v) { return v ? "Native" : "As the stick"; } const char* tx_sens(int v) { static char b[12]; snprintf(b, sizeof b, "%.2f", v / 100.0); return b; } // (the game's picture and the window it is shown in, as the last present had them: menu_note_present_sizes) std::atomic present_sizes{0}; bool filter_needed() { const uint64_t v = present_sizes.load(std::memory_order_relaxed); return upscaler_rows::filter_needed((unsigned)(v >> 48), (unsigned)(v >> 32) & 0xffff, (unsigned)(v >> 16) & 0xffff, (unsigned)v & 0xffff); } const char* tx_upscale(int v) { static const char* t[] = {"Off", "Catmull-Rom", "Lanczos", "AMD FSR 1"}; if ((unsigned)v >= sizeof t / sizeof t[0]) return t[0]; // (a setting past the row: the label, not the next bytes) return t[v]; } /// The Window scaling filter row's value: its filter, or that none is needed (the saved value stays, for another window size) const char* tx_filter(int v) { return filter_needed() ? tx_upscale(v) : "Not needed (window = output)"; } const char* tx_reflex(int v) { static const char* t[] = {"Off", "On", "On + Boost"}; // ((Triforce, 11-16: the owner saw Off and "not available" with DLSS frame generation on an NVIDIA card) With DLSS frame // generation Reflex is Streamline's and always on (vk_dlssg.cpp reflex_apply): its Off shows On, Boost as chosen if (mkwvk::dlssg::reflex_on()) return t[std::clamp(v, 1, 2)]; return t[reflex_available() ? std::clamp(v, 0, 2) : 0]; } /// Reflex: on the value, that it runs through Streamline with DLSS frame generation, or that it is not available here (the /// row shows Off) const char* hn_reflex(int v, int variant) { static const char* const t[] = {"The game as without it.", "The driver paces the frames for less latency.", "As On, and the GPU's clocks are kept up as well."}; static const char* const none = "Not available here: it needs an NVIDIA GPU whose driver has VK_NV_low_latency2."; static const char* const sl = "With DLSS frame generation Reflex runs through NVIDIA Streamline and stays on, as frame " "generation needs it. On + Boost keeps the GPU's clocks up as well."; if (variant < 0) return mkwvk::dlssg::reflex_on() ? sl : reflex_available() ? t[std::clamp(v, 0, 2)] : none; return variant == 0 ? t[std::clamp(v, 0, 2)] : variant == 1 ? none : variant == 2 ? sl : nullptr; } const char* tx_antilag(int v) { return antilag_available() && v ? "On" : "Off"; } /// Anti-Lag 2: on the value, or that it is not available here (the row shows Off) const char* hn_antilag(int v, int variant) { static const char* const t[] = {"The game as without it.", "The driver delays each frame's start for less latency."}; static const char* const none = "Not available here: it needs an AMD GPU whose driver has VK_AMD_anti_lag."; if (variant < 0) return antilag_available() ? t[v ? 1 : 0] : none; return variant == 0 ? t[v ? 1 : 0] : variant == 1 ? none : nullptr; } // The Upscaler (opts.dlss): what scales the 3D up to the output. DLSS and DLAA only where dlss_why() lets them run, FSR 3.1 // only where vk_fsr3.cpp says it does, FSR 4 and its native AA only where fsr4_why() does; the menu shows (and steps from) // what runs, and keeps the saved choice for a PC where it can namespace ur = upscaler_rows; /// One bit per upscaler that runs here (upscaler_rows.h bit). Each backend caches its own answer, so this costs nothing unsigned upscalers_available() { return ur::bit(ur::GAME) | ur::dlss_bits(dlss_why() == DLSS_OK) | ur::fsr3_bits(fsr3::supported()) | ur::fsr4_bits(fsr4_why() == FSR_OK); } /// (FSR 3.1 has inputs of its own, at the Render resolution's mode or as its Native AA; DLSS and FSR 4 run on the frame /// chain they share, temporal_mode) int upscaler() { return fsr3_wanted() ? (int)(fsr3_native() ? ur::FSR3_AA : ur::FSR3) : temporal_mode(); } const char* tx_upscaler(int) { static const char* t[ur::kUpscalers] = {"Game", "NVIDIA DLSS", "NVIDIA DLAA", "AMD FSR 3.1", "AMD FSR 4", "AMD FSR 4 Native AA", "AMD FSR 3.1 Native AA"}; return t[std::clamp(upscaler(), 0, ur::kUpscalers - 1)]; } /// The Upscaler: the one shown (what runs, upscaler()), and with the game's own, why DLSS and FSR are not offered. Variants /// (every one): each value, then the game's own with each of DLSS's reasons, then with each of FSR's const char* hn_upscaler(int v, int variant) { static const char* const t[ur::kUpscalers] = { "The game's own network.", "NVIDIA's, from a smaller 3D. Softer than the game's own: set Sharpness to around 80%. Things that move by " "themselves can trail for now.", "NVIDIA's, the 3D at full size with its edges smoothed; the slowest. Softer than the game's own: set Sharpness to " "around 80%. Things that move by themselves can trail for now.", "AMD's, from a smaller 3D, on any GPU: built from AMD's own shaders. Things that move by themselves can trail for " "now.", "AMD's machine-learned upscaler, from a smaller 3D, with AMD's files beside the game. Things that move by themselves " "can trail for now.", "AMD's machine-learned upscaler, the 3D at full size with its edges smoothed; the slowest.", "AMD's, the 3D at full size with its edges smoothed, on any GPU: built from AMD's own shaders. Slower than FSR 3.1 " "from a smaller 3D; the 3D takes its full size at the next start. Things that move by themselves can trail for now.", }; static const char* const dlss_no[DLSS_WHY_COUNT] = { nullptr, "DLSS and DLAA: not in this build (built without NVIDIA's DLSS SDK, see the readme).", "DLSS and DLAA: off for this run (RX_VK_DLSS=0).", "DLSS and DLAA: need an NVIDIA RTX GPU.", "DLSS and DLAA: need a newer NVIDIA driver.", "DLSS and DLAA: DLSS's runtime was not found (the game folder's ngx folder, see the readme).", "DLSS and DLAA: NVIDIA's NGX on Linux loads DLSS's runtime only from a folder named in ASCII (see the readme).", "DLSS and DLAA: NVIDIA's NGX started but gave DLSS nothing to work with (see the log).", }; static const char* const fsr_no[FSR_WHY_COUNT] = { nullptr, "AMD FSR 4: not in this build (see the readme).", "AMD FSR 4: off for this run (RX_VK_FSR4=0).", "AMD FSR 4: AMD's files were not found beside the game (see the readme).", "AMD FSR 4: AMD's files have no FSR 4 for this GPU.", }; // (now: the value shown and what runs here, with both engines' reasons; every one: as said above) int d = 0, f = 0; if (variant < 0) { v = std::clamp(upscaler(), 0, ur::kUpscalers - 1), d = (int)dlss_why(), f = (int)fsr4_why(); } else if (v == ur::GAME) { if (variant < DLSS_WHY_COUNT) d = variant; else if (variant < DLSS_WHY_COUNT + FSR_WHY_COUNT - 1) f = variant - DLSS_WHY_COUNT + 1; else return nullptr; } else if (variant > 0) { return nullptr; } v = std::clamp(v, 0, ur::kUpscalers - 1); // (the reasons are said only where the engine is in the build: one without FSR does not tell an NVIDIA user why) const char* dn = dlss_built() || variant >= 0 ? dlss_no[d] : nullptr; const char* fn = fsr4_built() || variant >= 0 ? fsr_no[f] : nullptr; if (v != ur::GAME || (!dn && !fn)) return t[v]; static char b[DLSS_WHY_COUNT][FSR_WHY_COUNT][320]; snprintf(b[d][f], sizeof b[d][f], "%s%s%s%s%s", t[0], dn ? " " : "", dn ? dn : "", fn ? " " : "", fn ? fn : ""); return b[d][f]; } /// The DLSS model row (opts.dlss_model): NVIDIA's network by its preset, or RX_VK_DLSS_PRESET's for this run const char* dlss_preset_env() { static const char* const e = getenv("RX_VK_DLSS_PRESET"); return ur::preset_env(e) ? e : nullptr; } const char* tx_dlss_model(int v) { static const char* const t[] = {"Transformer (K)", "Transformer 2 (M)", "Transformer 2 (L)", "NVIDIA default"}; if (const char* e = dlss_preset_env()) { static char b[48]; const unsigned p = ur::dlss_preset(v, e); if (p) snprintf(b, sizeof b, "Preset %c (RX_VK_DLSS_PRESET)", ur::preset_letter(p)); else snprintf(b, sizeof b, "NVIDIA default (RX_VK_DLSS_PRESET)"); return b; } return t[std::clamp(v, 0, ur::kModels - 1)]; } /// The DLSS model: the value chosen; variant 1: the game's own upscales (the row waits for DLSS or DLAA); variant 2: set for /// this run by RX_VK_DLSS_PRESET const char* hn_dlss_model(int v, int variant) { static const char* const t[] = { "NVIDIA's transformer model: the one tested most here.", "NVIDIA's second-generation transformer, its pick for Performance: sharper, at a little more GPU time.", "The second-generation transformer as NVIDIA tuned it for Ultra Performance, the smallest Render resolutions.", "Lets DLSS's runtime pick for each mode: what it picks can change with a runtime update.", }; static const char* const unused = "Used by NVIDIA DLSS and DLAA: choose one in the Upscaler row."; static const char* const env = "Set for this run by RX_VK_DLSS_PRESET."; if (variant < 0) variant = dlss_preset_env() ? 2 : upscaler() == ur::GAME ? 1 : 0; if (variant == 1) return unused; if (variant == 2) return env; return variant == 0 ? t[std::clamp(v, 0, ur::kModels - 1)] : nullptr; } const char* tx_aniso(int v) { // (Triforce: the Texture filtering row) static const char* t[] = {"Game", "2x", "4x", "8x", "16x"}; // ((Triforce, 11-16) "Game", the owner's word) if ((unsigned)v >= sizeof t / sizeof t[0]) return t[0]; return t[v]; } // (Triforce) The Texture detail row (opts.tex_detail, tex_detail.h): Automatic is the card's own level by its video memory, // which the row says once the first texture was made; RX_VK_TEX_DETAIL goes over the row for a run int tex_detail_env() { static const int e = tex_detail::parse(getenv("RX_VK_TEX_DETAIL")); return e; } const char* tx_tex_detail(int v) { static const char* const t[] = {"Automatic", "Full", "Reduced", "Low"}; static const char* const picked[] = {"Automatic (Full)", "Automatic (Reduced)", "Automatic (Low)"}; if ((unsigned)v >= sizeof t / sizeof t[0]) v = 0; const int here = texture_detail_auto(); return v == 0 && here >= 0 && here <= 2 ? picked[here] : t[v]; } /// The Texture detail: the value chosen; variant 1: set for this run by RX_VK_TEX_DETAIL const char* hn_tex_detail(int v, int variant) { static const char* const t[] = { "By this graphics card's video memory: Full from 12 GB (never on integrated graphics), Reduced on 8 and 10 GB cards, " "Low under that. The value shows what it gives here.", "Every texture whole. On a card with less than 12 GB the video memory can run out, and the frame rate then falls to a " "fraction.", "The game's large textures at half their size each way, a quarter of their video memory. Text, icons and the HUD stay " "whole.", "As Reduced, and the largest textures at a quarter of their size each way.", }; static const char* const env[] = {"Full for this run (RX_VK_TEX_DETAIL=full), whatever is chosen here.", "Reduced for this run (RX_VK_TEX_DETAIL=reduced), whatever is chosen here.", "Low for this run (RX_VK_TEX_DETAIL=low), whatever is chosen here."}; if (variant < 0) variant = tex_detail_env() >= 0 ? 1 + tex_detail_env() : 0; if (variant == 0) return t[(unsigned)v < sizeof t / sizeof t[0] ? v : 0]; return variant <= 3 ? env[variant - 1] : nullptr; } /// (Triforce) Opaque textures as BC1 (opts.tex_bc1, tex_bc1.h): nothing about the value itself; variants 0 and 1: /// RX_VK_TEX_BC1 decides for this run, off or on const char* hn_tex_bc1(int, int variant) { static const char* const t[] = {"Off for this run (RX_VK_TEX_BC1=0), whatever is chosen here.", "On for this run (RX_VK_TEX_BC1), whatever is chosen here."}; if (variant < 0) { static const char* const e = getenv("RX_VK_TEX_BC1"); return !e || !*e ? nullptr : t[atoi(e) != 0]; } return variant < 2 ? t[variant] : nullptr; } const char* tx_percent(int v) { static char b[8]; snprintf(b, sizeof b, "%d%%", v); return b; } // (local, RenoDX port: vk_renodx.cpp) const char* tx_rdx_tonemap(int v) { return v == 2 ? "RenoDRT" : v ? "PsychoV35" : "Vanilla"; } // (Triforce: RenoDRT) const char* tx_rdx_gamma(int v) { return v == 1 ? "2.2" : v == 2 ? "BT.1886 (2.4)" : "Off"; } // (Triforce) const char* tx_rdx_midgray(int v) { return v == 1 ? "Vanilla" : v == 2 ? "Eye adaptation" : "Render"; } const char* tx_rdx_space(int v) { return v == 1 ? "BT.709" : v == 2 ? "DCI-P3" : "Vanilla"; } const char* tx_rdx_grade(int v) { static char b[8]; snprintf(b, sizeof b, "%d", v); return b; } // The output the menu's sizes are shown for: the Output resolution row's (applied at the next start), so the rows below follow a change // at once; the handheld profile runs the game's own (1536x864) struct Out { uint32_t w, h; }; // ((Triforce, 11-16, the owner: "Add a resolution of 5120x2160 before 5120x2880") 6 is 5120x2160, after the others so that the // saved numbers keep their sizes; kOutputOrder shows it between 5120x1440 and 5120x2880) constexpr Out kOutputs[] = {{2048, 1152}, {2560, 1440}, {3840, 2160}, {1920, 1080}, {5120, 1440}, {5120, 2880}, {5120, 2160}}; constexpr int kLastOutput = std::size(kOutputs) - 1; int output_choice(int v) { return v >= 0 && v <= kLastOutput ? v : 0; } // Display the sizes from smallest to largest while keeping the IDs used by saved settings. constexpr int kOutputOrder[] = {3, 0, 1, 2, 4, 6, 5}; static_assert(std::size(kOutputOrder) == std::size(kOutputs)); int step_output_choice(int id, int dir) { const int* pos = std::find(std::begin(kOutputOrder), std::end(kOutputOrder), output_choice(id)); const int next = std::clamp((int)(pos - std::begin(kOutputOrder)) + dir, 0, kLastOutput); return kOutputOrder[next]; } Out shown_output() { return opts.handheld ? Out{1536, 864} : kOutputs[output_choice(opts.output_res)]; } // The size the game draws the 3D at for a fixed scale of its output, a twelfth of it: every twelfth asked came out exact at the three // outputs (2048x1152: 0.58 drew 1195x672, 0.6667 1366x768). So the scale the game is given is the twelfth too: 0.67 drew 2615x1471 at // 3840x2160, not the 2560x1440 of 8/12. int twelfths(float scale) { return std::min(std::max((int)(scale * 12.0f + 0.5f), 1), 12); } void game_size(float scale, uint32_t& w, uint32_t& h) { const Out o = shown_output(); const int k = twelfths(scale); w = (o.w * k + 11) / 12, h = o.h * k / 12; } const char* tx_resolution(int v) { static char b[48]; const int up = upscaler(); if (up == ur::DLAA) return "Native (DLAA)"; if (up == ur::FSR4_AA) return "Native (FSR 4)"; if (up == ur::FSR3_AA) return "Native (FSR 3.1)"; if (!ur::percent(v)) return "Auto (dynamic)"; if (const char* mode = ur::scales_by_mode(up) ? ur::dlss_mode_name(v) : nullptr) { snprintf(b, sizeof b, "%s (%d%%)", mode, ur::percent(v)); return b; } uint32_t w, h; game_size(ur::percent(v) / 100.0f, w, h); snprintf(b, sizeof b, "%d%% (%ux%u)", ur::percent(v), w, h); return b; } /// The Render resolution: the value chosen, for the Upscaler shown (every one: each value with each Upscaler) const char* hn_resolution(int v, int variant) { const int up = variant < 0 ? std::clamp(upscaler(), 0, ur::kUpscalers - 1) : variant; if (up >= ur::kUpscalers) return nullptr; if (up == ur::DLAA) return "DLAA draws the 3D at full size: nothing to set here. Choose DLSS or the game's own upscaler to draw it " "smaller."; if (up == ur::FSR4_AA) return "FSR 4's native AA draws the 3D at full size: nothing to set here. Choose FSR 4 or the game's own upscaler " "to draw it smaller."; if (up == ur::FSR3_AA) return "FSR 3.1's native AA draws the 3D at full size: nothing to set here. Choose FSR 3.1 or the game's own " "upscaler to draw it smaller."; const int p = ur::percent(v); if (up == ur::DLSS) { switch (p) { case 0: return "The game lowers it when the GPU is busy, and DLSS follows. Set Sharpness to around 80%."; case 67: return "DLSS's sharpest mode. Set Sharpness to around 80%."; case 58: return "Between Quality and Performance. Set Sharpness to around 80%."; case 50: return "Faster, and softer. Set Sharpness to around 80%."; case 33: return "DLSS's fastest mode, and its softest. Set Sharpness to around 80%."; default: return nullptr; // (not one of DLSS's steps: the row moves to one) } } if (up == ur::FSR3 || up == ur::FSR4) { // (the same modes, AMD's ratios) switch (p) { case 0: return "The game lowers it when the GPU is busy, and FSR follows."; case 67: return "FSR's Quality mode, 1.5x: its sharpest."; case 58: return "FSR's Balanced mode, 1.7x."; case 50: return "FSR's Performance mode, 2x: faster, and softer."; case 33: return "FSR's Ultra Performance mode, 3x: its fastest, and its softest."; default: return nullptr; // (not one of FSR's steps: the row moves to one) } } if (!p) return "The game lowers it when the GPU is busy."; if (p == 100) return "The 3D at the output's full size: the sharpest, and the slowest."; return "A steady size: lower is faster, and softer."; } /// (Triforce) The Anti-aliasing row (aa_rows.h, vk_aa.h): its choice, RX_VK_AA's for the run over it; while DLSS or FSR /// draws, whose anti-aliasing the picture has instead const char* tx_aa(int v) { const int up = upscaler(); if (ur::is_dlss(up)) return "DLSS's own"; if (aa_rows::upscaler_own(up)) return "FSR's own"; return aa_rows::name(aa_rows::chosen(v, aa_env_choice())); } /// The Anti-aliasing: the value chosen (variant 0); that it does not apply while NVIDIA DLSS or DLAA (1) or AMD FSR (2) /// draws; that RX_VK_AA set it for this run (3); that the game's pass was not there to replace (4) const char* hn_aa(int v, int variant) { static const char* const t[aa_rows::kValues] = { "The game's own SMAA, as on the console.", "None: the 3D's edges as they were drawn. The sharpest, with stair steps on edges and shimmer on thin things.", "FXAA in place of the game's SMAA: a fast smoothing of the finished 3D's edges, a little softer on fine detail.", "SMAA at its highest preset in place of the game's own: long and diagonal edges smoother, for more GPU time."}; static const char* const own[2] = { "NVIDIA DLSS and DLAA smooth the 3D's edges themselves: nothing to set here. The choice is kept for the game's own " "upscaler.", "AMD FSR smooths the 3D's edges itself: nothing to set here. The choice is kept for the game's own upscaler."}; static const char* const env = "Set for this run by RX_VK_AA, whatever is chosen here."; static const char* const missing = "No frame of the last minute had the game's own anti-aliasing pass to replace (a screen without the 3D, or another " "version of the game): the picture is the game's."; if (variant < 0) { const int up = upscaler(); const bool asked = aa_rows::chosen(v, aa_env_choice()) != aa_rows::GAME; variant = ur::is_dlss(up) ? 1 : aa_rows::upscaler_own(up) ? 2 : asked && aa_state() == aa_rows::MISSING ? 4 : aa_env_choice() >= 0 ? 3 : 0; } switch (variant) { case 0: return t[v >= 0 && v < aa_rows::kValues ? v : 0]; case 1: return own[0]; case 2: return own[1]; case 3: return env; case 4: return missing; default: return nullptr; } } /// A row with nothing else to choose here: shown without its arrows, Left and Right leave it (and the saved value) alone bool row_fixed(const int* value) { return (value == &opts.reflex && !reflex_available() && !mkwvk::dlssg::reflex_on()) || (value == &opts.antilag && !antilag_available()) || (value == &opts.aa && aa_rows::fixed(upscaler(), aa_env_choice() >= 0)) || (value == &opts.dlss && ur::upscaler_fixed(upscalers_available())) || (value == &opts.resolution && ur::resolution_fixed(upscaler())) || (value == &opts.upscale && !filter_needed()) || (value == &opts.dlss_model && ur::model_fixed(upscaler(), dlss_preset_env() != nullptr)); } const char* tx_output_res(int v) { static char b[32]; v = output_choice(v); const Out o = kOutputs[v]; snprintf(b, sizeof b, "%ux%u", o.w, o.h); // ((Triforce, 11-16) the size alone; the hint says which is the game's own) return b; } const char* tx_speed(int v) { return v ? "Real time" : "Per frame"; } const char* tx_text_speed(int v) { static const char* t[] = {"Normal", "2x", "4x", "Instant"}; if ((unsigned)v >= sizeof t / sizeof t[0]) return t[0]; return t[v]; } const char* tx_ultrawide(int v) { // (Triforce: 1 to 3, the fixed shapes, ultrawide_rows.h; host/hos_main.c ultrawide_ratio) static const char* const t[] = {"16:9", "16:10", "21:9", "32:9"}; return t[std::min(std::max(v, 0), 3)]; } const char* tx_wide_hud(int v) { return v ? "Screen edges" : "Middle"; } const char* tx_prompts(int v) { static const char* t[HOS_PROMPT_N + 1] = {"Auto", "Switch", "Xbox", "PlayStation 4", "PlayStation 5", "Steam Deck", "Keyboard & mouse"}; return t[std::min(std::max(v, 0), (int)HOS_PROMPT_N)]; } const char* tx_gpu(int v) { static char buf[300]; const int idx = v - 1; if (v <= 0) snprintf(buf, sizeof buf, "Auto"); else if (idx < (int)gpu_device_names.size()) snprintf(buf, sizeof buf, "%d: %s", idx, gpu_device_names[idx].c_str()); else snprintf(buf, sizeof buf, "%d: Device %d", idx, idx); // (the whole name shows: the selected row slides through it, see marquee_pos) return buf; } const char* tx_pad_layout(int v); // (hookshot) the Microphone row: Off, the system's default, or one of the host's microphones (host/nn_audio_in.c: the // ocarina's input streams), told to the host by its name (host->mic_select) whenever it changes. The chosen one is kept by // its name, mic_want, also while it is unplugged: the row then has one more entry for it, " (not connected)", the // host lets the default stand in and opens it again once it is back, and the name stays in the ini. In the ini the name is // cut to kMicNameKept bytes (at a character's start), so the line fits the 80-byte readers of the file (host/nn_hid.c, // nn_applet.c, hos_main.c), and a name is matched by that much of it constexpr int kMaxMics = 16; constexpr size_t kMicNameKept = 60; std::string mic_want; // (the chosen microphone's name, cut to kMicNameKept; empty: Off or the default chosen) bool mic_missing = false; // (mic_want is not plugged in: the row's last entry, 2 + mic_listed, stands for it) int mic_listed = 0; // (the microphones as the host last listed them) bool can_mic() { return host && host->mic_count && host->mic_name && host->mic_select; } size_t text_char_start(const std::string& text, size_t at) { while (at > 0 && at < text.size() && ((unsigned char)text[at] & 0xc0) == 0x80) at--; return at; } std::string mic_key(const char* name) { std::string k(name ? name : ""); for (char& c : k) // (a device's name goes into triforce_options.ini: a line break in it would add lines there) if ((unsigned char)c < 0x20 || c == 0x7f) c = ' '; if (k.size() > kMicNameKept) k = k.substr(0, text_char_start(k, kMicNameKept)); // (and no spaces at the end: a saved line's end, made one above, and those an older build saved with the name) while (!k.empty() && k.back() == ' ') k.pop_back(); return k; } /// buf cut back to whole UTF-8 characters (snprintf may have cut one) void utf8_whole(char* buf) { size_t n = strlen(buf), i = n; while (i > 0 && ((unsigned char)buf[i - 1] & 0xC0) == 0x80) i--; // (the last character's continuation bytes) if (i == 0) return; const unsigned char lead = (unsigned char)buf[i - 1]; const size_t want = lead >= 0xF0 ? 4 : lead >= 0xE0 ? 3 : lead >= 0xC0 ? 2 : 1; if (n - (i - 1) < want) buf[i - 1] = 0; } const char* tx_mic(int v) { static char buf[160]; if (v <= 0) return "Off"; if (v == 1) return "Default"; if (mic_missing && v == 2 + mic_listed) { const int room = (int)sizeof buf - (int)sizeof " (not connected)"; snprintf(buf, (size_t)room + 1, "%s", mic_want.c_str()); utf8_whole(buf); strcat(buf, " (not connected)"); return buf; } const char* n = can_mic() ? host->mic_name(v - 2) : ""; snprintf(buf, sizeof buf, "%s", n && *n ? n : "Microphone"); utf8_whole(buf); return buf; } /// The Microphone row: Off, the default, a microphone of the list, or the chosen one while it is unplugged (variant 1) const char* hn_mic(int v, int variant) { if (v <= 0) return variant <= 0 ? "The game hears silence." : nullptr; if (v == 1) return variant <= 0 ? "The system's default recording device. On Windows, desktop apps must be allowed to use the " "microphone (Settings, Privacy & security)." : nullptr; const bool missing = variant < 0 ? mic_missing && v == 2 + mic_listed : variant == 1; if (variant > 1) return nullptr; return missing ? "Not plugged in: Default stands in until it is back." : "This microphone, by its name. A change applies at once."; } // (Triforce) The Game language row. The game's language is the host's to read, once, at the start: language.txt in the // game folder (host/nn_applet.c desired_language), which Setup writes at a build and which lists the game's languages; // HOS_LANGUAGE goes over it for a run. The row's entries are the languages that file names (game_language.h), and a choice // is written back into the file as its choice line, everything else in it as it was (lang_store, at each save). It is not // kept in triforce_options.ini. No row while the file is not there or names nothing to choose from namespace gl = game_language; int lang_entries[gl::kCount]; // (the row's entries: places in gl::kLanguages, in its order) int lang_count = 0; int lang_saved = -1; // (the entry language.txt chooses now: as read at the start, or as last written) bool lang_failed = false; // (the last choice could not be written: the row is back on the file's) const char* tx_language(int v) { return lang_count > 0 ? gl::kLanguages[lang_entries[std::min(std::max(v, 0), lang_count - 1)]].name : ""; } /// The Game language: nothing about the value itself; variant 0: HOS_LANGUAGE decides for this run; variant 1: the choice /// could not be written const char* hn_language(int, int variant) { static const char* const env = "This run's language is set by HOS_LANGUAGE. The choice here is for runs without it."; static const char* const failed = "language.txt in the game folder could not be written: the language stays as it was."; if (variant < 0) { static const bool by_env = getenv("HOS_LANGUAGE") != nullptr; return lang_failed ? failed : by_env ? env : nullptr; } return variant == 0 ? env : variant == 1 ? failed : nullptr; } const char* tx_rumble(int v) { return v ? tx_percent(v) : "Off"; } const char* tx_volume(int v) { return v ? tx_percent(v) : "Muted"; } const char* tx_menu_sounds(int v) { return v ? tx_percent(v) : "Off"; } // (Triforce: the Menu sounds row) const char* tx_sprint(int v) { return v == 1 ? "Left stick click" : v == 2 ? "B" : "Off"; } const char* tx_sprint_mode(int v) { return v ? "Hold" : "Toggle"; } // (hookshot) Menu size: how large the overlays are drawn (vk_ui.h unit); Auto is Large in fullscreen at 1080 lines and up while // a controller is the menu's input, else Medium bool pad_last = false; // (a controller was the menu's last input: its buttons in the prompts) // (Auto's choice: the controller or not, decided as the menu opens by the input that opened it. A controller's input makes it // Large at any time; the keys and the mouse never make it smaller while the menu is open, so it never changes size under the // cursor) bool auto_pad = false; int pad_confirm = 0, pad_back = 1; // (the face buttons that confirm and go back, HOS_PAD_*: menu_keys::confirm_back, each tick) bool auto_large(uint32_t h) { return opts.fullscreen && h >= 1080 && auto_pad; } const char* tx_menu_size(int v) { static const char* t[] = {"Auto", "Small", "Medium", "Large"}; if (v == 0) return auto_large(dev.swap_extent.height) ? "Auto (Large)" : "Auto (Medium)"; return (unsigned)v < 4 ? t[v] : t[0]; } const char* tx_stick_dead_zone(int v) { static const char* t[] = {"Default (24%)", "5%", "10%", "15%", "20%", "30%"}; return (unsigned)v < 6 ? t[v] : t[0]; } // (Triforce) a stick's own dead zone: none of its own (the Stick dead zone row's), or 0% to 50% const char* tx_own_dead_zone(int v) { return v < 0 ? "As Stick dead zone" : tx_percent(v); } // (Triforce) the Walk key row's keys, in host/nn_hid.c walk_key_code's order const char* tx_walk_key(int v) { static const char* t[] = {"Off", "Caps Lock", "Shift", "Ctrl", "Tab"}; return (unsigned)v < 5 ? t[v] : t[0]; } // (hookshot) Audio output: the speakers the game mixes for, read once at its start (host/nn_audio.c au_menu_output) const char* tx_audio_output(int v) { static const char* t[] = {"Auto", "Stereo", "5.1"}; return (unsigned)v < 3 ? t[v] : t[0]; } // (hookshot) the motion's deadzone: the console's three zero-drift modes, the rate under which the pad counts as still const char* tx_deadzone(int v) { static const char* t[] = {"Low", "Standard", "High"}; return t[v < 0 ? 0 : v > 2 ? 2 : v]; } const char* tx_robust(int v) { static const char* t[] = {"Auto", "Off", "On"}; return (unsigned)v < 3 ? t[v] : t[0]; } const char* tx_mesh(int v) { return v == 1 ? "Compute fallback" : "Auto"; } // ((Triforce, 11-18) opts.mesh_mode, vk_main.cpp) // (Triforce) The Debug tab's Replay helper threads row (opts.replay_threads; vk_replay.cpp par_threads_max): Off, or the // parallel replay tried on 2 to 8 threads as RX_VK_PARALLEL_AUTO= does. The switches go over the row for a run const char* replay_threads_env() { static const char* const e = getenv("RX_VK_PARALLEL") ? "RX_VK_PARALLEL" : getenv("RX_VK_PARALLEL_AUTO") ? "RX_VK_PARALLEL_AUTO" : nullptr; return e; } const char* tx_replay_threads(int v) { // (Triforce: 8, Automatic, is the count replay_threads.h gives this PC, tried as the fixed counts are) static const char* const t[] = {"Off", "Auto, 2 threads", "Auto, 3 threads", "Auto, 4 threads", "Auto, 5 threads", "Auto, 6 threads", "Auto, 7 threads", "Auto, 8 threads", "Automatic"}; static_assert(replay_threads_of(1) == 2 && replay_threads_of(7) == 8 && !replay_threads_of(0) && !replay_threads_of(8)); static_assert(replay_threads::kRowAutomatic == 8 && replay_threads::of_row(8, 3) == 3 && replay_threads::of_row(7, 3) == 8); return t[(unsigned)v < sizeof t / sizeof t[0] ? v : 0]; } /// Replay helper threads: variants 0 and 1: a switch decides for this run; variant 2, Automatic's own line (the row's value /// unless the options file says otherwise, replay_threads.h) const char* hn_replay_threads(int v, int variant) { static const char* const by_default = "The default. The log's \"replay helper threads\" line at the start says how many this PC " "gets, and its \"parallel replay, trial\" lines when they are in use."; static const char* const t[] = {"Set for this run by RX_VK_PARALLEL, whatever is chosen here.", "Set for this run by RX_VK_PARALLEL_AUTO, whatever is chosen here.", by_default}; const bool automatic = v == replay_threads::kRowAutomatic; if (variant < 0) { const char* e = replay_threads_env(); return e ? (!strcmp(e, "RX_VK_PARALLEL") ? t[0] : t[1]) : automatic ? t[2] : nullptr; } return variant < 2 || (variant == 2 && automatic) ? t[variant] : nullptr; } const char* tx_preset(int v) { static const char* t[] = {"Custom", "Minimum (6GB)", "Low (8GB)", "Balanced (12GB)", "High (16GB)", "Ultra (20GB+)"}; return t[std::min(std::max(v, 0), 5)]; } // ((Triforce, 11-15, the owner: "make these say minimum 6gb low 8gb balanced 12gb high 16gb"; Ultra 20GB+, their choice) Each // preset's budgets are those of its card's size: the 6 GB ones Low (6GB) had, the 8 GB ones Balanced (8GB) had, the 12 GB ones // High (12GB) had, the 16 GB ones Ultra (16GB+) had, and Ultra's own for 20 GB and more. vk_memory.cpp preset_caps_memory has // the same sizes) void sync_preset_budgets(int p) { switch (p) { case 1: opts.vram_mb = 3600; opts.mirror_mb = 512; break; case 2: opts.vram_mb = 4800; opts.mirror_mb = 1024; break; case 3: opts.vram_mb = 7500; opts.mirror_mb = 2048; break; case 4: opts.vram_mb = 11000; opts.mirror_mb = 3072; break; case 5: opts.vram_mb = 14000; opts.mirror_mb = 3072; break; default: opts.vram_mb = 0; opts.mirror_mb = 0; break; } } // (Sharpness: tuned for the window pass's neighbours one picture pixel apart, each about the old setting's sharpening on a // 3840 x 2160 window at that preset's picture, 2048 x 1152 or the handheld profile's 1536 x 864: same frame, mean |Laplacian| // of the window and of the picture, on the slider's steps) void apply_preset(int p) { switch (p) { case 1: // Minimum (6GB VRAM / iGPU) opts.resolution = 4; opts.upscale = 2; opts.sharpness = 30; opts.pace = 1; opts.realtime = 1; opts.handheld = 1; break; case 2: // Low (8GB VRAM) opts.resolution = 2; opts.upscale = 2; opts.sharpness = 30; opts.pace = 1; opts.realtime = 1; opts.handheld = 1; break; case 3: // Balanced (12GB VRAM) opts.resolution = 1; opts.upscale = 1; opts.sharpness = 30; opts.pace = 1; opts.realtime = 1; opts.handheld = 0; break; case 4: // High (16GB VRAM) opts.resolution = 1; opts.upscale = 2; opts.sharpness = 40; opts.pace = 1; opts.realtime = 1; opts.handheld = 0; break; case 5: // Ultra (20GB+ VRAM) opts.resolution = 1; opts.upscale = 2; opts.sharpness = 50; opts.pace = 1; opts.realtime = 1; opts.handheld = 0; break; default: break; } // (the Upscaler and Frame generation are the player's: a preset never turns DLSS or made frames on or off. With DLSS // its resolution is DLSS's nearest mode) if (p > 0) opts.resolution = ur::snap(upscaler(), opts.resolution); // ((Triforce, 11-15, the owner: each preset sets the Texture detail, "default texture detail respectively") Minimum Low, // Low Reduced, Balanced, High and Ultra Full: each preset's texture budget is for its card's size, and the smaller ones keep // the textures smaller so the budget does not evict and make again what Full would keep asking for. Custom leaves it) static const int detail[] = {0, 3, 2, 1, 1, 1}; if (p > 0 && p <= 5) opts.tex_detail = detail[p]; sync_preset_budgets(p); } MENU_HINTS(hn_preset, 0, "Each row as you set it. Changing most rows yourself comes back to Custom.", "Resolution 50% (with DLSS its nearest mode), Lanczos, Sharpness 30%, Handheld profile.", "Resolution 75% (with DLSS its nearest mode), Lanczos, Sharpness 30%, Handheld profile.", "Resolution 100% (with DLSS its nearest mode), Catmull-Rom, Sharpness 30%.", "Resolution 100% (with DLSS its nearest mode), Lanczos, Sharpness 40%.", "Resolution 100% (with DLSS its nearest mode), Lanczos, Sharpness 50%.") MENU_HINTS(hn_gpu, 0, "The best dedicated GPU.") /// (Triforce) The Frame generation row's AMD FSR 4 (framegen_rows.h FSR4): what makes the frame, or, for a choice saved /// where it could, why AMD's library cannot here (fsr4fg::why) and what makes the frame in its place. Variants: every line /// it can show const char* hn_framegen_fsr4(int variant) { static const char* const ok = "One made frame between each two of the game's, by AMD's FSR 4 library from the scene's depth " "and motion. The HUD is part of the picture it works from."; static const char* const no[framegen_rows::FG_WHY_COUNT] = { nullptr, "AMD FSR 4 is not in this build: the renderer's own makes the one frame, as at 2x.", "AMD FSR 4 is switched off for this run (RX_VK_FSR4_FG=0 or RX_VK_FSR4=0): the renderer's own makes the frame.", "Not known yet: asked of AMD's library once the game's picture is up.", "AMD's files were not found beside the game: the renderer's own makes the one frame, as at 2x.", "AMD's frame generation library was not found beside the game: the renderer's own makes the frame.", "AMD's library has no FSR 4 frame generation for this GPU and driver: the renderer's own makes the frame.", "AMD's frame generation failed in this run (the log says where): the renderer's own makes the frame."}; if (variant < 0) { const int w = (int)fsr4fg::why_known(); // ((Triforce) as known: "not known yet" until menu_ahead has asked) return w == framegen_rows::FG_OK ? ok : no[std::clamp(w, 1, (int)framegen_rows::FG_WHY_COUNT - 1)]; } return variant == 0 ? ok : variant < (int)framegen_rows::FG_WHY_COUNT ? no[variant] : nullptr; } /// Frame generation: how many frames are made for each of the game's const char* hn_framegen(int v, int variant) { if (v == framegen_rows::FSR4) return hn_framegen_fsr4(variant); // (Triforce: AMD's library makes the frame) // (2x: by AMD FSR 3.1 where it runs, from the scene's depth and motion: vk_framegen.cpp. Variant 1 is that text) if (v == 2 && (variant < 0 ? fsr3fi::frames_wanted() != 0 : variant == 1)) return "One made frame between each two of the game's, by AMD FSR 3.1 from the scene's depth and motion."; if (variant > 0) return nullptr; if (v <= 0) return "Only the game's own frames: no added delay."; if (v == 1) return "A frame for each of the display's refreshes: none made when the game keeps up. Frame pacing does not apply."; static char b[9][96]; snprintf(b[v], sizeof b[v], "%s between each two of the game's.", v == 2 ? "One made frame" : v == 3 ? "Two made frames" : v == 4 ? "Three made frames" : v == 5 ? "Four made frames" : v == 6 ? "Five made frames" : v == 7 ? "Six made frames" : "Seven made frames"); return b[std::clamp(v, 2, 8)]; } MENU_HINTS(hn_pace, 0, "As soon as it is ready.", "At an even interval: less stutter, at up to one frame of delay.") MENU_HINTS(hn_output_res, 0, "The game's own size.", "The sharpest on a 2560x1440 screen: nothing to scale to the window.", "The sharpest on a 3840x2160 screen. The game's render targets get a bigger GPU pool, so a full-size 3D fits.", "The sharpest on a 1920x1080 screen: the HUD and text pixel for pixel, nothing to scale to the window.", "The sharpest on a 5120x1440 ultrawide screen: the whole frame pixel for pixel. The game's render targets get a bigger GPU pool, so a full-size 3D fits.", "The sharpest on a 5120x2880 (5K) screen: the whole frame pixel for pixel. The game's render targets get a bigger GPU pool, so a full-size 3D fits.", "The sharpest on a 5120x2160 ultrawide screen: the whole frame pixel for pixel. The game's render targets get a bigger GPU pool, so a full-size 3D fits.") /// The Window scaling filter: its filter, or that none is needed at this window's size const char* hn_filter(int v, int variant) { static const char* const t[] = {"The plain copy.", "Sharper.", "Sharper still; can ring on edges.", "AMD FSR 1: rebuilds edges as it enlarges, with Sharpness as its own sharpening."}; static const char* const none = "The window is the Output resolution's size: nothing to scale. The choice is kept for " "another size."; if (variant < 0) return filter_needed() ? t[std::clamp(v, 0, 3)] : none; return variant == 0 ? t[std::clamp(v, 0, 3)] : variant == 1 ? none : nullptr; } /// Sharpness: with DLSS or DLAA, the amount that suits them const char* hn_sharpness(int v, int variant) { static const char* const dlss = "DLSS and DLAA look softer than the game's own upscaler: around 80% suits them."; const bool with_dlss = variant < 0 ? upscaler() == ur::DLSS || upscaler() == ur::DLAA : variant == 1; if (variant > 1) return nullptr; return with_dlss ? dlss : v == 0 ? "Off: the picture as it is." : nullptr; } MENU_HINTS(hn_handheld, 0, "Docked: the Output resolution's size.", "Lower resolutions, lighter on the GPU.") MENU_HINTS(hn_ultrawide, 0, "The game's own shape.", "A 16:10 picture whatever the screen (as a 1920x1200 or 2560x1600 screen), the world a little narrower at the sides: " "the window opens in that shape, and a screen of another shape shows it between black bars.", "A 21:9 picture whatever the screen (64:27, as a 2560x1080 screen): the window opens in that shape, and a screen of " "another shape shows it between black bars. The HUD keeps its 16:9 shape in the middle.", "A 32:9 picture whatever the screen (as a 5120x1440 screen): the window opens in that shape, and a screen of " "another shape shows it between black bars. The HUD keeps its 16:9 shape in the middle.") const char* tx_wide_menus(int v) { static const char* t[] = {"Full width", "Centred, blurred sides", "Centred, black bars"}; return t[std::min(std::max(v, 0), 2)]; } MENU_HINTS(hn_wide_menus, 0, "The menus stretched over the whole screen, as before.", "The menus in the middle 16:9; beside them, what the game draws there, out of focus.", "The menus in the middle 16:9; black beside them.") MENU_HINTS(hn_robust, 0, "Off, on every card.", "Can be faster on some NVIDIA cards.", "Always on.") MENU_HINTS(hn_mesh, 0, "As the game finds best for this GPU: the fallback on AMD's RX 6000 driver, native mesh shaders elsewhere.", "Every mesh draw through compute shaders: a little slower. Try it if walls glow or the GPU stops responding on an AMD " "card. The shaders are prepared again once.") MENU_HINTS(hn_fps, 0, nullptr, "With frame generation on, the game's own rate too.", "In the counter's place in the top right corner, a see-through panel: the GPU's and the CPU's load, temperatures and memory, " "the frame rate with its lows, the frame times and their graph, the waits per frame and the picture's settings. It " "measures only while it is shown.") /// (Triforce) The FPS counter row's third value, Full, after NX2navi's perf_overlay (off, fps, full): 0 and 1 are Off and /// On as before. The row keeps its name, and with it its key in the options file (fps_counter) const char* tx_perf(int v) { return v == 1 ? "On" : v >= 2 ? "Full" : "Off"; } MENU_HINTS(hn_menu_size, 0, "Large in fullscreen on a screen of 1080 lines or more while a controller is in use, else Medium.", "Smaller, for a desk.", "The usual size.", "Larger, for a TV across the room.") MENU_HINTS(hn_speed, 0, "A step each frame: the game slows down whenever it runs below 60 fps.", "Normal speed down to 15 fps, by taking longer steps.") MENU_HINTS(hn_text_speed, 0, "The game's own pace, with its pauses.", "Twice as fast.", "Four times as fast.", "Each page at once, as pressing A does.") MENU_HINTS(hn_audio_output, 0, "5.1 when the default output device has 5.1 or more speakers, else stereo.", "Stereo, whatever the device has.", "5.1, whatever the device has. Mixed down on stereo speakers.") MENU_HINTS(hn_background, 0, "Only while the game's window has the focus.", "Also behind other windows, for streaming or other apps. The keyboard and mouse still need the game's window.") MENU_HINTS(hn_mousecam, 0, "The mouse stands in for the right stick, with its curve and top speed.", "The mouse turns the camera itself, one to one, as in a PC game.") MENU_HINTS(hn_mouse_invert, 0, nullptr, "Moving the mouse forward tilts the camera down.") MENU_HINTS(hn_gyro, 0, "The sticks alone aim.", "Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the " "connected pad has a gyroscope.") MENU_HINTS(hn_pad_layout, 0, "The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "A at the bottom (action and talk), B on the right, X on the left, Y at the top.", "A at the bottom, B on the right; X and Y as on the Switch.", "Bindings of your own, from the Controls page.") // ((Triforce) Auto's choice is host/prompts.c auto_face's; the keyboard and mouse face is nx2/prompt_keys.py's) MENU_HINTS(hn_prompts, 0, "Those of the first controller, from its name (SDL's). The keys' and the mouse's when the game starts with no " "controller; the Switch's for a controller that has no name, as with XInput alone.", nullptr, nullptr, nullptr, nullptr, nullptr, "Each button shows the first key or mouse button bound to it on this page, moving shows the movement keys, and " "the camera shows the mouse.") // (Triforce) what each walk key is bound to out of the box (host/nn_hid.c key_default), which it stops pressing while chosen MENU_HINTS(hn_walk_key, 0, "The movement keys always push the stick all the way: Link runs.", "Caps Lock presses no button by default. The system still switches capitals on and off with each press.", "Shift is B's key by default. While it is the walk key it does not press B: give B another key on the " "Controls page.", "Ctrl is the left stick press's key by default, which the Sprint button's Left stick click uses. While it is " "the walk key it does not press it.", "Tab is one of Plus's keys by default. While it is the walk key it does not press Plus; Enter still does.") // (Triforce) the Lazy write-back row (vk_memory.cpp lazy_decide, wb_lazy_state.h choose) MENU_HINTS(hn_lazy_write_back, 0, "Copied back after every submission, as always.", "Copied back when it is read. Stays off with an AMD card's driver unless RX_VK_LAZY_WB=1 is set, and does nothing " "with no VRAM mirrors.") // (Triforce) The cheats of the mods' cheat files (mods//cheats/.txt), which the host reads and runs // (host/mod_cheats.c) and names for the menu at the first frame (menu_option_set: HOS_OPT_MODCHEAT_*). Each has a row on the // System tab with the file's own name, On | Off as the toggles; the table below holds mod_cheat_rows::kSlots rows for them and // a heading, not shown until the host has named its cheats (row_shown). A row has no value of the menu's: its switch is the // list's, which the host asks for every frame (menu_take_mod_cheat) and keeps for the next start itself mod_cheat_rows::List mod_cheats; constexpr char kModCheatHeading[] = "Mod cheats"; // (the heading row's name in the table below: row_shown tells it by it) constexpr char kModCheatHelp[] = "A cheat from a mod's cheat file, in the mods folder. On: its code runs once every frame of the game. Off at first; one you " "switch on stays on at the next start."; /// A row's place among the mods' cheats (its name is the list's own), -1 for every other row int mod_cheat_slot(const char* name) { return mod_cheats.slot_of(name); } #define MOD_CHEAT_ROW(i) {TAB_SYSTEM, mod_cheats.names[i], nullptr, 0, 0, 0, nullptr, kModCheatHelp, nullptr, false, true}, #define MOD_CHEAT_ROWS8(i) \ MOD_CHEAT_ROW(i) MOD_CHEAT_ROW(i + 1) MOD_CHEAT_ROW(i + 2) MOD_CHEAT_ROW(i + 3) MOD_CHEAT_ROW(i + 4) MOD_CHEAT_ROW(i + 5) \ MOD_CHEAT_ROW(i + 6) MOD_CHEAT_ROW(i + 7) static_assert(mod_cheat_rows::kSlots == 96, "MOD_CHEAT_ROWS8 below is used twelve times: a row for every slot"); Row rows[] = { {TAB_DISPLAY, "Screen", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // Display: the window and the screen {TAB_DISPLAY, "Fullscreen", &opts.fullscreen, 0, 1, 1, tx_onoff, "Fills the whole screen with the game, without the window's border. The same as F10 or Alt+Enter.", nullptr, false, true}, // (the picture's way, top to bottom: the output's size, what fills it from the 3D, the 3D's size, then the window) {TAB_DISPLAY, "Output resolution", &opts.output_res, 0, kLastOutput, 1, tx_output_res, "The game's whole frame, HUD included, before it is scaled to the window. Docked only. Applies after a restart.", hn_output_res, true}, {TAB_DISPLAY, "GPU device", &opts.gpu_device, 0, 8, 1, tx_gpu, "Which graphics card the game runs on. Applies after a restart.", hn_gpu, true, true}, {TAB_DISPLAY, "Widescreen", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_DISPLAY, "Ultrawide", &opts.ultrawide, 0, 3, 1, tx_ultrawide, "The camera's shape: the game's own 16:9, or a fixed 16:10, 21:9 or 32:9 for a screen or a window of that shape. A screen " "of another shape shows the picture between black bars. Applies after a restart.", hn_ultrawide, true}, // (Triforce: host/oot_wide_hud.c) {TAB_DISPLAY, "Ultrawide HUD", &opts.wide_hud, 0, 1, 1, tx_wide_hud, "With Ultrawide: where the hearts, the item slot and the map sit on a screen wider than 16:9. Middle: in the " "middle 16:9, as on a normal screen. Screen edges: out in the screen's corners. Applies after a restart.", nullptr, true, true}, {TAB_DISPLAY, "Ultrawide menus", &opts.wide_menus, 0, 2, 1, tx_wide_menus, "With Ultrawide: the pause, item and map menus, and what shows beside them. Loading screens and pre-rendered movies, " "which draw no world either, get the same sides; a fade always covers the whole screen. Changes at once.", hn_wide_menus}, {TAB_DISPLAY, "Frame rate", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_DISPLAY, "Game frame rate cap", &opts.fps_cap, -3, 6, 1, tx_fps_cap, // (6: Monitor's rate, fps_cap.h kMonitor) "Limits frames rendered by the game. Generated frames are additional. Takes a restart. " "30, 40 and 45 are for a PC or handheld that holds one of them steadily where 60 swings; the game keeps its speed. " "Past 60 is experimental: the game keeps real time, but some cutscenes and bosses can misbehave (Gohma, the intro's " "narration). 60 is the safe choice. Monitor's rate is the refresh rate of the screen the game starts on, from 30 to 240.", nullptr, true, true}, // (Triforce: host/pace_steady.h, host/nn_vi.c steady_period. Off until chosen: nobody has run it in the game) {TAB_DISPLAY, "Steady frame rate", &opts.steady_fps, 0, 2, 1, tx_steady_fps, "Paces the game to a frame rate this PC holds where you are, under the Game frame rate cap, and shows each frame a " "period after the last, so that frames come evenly instead of each as soon as it is ready. It goes down quickly where " "frames run late and back up slowly where there is room; loads and single hitches do not move it. Gives up some frame " "rate for steadiness. Any rate suits a screen with variable refresh (G-SYNC, FreeSync) or VSync off; Refresh steps keeps " "to whole divisions of the refresh rate (at 240 Hz: 120, 80, 60 ...) for VSync without variable refresh. Takes a restart.", nullptr, true, true}, // (Triforce, after NX2navi's reflex_limit: vk_dlssg.cpp pace, dlssg_pace.h. Off until chosen: nobody has run it in the game) {TAB_DISPLAY, "Reflex frame limit", &opts.reflex_limit, 0, 1, 1, tx_onoff, "With DLSS frame generation: NVIDIA Reflex holds the Game frame rate cap where each frame starts, in place of the " "game's own wait, so a frame waits once and the controls are read later. The game's own wait is back whenever no " "frame is being generated. Where RivaTuner Statistics Server is the game's limiter it holds the frames instead. " "Changes at once.", hn_reflex_limit, false, true}, // (Triforce, after NX2navi's VSync switch: the swapchain's present mode, made again at once. present_mode.h, vk_main.cpp) {TAB_DISPLAY, "VSync", &opts.vsync, 0, 1, 1, tx_onoff, "Whether a finished frame waits for the screen's next refresh. Off shows it at once: a little less delay, and the picture " "can tear. Neither changes the frame rate, which the Game frame rate cap limits. Changes at once.", hn_vsync, false, true}, // (Triforce, after NX2navi's perf_overlay: a third value, Full, NX2navi's full performance overlay: perf_sample, draw_perf) {TAB_DISPLAY, "FPS counter", &opts.show_fps, 0, 2, 1, tx_perf, "On: frames per second in the top right corner. Full: a performance overlay in its place, with the GPU's and the CPU's load, " "temperatures and memory, the frame rate and its 1% and 0.1% lows, the frame times and their graph, the waits per frame " "and the picture's settings.", hn_fps, false, true}, {TAB_DISPLAY, "High dynamic range", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_DISPLAY, "HDR", &opts.hdr, 0, 2, 1, tx_hdr, "HDR10 out on an HDR display (Windows: Use HDR on in the display settings). Expanded: the game's SDR picture, its white at " "the paper white and its highlights up to the peak. Native: the game's own HDR, told the display's peak and paper white.", nullptr, false, true}, {TAB_DISPLAY, "HDR paper white", &opts.hdr_white, 80, 400, 10, tx_nits, "How bright the picture's white is with HDR on. Around 200 for a normal room; higher in a bright one.", nullptr, false, true}, // (Triforce: up to HDR10's own 10,000 nits, as NX2navi's hdr_peak_nits; it stopped at 4,000. Every reader takes that much) {TAB_DISPLAY, "HDR peak brightness", &opts.hdr_peak, 400, 10000, 100, tx_nits, "The brightest highlights with HDR on: set it to your display's peak brightness.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce, 11-13: RenoDX is in every build and off until this row turns it on. The scene's format is chosen at the // start, host/nn_vi.c hos_scene_rgba16f: a restart) {TAB_DISPLAY, "RenoDX HDR", &opts.renodx, 0, 1, 1, tx_onoff, "With HDR set to Native: RenoDX's tone mapping, eye adaptation and colour grading in place of the game's own, and its " "rows below. Off: the game's own HDR. Applies after a restart. RenoDX is by Carlos Lopez (clshortfuse), under the MIT " "license.", nullptr, true, true}, // (local, RenoDX port: vk_renodx.cpp. Shown with HDR Native, where its shaders run) // (Triforce: RenoDRT, the third tone mapper NX2navi's HDR has; the rows of one tone mapper show while it is chosen, // rdx_applies. Ranges and steps as NX2navi's menu has them) {TAB_DISPLAY, "RenoDX tonemapper", &opts.rdx_tonemap, 0, 2, 1, tx_rdx_tonemap, "With HDR Native: how the scene's light is brought to the display. Vanilla: the game's own curve. PsychoV35: RenoDX's, " "which keeps hue and saturation into the highlights, up to the peak brightness. RenoDRT: RenoDX's, which carries the " "game's SDR look up to the peak by brightness. RenoDX is by Carlos Lopez (clshortfuse), under the MIT license.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX gamma correction", &opts.rdx_gamma, 0, 2, 1, tx_rdx_gamma, "Shows the picture as a 2.2 or BT.1886 (2.4) display would, as the game was made to be seen: darker shadows. Off keeps " "the sRGB curve. With every tonemapper. PsychoV35 and RenoDRT still end at the peak brightness; Vanilla's highlights " "are the game's own, which 2.2 dims a little and 2.4 brightens a little.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX midgray", &opts.rdx_midgray, 0, 2, 1, tx_rdx_midgray, "With PsychoV35: what the scene's middle grey is held to. Render: as rendered. Vanilla: where the game's own curve puts it. " "Eye adaptation: it follows what is on screen over a few seconds, weighted towards the middle of the view, as eyes adjust.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX match tone slope", &opts.rdx_match_slope, 0, 1, 1, tx_onoff, "With PsychoV35: gives the mid tones the contrast of the game's own curve. Off: PsychoV35's own, softer.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX tone slope", &opts.rdx_tone_slope, 0, 100, 1, tx_rdx_grade, "With PsychoV35: the steepness of the tone curve through middle grey. 50 leaves it unchanged.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX hue clip", &opts.rdx_hue_clip, 0, 100, 5, tx_percent, "With PsychoV35: how much bright colours turn as they do where the game's SDR picture clips: fire towards yellow and " "white. 0% keeps their hue.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX UI brightness", &opts.rdx_ui_white, 80, 400, 10, tx_nits, "How bright the menus' and the HUD's white is with RenoDX's tonemapper. The scene's follows HDR paper white.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX color space", &opts.rdx_space, 0, 2, 1, tx_rdx_space, "The colours the picture is taken to be in before HDR10's. Vanilla: the game's own matrix. BT.709: as the SDR picture. " "DCI-P3: more saturated.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX exposure", &opts.rdx_exposure, 0, 200, 5, tx_percent, "The scene's brightness before RenoDX's tone mapping. 100% is the game's.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX highlights", &opts.rdx_highlights, 0, 100, 5, tx_rdx_grade, "RenoDX's colour grading: the bright parts of the scene. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX shadows", &opts.rdx_shadows, 0, 100, 5, tx_rdx_grade, "RenoDX's colour grading: the dark parts of the scene. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX contrast", &opts.rdx_contrast, 0, 100, 5, tx_rdx_grade, "RenoDX's colour grading: the scene's contrast. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX saturation", &opts.rdx_saturation, 0, 100, 5, tx_rdx_grade, "RenoDX's colour grading: the scene's saturation. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX highlight saturation", &opts.rdx_highlight_sat, 0, 100, 1, tx_rdx_grade, "With RenoDRT: the strength of the colours of the brightest parts. 50 leaves it unchanged.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX blowout", &opts.rdx_blowout, 0, 100, 1, tx_rdx_grade, "With RenoDRT: turns the brightest parts towards white. 0 keeps their colour.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX flare", &opts.rdx_flare, 0, 100, 1, tx_rdx_grade, "With RenoDRT: lifts the darkest parts as a little stray light would. 0 keeps black black.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX hue correction", &opts.rdx_hue, 0, 100, 5, tx_percent, "With RenoDRT: how much bright colours keep the hue they have before the tonemapper. 0% lets them shift as the curve " "takes them.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX color grading", &opts.rdx_grade, 0, 100, 5, tx_percent, "With RenoDRT: how much of the game's own colour grading the HDR picture keeps. 0% is the scene without it.", nullptr, false, true}, {TAB_DISPLAY, "RenoDX bloom", &opts.rdx_bloom, 0, 100, 5, tx_rdx_grade, "How strong the glow around bright things is. 50 is the game's.", nullptr, false, true}, {TAB_GRAPHICS, "Quality", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // Graphics: the picture, top to bottom (the Upscaler only in a build with DLSS, or where AMD FSR 3.1 runs: row_shown) {TAB_GRAPHICS, "Quality preset", &opts.preset, 0, 5, 1, tx_preset, "Sets the scaling rows and memory limits for a GPU with that much memory. The Upscaler and Frame generation stay yours.", hn_preset}, // (Triforce: read once, at the start (host/nn_vi.c): Auto -> 100% in game left the 3D at the dynamic path's size) {TAB_GRAPHICS, "Render resolution", &opts.resolution, 0, ur::kValues - 1, 1, tx_resolution, "The share of the output the 3D is drawn at; the Upscaler fills in the rest. Applies after a restart.", hn_resolution, true}, // (Triforce, after NX2navi's texture_detail: tex_detail.h, vk_texture.cpp texture_detail_level. Read at the first texture) {TAB_GRAPHICS, "Texture detail", &opts.tex_detail, 0, 3, 1, tx_tex_detail, "How large the game's textures are kept in video memory. Automatic suits the graphics card; a Quality preset sets it " "for its card's size. Applies after a restart.", hn_tex_detail, true}, {TAB_GRAPHICS, "Texture filtering", &opts.aniso, 0, 4, 1, tx_aniso, // (Triforce: vk_draw.cpp sampler_for) "Anisotropic filtering: keeps ground, paths and walls sharp where they slope away from the camera. Game's is what the game " "asks for; 16x is the sharpest, at a small cost."}, {TAB_GRAPHICS, "Upscaling and edges", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_GRAPHICS, "Upscaler", &opts.dlss, 0, ur::kUpscalers - 1, 1, tx_upscaler, "What scales the 3D up to the Output resolution.", hn_upscaler}, {TAB_GRAPHICS, "DLSS model", &opts.dlss_model, 0, ur::kModels - 1, 1, tx_dlss_model, "Which of NVIDIA's DLSS networks draws the picture.", hn_dlss_model, false, true}, // (Triforce, 11-13: vk_temporal.cpp pre_wanted, off until asked) {TAB_GRAPHICS, "Upscale before bloom", &opts.upscale_pre, 0, 1, 1, tx_onoff, "With NVIDIA DLSS, DLAA or AMD FSR as the Upscaler: On, it works on the scene before the game's glow and tone mapping, " "so both are made from the sharpened scene. Off: on the finished picture, as before. Applies after a restart.", nullptr, true, true}, // (Triforce, after NX2navi's aa setting: aa_rows.h, vk_aa.cpp. Taken at each frame; not a Quality preset's) {TAB_GRAPHICS, "Anti-aliasing", &opts.aa, 0, aa_rows::kValues - 1, 1, tx_aa, "How the 3D's edges are smoothed before it is scaled up: by the game's own SMAA, not at all, by FXAA, or by SMAA at " "its Ultra preset. Changes at once.", hn_aa, false, true}, {TAB_GRAPHICS, "Sharpness", &opts.sharpness, 0, 100, 10, tx_percent, "Sharpens the picture as it goes to the window, with any filter. Too much shows halos around edges.", hn_sharpness}, {TAB_GRAPHICS, "Window scaling filter", &opts.upscale, 0, 3, 1, tx_filter, // (Triforce: 3 = AMD FSR 1, vk_framegen.cpp) "How the finished picture is scaled to the window, when its size differs from the Output resolution.", hn_filter}, {TAB_GRAPHICS, "Smoothness", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce: 9 is AMD FSR 4, framegen_rows.h FSR4, there only where AMD's library can make the frames: framegen_row_sync) {TAB_GRAPHICS, "Frame generation", &opts.framegen, 0, 9, 1, tx_framegen, "Makes frames between the game's own, for smoother motion, at a little input delay. Fast motion or camera cuts can " "show artifacts.", hn_framegen, false, true}, // (Triforce, after NX2navi's: vk_dlssg.cpp. Read at the start, where the device is made through NVIDIA's Streamline) {TAB_GRAPHICS, "DLSS frame generation", &opts.dlssg, 0, 3, 1, tx_dlssg, "NVIDIA RTX 40 and 50 cards: frames made between the game's own by NVIDIA DLSS, from the scene's depth and motion, " "with NVIDIA Reflex. The Frame generation row above is not used with it. Applies after a restart.", hn_dlssg, true, true}, {TAB_GRAPHICS, "Frame pacing", &opts.pace, 0, 1, 1, tx_onoff, "When each frame is shown.", hn_pace}, {TAB_GRAPHICS, "Latency", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_GRAPHICS, "NVIDIA Reflex", &opts.reflex, 0, 2, 1, tx_reflex, "NVIDIA GPUs: each frame starts as late as it can, for less input delay. With DLSS frame generation it runs through " "NVIDIA Streamline; not used with the other frame generation.", hn_reflex}, {TAB_GRAPHICS, "AMD Anti-Lag 2", &opts.antilag, 0, 1, 1, tx_antilag, "AMD GPUs: each frame starts as late as it can, for less input delay. Not used with frame generation.", hn_antilag}, {TAB_GRAPHICS, "Advanced", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_GRAPHICS, "Handheld profile", &opts.handheld, 0, 1, 1, tx_onoff, "Runs the game as if the console were undocked. Applies after a restart.", hn_handheld, true}, {TAB_GRAPHICS, "Robust buffers", &opts.robust, 0, 2, 1, tx_robust, "Bounds-checked buffer reads: a read past a buffer's end is dropped instead of stopping the GPU. Applies after a " "restart.", hn_robust, true}, // ((Triforce, 11-18) a player's RX 7700S: glowing doors and walls with native mesh shaders, gone with the compute fallback // (#bug-tracker). The row's key, mesh_shaders, is read where the device is made: vk_main.cpp) {TAB_GRAPHICS, "Mesh shaders", &opts.mesh_mode, 0, 1, 1, tx_mesh, "How the game's mesh-shader draws run. Try Compute fallback on an AMD card that shows glowing walls or loses the GPU. " "Applies after a restart.", hn_mesh, true}, {TAB_SYSTEM, "Game", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce: language.txt's choice, not the options file's. Its entries are counted when the file is read: lang_load) {TAB_SYSTEM, "Game language", &opts.language, 0, 0, 1, tx_language, "The language of the game's texts. Kept in language.txt in the game folder, which lists the languages the game has. " "Applies after a restart.", hn_language, true, true}, {TAB_SYSTEM, "Game speed", &opts.realtime, 0, 1, 1, tx_speed, "How the game keeps time when it runs below 60 fps.", hn_speed}, {TAB_SYSTEM, "Text speed", &opts.text_speed, 0, 3, 1, tx_text_speed, "How fast the letters of dialogue and other messages appear.", hn_text_speed}, {TAB_SYSTEM, "Discord status", &opts.discord, 0, 1, 1, tx_onoff, "Shows \"Playing Triforce\" and the time played in your Discord status, while Discord runs on this PC.", nullptr, false, true}, {TAB_SYSTEM, "Saves", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce, after NX2navi's save rows: they act on a press, share_row; the host does the work, host/save_share.c) {TAB_SYSTEM, "Export save", nullptr, 0, 0, 0, nullptr, "Writes your save as a zip into your Downloads folder: to keep, or to give to someone. No game file is in it."}, {TAB_SYSTEM, "Export save for a bug report", nullptr, 0, 0, 0, nullptr, "The same zip with the game's logs, its settings and its freeze report added: what to send with a problem report."}, {TAB_SYSTEM, "Import a save", nullptr, 0, 0, 0, nullptr, "Takes a save export of Triforce or NX2navi: a zip you put into the game folder's save-import folder. It becomes your " "save at the next start, and the save it replaces is kept. For an emulator's save: Convert saves in Triforce Setup."}, {TAB_SYSTEM, "Tools", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce, after NX2navi's F8: host/bug_capture.c writes the folder, vk_bugshot.cpp its picture) {TAB_SYSTEM, "Bug capture (F8)", nullptr, 0, 0, 0, nullptr, "Writes what a problem report needs into a folder of its own under captures in the game folder: a picture of the frame, " "your settings, the end of the log and your save. F8 does the same while you play."}, // (Triforce, after NX2navi's Cheats tab: the cheats of the mods' cheat files, a row each once the host has named them) {TAB_SYSTEM, "Mod cheats", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // (kModCheatHeading) MOD_CHEAT_ROWS8(0) MOD_CHEAT_ROWS8(8) MOD_CHEAT_ROWS8(16) MOD_CHEAT_ROWS8(24) MOD_CHEAT_ROWS8(32) MOD_CHEAT_ROWS8(40) MOD_CHEAT_ROWS8(48) MOD_CHEAT_ROWS8(56) MOD_CHEAT_ROWS8(64) MOD_CHEAT_ROWS8(72) MOD_CHEAT_ROWS8(80) MOD_CHEAT_ROWS8(88) // (Triforce, after NX2navi's volume row: over the game's own mix, host/nn_audio.c; the game's own Options have none) {TAB_AUDIO, "Master volume", &opts.volume, 0, 100, 5, tx_volume, "How loud the game is, in percent of its own volume. The game's sounds and music keep their balance.", nullptr, false, true}, // (Triforce, after NX2navi's menu_sound_volume: the options' own sounds, host/menu_sound.c; under the Master volume) {TAB_AUDIO, "Menu sounds", &opts.menu_sounds, 0, 100, 5, tx_menu_sounds, "How loud these options' own sounds are: the game's interface sounds, played from your game files as you move through " "the tabs and rows. Off is silent. The Master volume is over them too.", nullptr, false, true}, {TAB_AUDIO, "Audio output", &opts.audio_output, 0, 2, 1, tx_audio_output, "The speakers the game mixes its sound for. Applies after a restart.", hn_audio_output, true, true}, {TAB_AUDIO, "Microphone", &opts.mic, 0, 2 + kMaxMics, 1, tx_mic, "What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", hn_mic, false, true}, {TAB_CONTROLS, "Camera", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce: host/prompts.c build_camera) {TAB_CONTROLS, "Camera speed", &opts.camera_speed, 25, 300, 5, tx_sens, "How fast the right stick turns the camera: times the game's own speed, at any Camera sensitivity of the game's " "Options. The mouse keeps its own sensitivity. Applies after a restart.", nullptr, true, true}, {TAB_CONTROLS, "Invert camera X", &opts.invert_cam_x, 0, 1, 1, tx_onoff, "Inverts horizontal look (left/right) on the right analog stick.", nullptr, false, true}, {TAB_CONTROLS, "Invert camera Y", &opts.invert_cam_y, 0, 1, 1, tx_onoff, "Inverts vertical look (up/down) on the right analog stick.", nullptr, false, true}, {TAB_CONTROLS, "Mouse camera", &opts.mouse_native, 0, 1, 1, tx_mousecam, "How the captured mouse turns the camera.", hn_mousecam, false, true}, {TAB_CONTROLS, "Mouse sensitivity", &opts.mouse_sens, 10, 500, 10, tx_sens, "How far the camera turns for a mouse movement, with either Mouse camera: at 1.00 native look turns 0.1 degree a " "count. The - and = keys change it in game too.", nullptr, false, true}, {TAB_CONTROLS, "Invert mouse vertical", &opts.mouse_invert, 0, 1, 1, tx_onoff, "Swaps up and down for the mouse.", hn_mouse_invert, false, true}, {TAB_CONTROLS, "Sticks", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) {TAB_CONTROLS, "Stick dead zone", &opts.stick_dead_zone, 0, 5, 1, tx_stick_dead_zone, "How far a stick moves before the game sees it, on each axis. Lower for a precise stick, higher for one that drifts. " "The game's own dead zone still follows.", nullptr, false, true}, // (Triforce, after NX2navi's lstick_deadzone and rstick_deadzone: host/nn_hid.c hos_stick_axis_own) {TAB_CONTROLS, "Left stick dead zone", &opts.lstick_dead_zone, -1, 50, 1, tx_own_dead_zone, "The left stick's own dead zone, in percent of its travel on each axis, in place of Stick dead zone: a worn stick can " "have a larger one than the other. 0% cuts nothing; the game's own dead zone still follows.", nullptr, false, true}, {TAB_CONTROLS, "Right stick dead zone", &opts.rstick_dead_zone, -1, 50, 1, tx_own_dead_zone, "The right stick's own dead zone, in percent of its travel on each axis, in place of Stick dead zone: a worn stick can " "have a larger one than the other. 0% cuts nothing; the game's own dead zone still follows.", nullptr, false, true}, {TAB_CONTROLS, "Movement", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce, after NX2navi's sprint button: host/oot_sprint.h) {TAB_CONTROLS, "Sprint button", &opts.sprint_button, 0, 2, 1, tx_sprint, "Link sprints from a button press, without rolling first. Left stick click: the game has no other use for it. B: sprints " "only while Link moves, and puts the weapon away as usual otherwise (with the game's Swap Jump Controls B is the jump: " "use the stick's click).", nullptr, false, true}, {TAB_CONTROLS, "Sprint mode", &opts.sprint_mode, 0, 1, 1, tx_sprint_mode, "Toggle: a press starts the sprint and the next press, or stopping, ends it. Hold: Link sprints while the button is " "held.", nullptr, false, true}, // (Triforce, after NX2navi's walk_key and walk_scale: host/nn_hid.c walk_key_code, walk_keys) {TAB_CONTROLS, "Walk key", &opts.walk_key, 0, 4, 1, tx_walk_key, "A key that makes Link walk on the keyboard: held with the movement keys, they push the left stick only as far as " "Walk scale. While it is chosen the key presses nothing else.", hn_walk_key, false, true}, {TAB_CONTROLS, "Walk scale", &opts.walk_scale, 20, 90, 1, tx_sens, "How far the movement keys push the left stick while the Walk key is held: 1.00 would be all the way, lower walks " "slower. A controller's stick and the camera's keys are not changed.", nullptr, false, true}, {TAB_CONTROLS, "Vibration", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // (Triforce: to 300 as NX2navi's rumble_strength, 150 before) {TAB_CONTROLS, "Rumble strength", &opts.rumble, 0, 300, 25, tx_rumble, "How strongly the controller rumbles, in percent of the game's rumble. Off turns it off. Over 100% a rumble that " "would pass the motors' full strength stops there.", nullptr, false, true}, // (Triforce, after NX2navi's rumble_curve: host/pad_sdl.c rumble_curve) {TAB_CONTROLS, "Vibration curve", &opts.rumble_curve, 20, 150, 5, tx_sens, "Shapes the rumble of a controller's two motors. 1.00 is the game's. Lower lifts the many weak rumbles so they can be " "felt and hardly changes the strong ones; higher quiets them. A Switch controller's HD rumble is not changed by it.", nullptr, false, true}, // (Triforce, after NX2navi's rumble_triggers: host/pad_sdl.c trigger_poll) {TAB_CONTROLS, "Trigger vibration", &opts.rumble_triggers, 0, 1, 1, tx_onoff, "Xbox One and Series controllers: the motors in the triggers rumble too, with the lighter of the two motors. " "Controllers without them rumble as before.", nullptr, false, true}, {TAB_CONTROLS, "Other", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, // ((Triforce) 11-17: a section) // Controls (17 rows; Motion opens the 6 TAB_MOTION rows, Controls its page with the 2 TAB_PAGE rows) {TAB_CONTROLS, "Controller in background", &opts.pad_background, 0, 1, 1, tx_onoff, "Whether the controller plays the game while another window has the focus.", hn_background}, {TAB_CONTROLS, "Menu shortcut", &opts.menu_shortcut, 0, 1, 1, tx_menu_shortcut, "Which keys open and close these options from anywhere. F1 always does; F1 only leaves Insert free for an overlay.", nullptr, false, true}, {TAB_CONTROLS, "Motion", nullptr, 0, 0, 0, nullptr, // (hookshot: opens the Motion page, the TAB_MOTION rows) "Motion controls: aiming with the controller's gyroscope, its sensitivity and its inverts."}, {TAB_CONTROLS, "Controls", nullptr, 0, 0, 0, nullptr, // (hookshot: opens its page) "The layout preset, the button prompts, and which gamepad button and which keys press each of the Switch's " "buttons."}, {TAB_MOTION, "Motion controls", &opts.gyro, 0, 1, 1, tx_gyro, "Aims and looks with the controller's gyroscope where the game uses motion, as on the Switch. Works with Switch Pro " "controllers and pads in Switch mode, DualSense and DualShock 4. Shown beside it: whether the connected pad has one.", hn_gyro, false, true}, {TAB_MOTION, "Motion sensitivity X", &opts.gyro_sens_x, 10, 600, 10, tx_percent, "How far the aim moves left and right for a given turn of the controller. 100% is the console's own.", nullptr, false, true}, {TAB_MOTION, "Motion sensitivity Y", &opts.gyro_sens_y, 10, 300, 10, tx_percent, "How far the aim moves up and down for a given tilt of the controller. 100% is the console's own.", nullptr, false, true}, {TAB_MOTION, "Invert motion X", &opts.gyro_inv_x, 0, 1, 1, tx_onoff, "Turns the motion aim's left and right around.", nullptr, false, true}, {TAB_MOTION, "Invert motion Y", &opts.gyro_inv_y, 0, 1, 1, tx_onoff, "Turns the motion aim's up and down around.", nullptr, false, true}, {TAB_MOTION, "Motion deadzone", &opts.gyro_deadzone, 0, 2, 1, tx_deadzone, "How slow a turn counts as none, the console's three settings: Standard is its own. High steadies a pad that jitters " "when held still; Low keeps the smallest movements.", nullptr, false, true}, // (hookshot) the Controls page's own rows, above its grid (TAB_PAGE: no tab shows them) {TAB_PAGE, "Layout preset", &opts.pad_layout, 0, 3, 1, tx_pad_layout, "Which face button is which. Binding one yourself on the Controls page makes it Custom.", hn_pad_layout}, {TAB_PAGE, "Button prompts", &opts.prompts, 0, HOS_PROMPT_N, 1, tx_prompts, "The button icons the game shows, in its texts and menus: those of this controller, or the keyboard's and the " "mouse's, for the buttons or keys your controls put each action on.", hn_prompts, true, true}, // Debug: the tools' switch, the tools themselves below it while they are on (cheat: menu_tick does what they do), then the // developer's rows {TAB_DEBUG, "Debug tools", &opts.debug_tools, 0, 1, 1, tx_onoff, "Testing tools: no-clip flight, a free camera, teleport, Link's age, the inventory, the clock and heart protection. Off " "puts flight, the free camera and heart protection away.", nullptr, false, true}, {TAB_DEBUG, "Heart protection", nullptr, 0, 0, 0, nullptr, "Protects Link's hearts. Hits can still knock him back.", nullptr, false, true, 0}, {TAB_DEBUG, "No-clip flight", nullptr, 0, 0, 0, nullptr, "Enable double-tap Jump for takeoff and landing. Hold Jump to climb or L to descend.", nullptr, false, true, 1}, {TAB_DEBUG, "Mark position", nullptr, 0, 0, 0, nullptr, "Remember Link's position for this loaded scene.", nullptr, false, true, 2}, {TAB_DEBUG, "Return to mark", nullptr, 0, 0, 0, nullptr, "Teleport Link to the marked position in the current scene.", nullptr, false, true, 3}, {TAB_DEBUG, "Set time", nullptr, 0, 0, 0, nullptr, "Choose an hour with Left or Right. Enter sets the world clock.", nullptr, false, true, 4}, {TAB_DEBUG, "Inventory item", nullptr, 0, 0, 0, nullptr, "Choose a consumable with Left or Right.", nullptr, false, true, 5}, {TAB_DEBUG, "Change quantity", nullptr, 0, 0, 0, nullptr, "Choose how many to add or remove. Enter applies the change.", nullptr, false, true, 6}, {TAB_DEBUG, "Free camera", nullptr, 0, 0, 0, nullptr, "Move and look with your usual controls. Page Up / Page Down or R / L changes height.", nullptr, false, true, 7}, {TAB_DEBUG, "Teleport", nullptr, 0, 0, 0, nullptr, "Opens the map list. Link travels through the game's own map change, in his current age.", nullptr, false, true, 8}, {TAB_DEBUG, "Switch age", nullptr, 0, 0, 0, nullptr, "Swaps Link between child and adult and reloads this map in the other age (the Market when this map has no match).", nullptr, false, true, 9}, {TAB_DEBUG, "Inventory", nullptr, 0, 0, 0, nullptr, "Enter opens the inventory editor: unlock or relock equipment, items, upgrades and quest items, and change amounts.", nullptr, false, true, 10}, // (Triforce: the name pages, after NX2navi's flags by name, cutscene starter and amiibo. Nothing is read, listed or sent // until one is opened) {TAB_DEBUG, "Game flags", nullptr, 0, 0, 0, nullptr, "Opens the game's story and world flags by name, in groups, read from your game files. See which are set in your save, and " "set or clear one. The game takes a change when it runs again.", nullptr, false, true, 11}, {TAB_DEBUG, "Cutscenes", nullptr, 0, 0, 0, nullptr, "Opens the game's events by name, read from your game files, and starts one as the game's own actors do. Many belong to " "one place or one moment of the story and may not play as they should anywhere else. Save first.", nullptr, false, true, 12}, {TAB_DEBUG, "Scan amiibo", nullptr, 0, 0, 0, nullptr, "Opens the dumps in the folder \"amiibo\" in the game folder (.bin files you made of your own figures). Choose one, then use " "amiibo in the game: the figure is on the reader when the game looks for one.", nullptr, false, true, 13}, {TAB_DEBUG, "Developer", nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}, {TAB_DEBUG, "Descriptor reuse", &opts.descriptor_reuse, 0, 1, 1, tx_onoff, "A draw keeps its descriptors while the texture slots it samples are unchanged, so streaming elsewhere in the game no longer " "rebuilds every set each frame. Applies after restart.", nullptr, true}, // (Triforce: vk_draw.cpp gpl_wanted, what RX_VK_GPL=1 does; gpl_rules.h. On by default since options_version 5) {TAB_DEBUG, "Fast pipeline link", &opts.fast_pipeline_link, 0, 1, 1, tx_onoff, "Experimental. A new pipeline is first linked from its shaders' libraries, in milliseconds where the graphics driver has " "them compiled, and the optimised one takes its place once it is built. The first start with it compiles those libraries " "once, which takes minutes. Needs a card with pipeline libraries. Applies after restart.", nullptr, true, true}, {TAB_DEBUG, "Sampler cache", &opts.sampler_cache, 0, 1, 1, tx_onoff, "What a sampler holds is kept beside it on the replay thread, so resolving a sampler that was not registered anew takes no " "lock. Helps while the game streams textures. Applies after restart.", nullptr, true}, // (Triforce: vk_memory.cpp "lazy write-back", wb_lazy_state.h; RX_VK_LAZY_WB over it. On by default since options_version // 5, but nowhere on AMD's driver by this row alone. Windows only: row_shown) {TAB_DEBUG, "Lazy write-back", &opts.lazy_write_back, 0, 1, 1, tx_onoff, "Experimental. What the GPU writes into memory the game shares with it is copied back only when the game, the system or " "the GPU next reads it there, not after every submission. Saves memory traffic where the game reads little of it. " "Applies after restart.", hn_lazy_write_back, true, true}, // (Triforce: vk_replay.cpp par_threads_max, what RX_VK_PARALLEL_AUTO= does. Automatic unless set here: replay_threads.h) {TAB_DEBUG, "Replay helper threads", &opts.replay_threads, 0, 8, 1, tx_replay_threads, "A frame's large command buffers are recorded on this many threads wherever short trials, made every so often as the game " "runs, find that faster than the replay thread alone. Automatic: 2 or 3 threads by this PC's processors, none with four " "cores or fewer. Off: the replay thread alone, always: choose it if frames flicker. Used with DLSS or FSR on too, for " "upscaling or frame generation: what comes after the upscale is recorded in order. Applies after restart.", hn_replay_threads, true, true}, // (Triforce, after NX2navi's tail_early: vk_replay.cpp the early tail, tail_early.h. Read at the start. The owner, 11-16: // "implement this in debug under developer" and "on by default": a Developer row, on by default since options_version 6) {TAB_DEBUG, "Start next frame early", &opts.tail_early, 0, 1, 1, tx_onoff, "Experimental. The game starts its next frame while the graphics card still draws the end of this one (the upscaling " "and the interface), where that end holds nothing the game reads back. Other frames run as before. Applies after " "restart.", nullptr, true, true}, // (Triforce, after NX2navi's astc_bc1: tex_bc1.h, vk_texture.cpp bc1_on. Read at the first texture; on by default since // options_version 5. The owner, 11-16: "put this in debug dev tab too": a Developer row, after Start next frame early) {TAB_DEBUG, "Opaque textures as BC1", &opts.tex_bc1, 0, 1, 1, tx_onoff, "Keeps the game's large textures that have no transparency in half the video memory, with the same picture. Off: as " "before. Turn it off if textures look wrong. Applies after a restart.", hn_tex_bc1, true, true}, // ((Triforce) 11-19, the owner: Restart and Quit moved to the pause menu's System page, as the game's own button under // Mods (draw_mods_row; its dialog draw_quit_ask) }; constexpr int kRowsEnd = sizeof rows / sizeof rows[0]; // (the table's end: tests read the table up to here) const Row* pending = nullptr; // (Restart or Quit: shows Confirm until its second press) bool cheats_env = false; // (HOS_OOT_CHEATS=1: on whatever the Debug tab says) /// The debug tools: the Debug tab's row, or HOS_OOT_CHEATS=1 bool cheats_on() { return cheats_env || opts.debug_tools; } // (Triforce) The Debug tab: shown always since 11-15 (the owner: "make debug on by default and remove the alt+g shortcut"). // Alt+G, which unlocked it and put it away again, is gone; the options file's old debug_tab= line is dropped at the next save bool debug_shown() { return true; } int tabs_shown() { return debug_shown() ? TAB_COUNT : TAB_COUNT - 1; } // (Triforce) Inside the game's own Options screen. host/oot_menu.c says each frame that screen runs (menu_option_set, // HOS_OPT_GAME_OPTIONS). While it does, the options' tabs are drawn over its header with one more in front, "Game": the // game's own list, which stays the game's (drawn by it, its input its own). L and R (the buttons the Switch's L and R are // bound to, or their keys: Q and E are the game's own keys there) go on to our tabs and back; on ours the game's list, // caption and guides are under the same plates, ours, which are opaque. Back on one of ours is the game's Back too // (host/nn_hid.c). TRIFORCE_OPTIONS_TABS=0: off (the game's Options as it is, ours through F1 alone) std::atomic game_options_ns{0}; // (prof_now at the last frame the host said so; 0 never) bool embed_open = false; // (our tabs are open from inside the game's Options: leaving them is its own tab again) int64_t embed_since = 0; // (when that screen was first seen running: the tabs fade in over its opening) constexpr int kGameTab = 99; // (the tabs' hit for the game's own tab) // ((Triforce) the mouse over the tabs on the game's own tab (draw_game_tab): their shift in the window, as menu_ox is draw_menu's, // and whether the mouse has been read since the game's screen came: a click from before is not the tabs') float game_tab_ox = 0; bool game_tab_read = false; bool hits_game_tab = false; // (the hits are draw_game_tab's: its tabs were drawn last, not the open menu) // (Triforce) Mods: an entry of the tab strip after System (before Debug) that opens a page of its own, kModsPage (vk_mods.h: // GameBanana's mods for this game, installed into the mods folder). Not a MenuTab: it has no rows constexpr int kModsTab = 98; // (the tabs' hit for it, and draw_tabs' sel while its page is open) constexpr int kModsPage = 8; // (page: 0 the options, 1 controls, 3 teleport, 4 inventory, 5 the restart question, 6 names) int mods_choice = 0; // (the card chosen) float mods_scroll_px = 0, mods_want_px = 0; int mods_wheel = 0, mods_page_rows = 1; // ((Triforce) 11-17, his "theres not even a way to scroll down on the mods description on the right side") The description's // own scroll: the right stick, or the mouse wheel over the details; back to its top when the choice moves int mods_desc_wheel = 0, mods_desc_for = -2; // ((Triforce) 11-17, his layout A) The Mods screen's categories, a strip of tabs under the banner turned by L and R: the loaded // list filtered by GameBanana's root category (or installed). A mod whose category none names is in All alone constexpr int kModsCats = 6; const char* const kModsCatNames[kModsCats] = {"All", "Gameplay", "Models", "Audio", "Interface", "Installed"}; int mods_cat = 0; int mods_cat_pick = -1; // (a click on a category's tab: taken by the next tick) /// ((Triforce) 11-18) after a card's author and category: a WiP or a kit (a program of its own) says so std::string mods_kind(const mods::Mod& m) { return m.kit ? " \xC2\xB7 Own program" : m.wip ? " \xC2\xB7 Work in progress" : ""; } bool mods_in_cat(const mods::Mod& m, int cat) { auto has = [&m](const char* w) { return m.category.find(w) != std::string::npos; }; switch (cat) { case 1: return has("Gameplay") || has("Mechanic") || has("Cheat"); case 2: return has("Model") || has("Texture") || has("Skin") || has("Character"); case 3: return has("Audio") || has("Sound") || has("Music") || has("Voice"); case 4: return has("UI") || has("HUD") || has("Interface") || has("Menu") || has("Font"); case 5: return m.installed; default: return true; } } float mods_desc_px = 0, mods_desc_x0 = 1e9f; uint32_t menu_pad_raw = 0; // (the pads' bits at this tick, host/nn_hid.c hos_pad_raw: the sticks' menu bits too) bool mods_follow = true; // (the cards follow the choice; the wheel lets go of it until the choice moves) int mods_btn = 0; // (a dialog's button chosen: 0 the upper one) // (Triforce) The Mods entry under a game list's last button (host/oot_menu.c tells where: HOS_OPT_MODS_*): the pause menu's // System page and the title's list. While the cursor is on it the menu is "open" on kModsRowPage, which draws the entry alone // over the game's list (the game's input is ours then, and the host lets its cursor go); A opens kModsPage constexpr int kModsRowPage = 9; std::atomic mods_list_bits{0}; // (HOS_MODS_LIST_*, as the last report had them) std::atomic mods_box[5]; // (the last button's box and the pitch, the layout's units: x0 x1 y0 y1 pitch) std::atomic mods_list_ns{0}; // (prof_now at the last report) std::atomic mods_enter{0}; // (the host's word: 1 the cursor onto the entry, 2 a click on it) std::atomic mods_press{0}; // (presses the host passed on while Mods has the cursor: HOS_MODS_PRESS_*) // ((Triforce) 11-19, the owner: "I want quit and restart moved from our custom settings menu to [under Mods on the pause menu's // System page]. IT NEEDS TO LOOK NATIVE". One button fits under Mods at the list's own pitch above the prompts, so it is Quit, // as the game's own button, and its dialog asks Quit Game / Restart Game / Cancel (his choice). The title's list has Mods only) int mods_row_sel = 0; // (the entry with the cursor: 0 Mods, 1 Quit) bool quit_ask = false; // (Quit's dialog is open) int quit_sel = 0; // (its choice: 0 Quit Game, 1 Restart Game, 2 Cancel) bool quit_entry_shown() { return (mods_list_bits.load(std::memory_order_relaxed) & HOS_MODS_LIST_TITLE) == 0; } bool mods_list_fresh() { const int64_t t = mods_list_ns.load(std::memory_order_relaxed); return t && prof_now() - t < 150000000LL; } // ((Triforce) 11-17, his ask "We need a search bar for mods") The Mods screen's search: a bar above the cards (mods_choice -1 is // the bar), typed into from the keyboard anywhere on the screen (host/display.c: HOS_OPT_TEXT_CHAR), or from a keyboard of the // game's look on the screen for a controller (A on the bar). The text is searched 0.5 s after the typing stops, or at once // with Confirm; fewer than 2 characters is the whole list again, where it was (vk_mods.cpp search) std::string mods_query; // (the bar's text as typed, UTF-8) std::string mods_query_sent; // (the text the list is the search of) int64_t mods_query_edit_ns = 0; // (the last change of the text) bool mods_kbd = false; // (the on-screen keyboard open) int mods_kbd_row = 1, mods_kbd_col = 0; int mods_browse_choice = 0; // (the whole list's choice and scroll when a search began: given back when it ends) float mods_browse_px = 0; std::mutex mods_typed_mu; std::vector mods_typed; // (code points typed, from the window's thread: taken by mods_tick) std::atomic mods_text_wanted{false}; float mods_kbd_box[4] = {0, 0, 0, 0}; // (the on-screen keyboard's box as last drawn, pixels: x0 y0 x1 y1) // (the keyboard: four rows of ten keys, the letters shown capital and typed small, and a row of Space, Delete, Clear, Search) const char* const kKbdRows[4] = {"1234567890", "qwertyuiop", "asdfghjkl'", "zxcvbnm-.&"}; const char* const kKbdWide[4] = {"Space", "Delete", "Clear", "Search"}; constexpr int kKbdWideAt[5] = {0, 4, 6, 8, 10}; // (the wide keys' first columns, and the row's end) int kbd_wide(int col) { return col < 4 ? 0 : col < 6 ? 1 : col < 8 ? 2 : 3; } void utf8_add(std::string& s, int cp) { if (cp < 0x80) s += (char)cp; else if (cp < 0x800) s += (char)(0xC0 | cp >> 6), s += (char)(0x80 | (cp & 63)); else if (cp < 0x10000) s += (char)(0xE0 | cp >> 12), s += (char)(0x80 | (cp >> 6 & 63)), s += (char)(0x80 | (cp & 63)); else s += (char)(0xF0 | cp >> 18), s += (char)(0x80 | (cp >> 12 & 63)), s += (char)(0x80 | (cp >> 6 & 63)), s += (char)(0x80 | (cp & 63)); } bool utf8_pop(std::string& s) { // (the last character, all its bytes) if (s.empty()) return false; while (!s.empty() && ((unsigned char)s.back() & 0xC0) == 0x80) s.pop_back(); if (!s.empty()) s.pop_back(); return true; } bool embed_allowed() { static const bool on = !getenv("TRIFORCE_OPTIONS_TABS") || atoi(getenv("TRIFORCE_OPTIONS_TABS")) != 0; return on; } /// (Triforce, 11-13, the user: "Remove f1 menu (we have it in options now natively)") Whether Insert, F1, a gamepad's Home and /// Select+Start open these options over the game from anywhere. Not any more: they are the tabs inside the game's own /// Options screen. TRIFORCE_INGAME_MENU=1 (triforce_env.txt) brings the keys back; with TRIFORCE_OPTIONS_TABS=0 (no tabs in /// the game's screen) they stay, or there would be no way to the options at all bool overlay_allowed() { static const bool on = (getenv("TRIFORCE_INGAME_MENU") && atoi(getenv("TRIFORCE_INGAME_MENU")) != 0) || !embed_allowed(); return on; } /// The game's Options screen ran within the last quarter second bool game_options_shown() { const int64_t t = game_options_ns.load(std::memory_order_relaxed); return embed_allowed() && t && prof_now() - t < 250000000LL; } // (a line shown for a moment at the foot of the screen: the Debug tab unlocked or locked while the options are closed) char notice_text[64] = ""; int64_t notice_until = 0; std::atomic protect_hearts{-1}; // -1 disables the shortcut, 0 enables it on the ground, and 1 means flying. std::atomic player_flight{-1}; std::atomic free_camera{0}; std::atomic cheat_action{0}; std::atomic link_age{-1}; // (the game side's report, OOT_CHEAT_AGE_ID: 0 child, 1 adult, -1 no save loaded) int clock_hour = 12; int pouch_item = 0; int pouch_delta = 1; constexpr const char* pouch_items[] = {"Deku Seeds", "Deku Nuts", "Deku Sticks", "Bombs", "Arrows"}; constexpr int kPouchItems = sizeof pouch_items / sizeof pouch_items[0]; // (teleport list: generated by work/oot-teleport-tools/write_destinations.py) // (the order of oot_destinations in host/hos_main.c; Enter sends 1000 + the index) constexpr const char* teleport_names[] = { "Kokiri Forest", "Hyrule Field", "Kakariko Village", "Market", "Hyrule Castle", "Lost Woods", "Sacred Forest Meadow", "Lake Hylia", "Graveyard", "Death Mountain Trail", "Death Mountain Crater", "Goron City", "Zora's River", "Zora's Domain", "Zora's Fountain", "Gerudo Valley", "Gerudo Fortress", "Haunted Wasteland", "Desert Colossus", "Inside the Deku Tree", "Dodongo's Cavern", "Jabu-Jabu's Belly", "Forest Temple", "Fire Temple", "Water Temple", "Shadow Temple", "Spirit Temple", "Bottom of the Well", "Ice Cavern", "Gerudo Training Ground", "Ganon's Castle"}; constexpr const char* teleport_notes[] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "adult only", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; struct TeleportSection { const char* name; int first; }; constexpr TeleportSection teleport_sections[] = {{"Overworld", 0}, {"Dungeons", 19}}; constexpr int kTeleportSections = sizeof teleport_sections / sizeof teleport_sections[0]; // (end of the generated teleport list) constexpr int kTeleports = sizeof teleport_names / sizeof teleport_names[0]; int teleport_choice = 0; int teleport_columns = 1, teleport_page_rows = 1; // (as last drawn: the cards in a row, the rows that fit: Page Up / Down) float teleport_scroll_px = 0, teleport_want_px = 0; // (the cards' scroll, eased toward teleport_want_px) bool teleport_follow = true; // (the scroll follows the choice; the wheel lets go of it until the choice moves) int teleport_wheel = 0; // (the wheel's notches since the last drawing: it scrolls by them) int teleport_section_of(int i) { int section = 0; while (section + 1 < kTeleportSections && i >= teleport_sections[section + 1].first) ++section; return section; } int teleport_section_end(int section) { return section + 1 < kTeleportSections ? teleport_sections[section + 1].first : kTeleports; } /// The destination rows rows down (up when negative) from i, in the grid the Teleport page draws: each section's cards /// teleport_columns to a row, under the section's heading; the column kept where the next row has it int teleport_step_rows(int i, int rows) { const int cols = std::max(1, teleport_columns); for (; rows > 0; --rows) { const int section = teleport_section_of(i), first = teleport_sections[section].first, end = teleport_section_end(section); const int p = i - first; if (p + cols < end - first) i += cols; else if (p / cols < (end - first - 1) / cols) i = end - 1; // (the section's last row, a short one) else if (section + 1 < kTeleportSections) i = std::min(end + p % cols, teleport_section_end(section + 1) - 1); else break; } for (; rows < 0; ++rows) { const int section = teleport_section_of(i), first = teleport_sections[section].first, p = i - first; if (p >= cols) i -= cols; else if (section > 0) { const int prev = teleport_sections[section - 1].first, n = first - prev; i = std::min(prev + (n - 1) / cols * cols + p, first - 1); } else break; } return i; } // the Inventory page (gpu/vk/oot_cheat_items.h): items and their section headings, counts from the game side #define OOT_MENU_ITEM_LABEL(label, name, kind) label, #define OOT_MENU_ITEM_KIND(label, name, kind) kind, #define OOT_MENU_NO_SECTION(name) constexpr const char* item_names[] = {OOT_CHEAT_ITEMS(OOT_MENU_NO_SECTION, OOT_MENU_ITEM_LABEL)}; constexpr unsigned char item_kinds[] = {OOT_CHEAT_ITEMS(OOT_MENU_NO_SECTION, OOT_MENU_ITEM_KIND)}; constexpr int kItems = sizeof item_names / sizeof item_names[0]; // (each section's first item: a counter that a section heading reads and an item bumps) constexpr int item_section_count() { int n = 0; #define OOT_MENU_COUNT_SECTION(title) n++; #define OOT_MENU_SKIP_ITEM(label, name, kind) OOT_CHEAT_ITEMS(OOT_MENU_COUNT_SECTION, OOT_MENU_SKIP_ITEM) return n; } constexpr int kItemSections = item_section_count(); struct ItemSections { TeleportSection s[kItemSections]; }; constexpr ItemSections make_item_sections() { ItemSections r{}; int section = 0, item = 0; #define OOT_MENU_ADD_SECTION(title) r.s[section].name = title, r.s[section].first = item, section++; #define OOT_MENU_ADD_ITEM(label, name, kind) item++; OOT_CHEAT_ITEMS(OOT_MENU_ADD_SECTION, OOT_MENU_ADD_ITEM) return r; } constexpr ItemSections item_sections = make_item_sections(); std::atomic item_counts[kItems]; // (-1 until the game side reports: OOT_CHEAT_ITEM_BASE + i) int item_choice = 0; int inventory_columns = 1, inventory_capacity = 1; // (as last drawn: the cards in a row, on a page) int inventory_filter = 0; // (All, then the item sections) int inventory_page = 0; // (the page shown: the choice's, or another the wheel turned to) bool inventory_amount = false; // (Left and Right change the chosen item's amount) int inventory_begin() { return inventory_filter ? item_sections.s[inventory_filter - 1].first : 0; } int inventory_end() { return inventory_filter && inventory_filter < kItemSections ? item_sections.s[inventory_filter].first : kItems; } void inventory_reveal() { inventory_page = (item_choice - inventory_begin()) / std::max(1, inventory_capacity); } void choose_inventory_filter(int filter) { inventory_filter = filter; item_choice = inventory_begin(); inventory_amount = false; inventory_reveal(); } constexpr int kCheatRows = 14; // (the debug tools' rows: Row::cheat 0 to 13; 11 to 13 Triforce's name pages) /// A debug tool's value as its row shows it ("" an action: confirm does it) std::string cheat_value(int i) { char t[16]; switch (i) { case 0: return tx_onoff(protect_hearts.load() == 1); case 1: return tx_onoff(player_flight.load() >= 0); case 4: return snprintf(t, sizeof t, "%02d:00", clock_hour), t; case 5: return pouch_items[pouch_item]; case 6: return snprintf(t, sizeof t, "%+d", pouch_delta), t; case 7: return tx_onoff(free_camera.load()); default: return ""; } } /// The tools that choose with Left and Right (arrows at their value's ends): Set time, Inventory item, Change quantity bool cheat_chooses(int i) { return i == 4 || i == 5 || i == 6; } /// Switch age as Kid | Adult, Link's age lit: once the game side has said it (a save loaded) bool age_shown(int i) { return i == 9 && link_age.load(std::memory_order_relaxed) >= 0; } /// What confirm does on a tool's row, for its prompt (nullptr: nothing) const char* cheat_confirm(int i) { static const char* const says[kCheatRows] = {"Toggle", "Toggle", "Apply", "Apply", "Set", nullptr, "Apply", "Toggle", "Open list", "Switch", "Open", "Open list", "Open list", "Open list"}; return i >= 0 && i < kCheatRows ? says[i] : nullptr; } constexpr int kRows = sizeof rows / sizeof rows[0]; int cur_tab = TAB_DISPLAY; int tab_selected[TAB_COUNT + 1] = {}; // (and the Motion page's) bool is_motion_row(const Row& r) { return r.tab == TAB_CONTROLS && !r.value && !strcmp(r.name, "Motion"); } // (Triforce) The System tab's rows that act on a press, after NX2navi's: Export save, Export save for a bug report, Import a // save and Bug capture. The work is the host's, on a thread of its own (host/save_share.c, host/bug_capture.c): a press leaves // what was asked for it to take (HOS_OPT_SHARE_ASK), and it sends back the line the row shows under its help // (HOS_OPT_SHARE_TEXT, HOS_OPT_SHARE_SAID). /// Which of them a row is: its HOS_SHARE_* (vk_api.h), what the host is asked and its place in share_lines; 0: none int share_row(const Row& r) { if (r.tab != TAB_SYSTEM || r.value || r.cheat >= 0) return 0; if (!strcmp(r.name, "Export save")) return HOS_SHARE_EXPORT; if (!strcmp(r.name, "Export save for a bug report")) return HOS_SHARE_EXPORT_BUG; if (!strcmp(r.name, "Import a save")) return HOS_SHARE_IMPORT; if (!strcmp(r.name, "Bug capture (F8)")) return HOS_SHARE_CAPTURE; return 0; } std::atomic share_ask{0}; // (what a row asked for, until the host takes it) std::atomic share_import_waits{0}; // (an imported save waits for the next start: the Import row cancels it) std::atomic share_busy_until{0}; // (a press waits for the host's answer until then: no second one meanwhile) std::atomic share_busy_row{0}; // (the row that press was on: its line is the answer) std::mutex share_mu; // (the lines: the host's thread writes them, the drawing reads them) std::string share_in; // (the line the host is sending, a byte a call) std::string share_lines[HOS_SHARE_NOTICE + 1]; // (by HOS_SHARE_*: what each row shows under its help; the notice's until shown) std::atomic share_notice_new{false}; // (a line for the foot of the screen came: menu_tick shows it) constexpr const char* kShareWorking = "Working..."; /// What a share row shows in its value's place and in the guides: what a press does const char* share_label(int row) { if (row == HOS_SHARE_CAPTURE) return "Capture"; if (row != HOS_SHARE_IMPORT) return "Export"; return share_import_waits.load(std::memory_order_relaxed) ? "Cancel the import" : "Import"; } /// The line under a share row's help: the host's last word on it std::string share_line(int row) { std::lock_guard lk(share_mu); if (share_lines[row] == kShareWorking && prof_now() > share_busy_until.load(std::memory_order_relaxed)) return "The game did not answer. Try again in a moment."; return share_lines[row]; } /// A press on a share row: asked of the host, once until it answers (or ten seconds went by) void share_press(int row) { const int64_t now = prof_now(); if (now < share_busy_until.load(std::memory_order_relaxed)) return; share_busy_until.store(now + 10000000000LL, std::memory_order_relaxed); share_busy_row.store(row, std::memory_order_relaxed); { std::lock_guard lk(share_mu); share_lines[row] = kShareWorking; } const bool cancel = row == HOS_SHARE_IMPORT && share_import_waits.load(std::memory_order_relaxed); share_ask.store(cancel ? HOS_SHARE_IMPORT_CANCEL : row, std::memory_order_relaxed); } // ---- the rows that take a restart: their values at the start (menu_init, the GPU's at menu_set_gpu_count) ---- namespace mr = menu_restart; mr::State restart_state; int restart_slot[kRows]; // (a row's slot in restart_state, -1 none) const char* restart_names[mr::kMax]; void restart_init() { static bool done = false; if (done) return; done = true; for (int i = 0; i < kRows; i++) { restart_slot[i] = rows[i].restart && rows[i].value ? restart_state.add(*rows[i].value) : -1; if (restart_slot[i] >= 0) restart_names[restart_slot[i]] = rows[i].name; } } int restart_slot_of(const Row& r) { return restart_slot[&r - rows]; } /// A row that takes a restart, changed from what the game started with (a row past menu_restart.h's kMax has no slot: never) bool restart_changed(const Row& r) { const int slot = restart_slot_of(r); return r.value && r.restart && slot >= 0 && *r.value != restart_state.start[slot]; } void restart_values(int* now) { for (int i = 0; i < kRows; i++) if (restart_slot[i] >= 0) now[restart_slot[i]] = *rows[i].value; } /// The rows whose value is not the one the game runs with (a bit a slot) unsigned restart_pending() { int now[mr::kMax]; restart_values(now); return restart_state.pending(now); } /// Whether closing the menu now asks to restart: something pending, not declined with Later, and a window to close bool restart_ask() { int now[mr::kMax]; restart_values(now); return app_window() && restart_state.ask(now); } std::string restart_list(const char* last) { return mr::names(restart_names, restart_state.n, restart_pending(), ", ", last); } int ask_sel = 0; // (the restart question's choice: 0 Later, 1 Restart now) /// A row on its tab: the debug tools only with them on, the Upscaler only in a build with DLSS or FSR 4, or where AMD /// FSR 3.1 runs bool rdx_row(const int* v) { // (local, RenoDX port) return v == &opts.rdx_tonemap || v == &opts.rdx_midgray || v == &opts.rdx_ui_white || v == &opts.rdx_space || v == &opts.rdx_exposure || v == &opts.rdx_highlights || v == &opts.rdx_shadows || v == &opts.rdx_contrast || v == &opts.rdx_saturation || v == &opts.rdx_bloom || // (Triforce: NX2navi's HDR rows) v == &opts.rdx_gamma || v == &opts.rdx_match_slope || v == &opts.rdx_tone_slope || v == &opts.rdx_hue_clip || v == &opts.rdx_highlight_sat || v == &opts.rdx_blowout || v == &opts.rdx_flare || v == &opts.rdx_hue || v == &opts.rdx_grade; } /// (Triforce) A RenoDX row applies to the tonemapper chosen: the rows only PsychoV35 reads show with PsychoV35 (1), those /// only RenoDRT reads with RenoDRT (2); every other row whatever is chosen, as before bool rdx_applies(const int* v) { if (v == &opts.rdx_match_slope || v == &opts.rdx_tone_slope || v == &opts.rdx_hue_clip) return opts.rdx_tonemap == 1; if (v == &opts.rdx_highlight_sat || v == &opts.rdx_blowout || v == &opts.rdx_flare || v == &opts.rdx_hue || v == &opts.rdx_grade) return opts.rdx_tonemap == 2; return true; } /// (Triforce) The Frame generation row ends at AMD FSR 4 only where AMD's library can make the frames (vk_fsr4.h fsr4fg, /// framegen_rows.h row_hi), and at 8x elsewhere, the row as it was. Asked when the menu opens, as the Upscaler's choices are. /// The table's own end is AMD FSR 4, so an options file with it loads as it is, before the graphics card is known; a saved /// AMD FSR 4 that cannot run here stays saved, shows as 2x (tx_framegen) and the arrows leave it for 8x or Off. (Triforce) As /// known: the library is asked off the menu's thread (menu_ahead), and the row is set again once it has answered void framegen_row_sync() { static_assert(framegen_rows::kRowMax == 9, "the Frame generation row's entry in rows[] ends at 9"); for (Row& r : rows) if (r.value == &opts.framegen) r.hi = framegen_rows::row_hi(fsr4fg::offered_known()); } // (Triforce) What the rows ask of NVIDIA's and AMD's libraries: whether DLSS, AMD FSR 4 and FSR 4's frame generation run // here. Asked at the menu's open on its thread (the presenting one), NGX's start and AMD's loader held the first open of // the options 2.1 s (test11). Now asked once, on a thread of its own, once the game's first frame is up (menu_tick), or at an open // before that; until the answers are in, the rows show what is known (DLSS and FSR 4 as offered, AMD FSR 4's frame // generation as not known yet), and are set again when they come. A choice of DLSS or FSR 4 before then starts it where it // runs, as before (its start waits for the answer there). The probes are the libraries' own (dlss_probe, fsr4_probe, // fsr4fg::why): once each, under their own locks. TRIFORCE_MENU_AHEAD=0: asked at the open on the menu's thread, as before std::atomic ahead_state{0}; // (0 not asked, 1 being asked, 2 answered) bool ahead_allowed() { static const bool on = !getenv("TRIFORCE_MENU_AHEAD") || atoi(getenv("TRIFORCE_MENU_AHEAD")) != 0; return on; } void ahead_thread() { const int64_t t0 = prof_now(); dlss_probe(); const int64_t t1 = prof_now(); fsr4_probe(); const int64_t t2 = prof_now(); (void)fsr4fg::why(); const int64_t t3 = prof_now(); logf("menu: the upscalers asked ahead of the menu, on a thread of their own: NVIDIA DLSS %.0f ms, AMD FSR 4 %.0f ms, its frame " "generation %.0f ms", (t1 - t0) / 1e6, (t2 - t1) / 1e6, (t3 - t2) / 1e6); ahead_state.store(2, std::memory_order_release); } void menu_ahead() { if (!dev.device) return; if (!ahead_allowed()) { // (as before: on this thread, at the open) dlss_probe(), fsr4_probe(), (void)fsr4fg::why(); ahead_state.store(2, std::memory_order_release); return; } int none = 0; if (ahead_state.compare_exchange_strong(none, 1)) std::thread(ahead_thread).detach(); } bool heading_over_shown(int i); bool row_shown(int i) { return (rows[i].cheat < 0 || cheats_on()) && // ((Triforce) 11-17, the tabs in sections: a heading only over a row shown, RenoDX's with no RenoDX build not left bare) (!rows[i].heading || heading_over_shown(i)) && (rows[i].value != &opts.dlss || ur::upscaler_shown(dlss_built() || fsr4_built(), fsr3::supported())) && (rows[i].value != &opts.dlss_model || ur::model_shown(dlss_built())) && // (local, RenoDX port: its rows with HDR Native, in a build with its shaders; Triforce: and its own row on, and // of the rows one tonemapper alone reads those of the one chosen) (!rdx_row(rows[i].value) || (opts.hdr == 2 && renodx_built() && opts.renodx && rdx_applies(rows[i].value))) && (rows[i].value != &opts.renodx || renodx_built()) && #ifndef _WIN32 // (Triforce: the lazy write-back's fault handler pays on Windows only, vk_memory.cpp) rows[i].value != &opts.lazy_write_back && #endif // (Triforce, 11-13: the Menu shortcut row chooses the keys that open the options from anywhere: gone with them) (rows[i].value != &opts.menu_shortcut || overlay_allowed()) && // (Triforce: the Game language row only with a language.txt that names languages to choose from) (rows[i].value != &opts.language || lang_count > 1) && // (Triforce: the mods' cheats: as many rows as the host named, and their heading with them) (!rows[i].heading || strcmp(rows[i].name, kModCheatHeading) || mod_cheats.shown() > 0) && (mod_cheat_slot(rows[i].name) < 0 || mod_cheat_slot(rows[i].name) < mod_cheats.shown()); } bool heading_over_shown(int i) { // (the rows of its tab after it, to the next heading: one of them shown) for (int j = i + 1; j < kRows; j++) { if (rows[j].tab != rows[i].tab) continue; if (rows[j].heading) return false; if (row_shown(j)) return true; } return false; } int tab_row_count(int t) { int c = 0; for (int i = 0; i < kRows; i++) if (rows[i].tab == (MenuTab)t && row_shown(i)) c++; return c; } int tab_row_to_global(int t, int local_idx) { int count = 0; for (int i = 0; i < kRows; i++) { if (rows[i].tab == (MenuTab)t && row_shown(i)) { if (count == local_idx) return i; count++; } } return 0; } std::atomic open_now{false}; bool menu_refresh = false; // (a value too long for its row, a GPU's name: the selected row's slides through it, a character a step, resting at // each end; the other rows end it with "...". The drawing (fit) says how far it can slide, menu_tick moves it) int marquee_pos = 0, marquee_max = 0; int64_t marquee_next = 0; constexpr int64_t kMarqueeStep = 150000000LL, kMarqueeRest = 1200000000LL; // (ns) // (hookshot) the mouse (menu_tick): the tab strip's part under the cursor (a tab 0 to TAB_COUNT - 1, TAB_COUNT the previous, // TAB_COUNT + 1 the next; -1 none); the slider held with the left button (its row in the tab, -1 none) int hover_tab = -1; int drag_row = -1; bool mouse_read = false; // (the menu has read the mouse since it opened) bool is_slider(const Row& r) { return r.value == &opts.sharpness || r.value == &opts.mouse_sens || r.value == &opts.gyro_sens_x || r.value == &opts.gyro_sens_y; } /// (a scale: the arrows and a click stop at its ends; Rumble strength would go from Off to its strongest) bool stops_at_ends(const Row& r) { return r.value == &opts.mouse_sens || r.value == &opts.rumble || r.value == &opts.rumble_curve || r.value == &opts.lstick_dead_zone || r.value == &opts.rstick_dead_zone || r.value == &opts.walk_scale || r.value == &opts.gyro_sens_x || r.value == &opts.gyro_sens_y; } /// (the ini's Rumble strength on the menu's steps: 0 to 300, the nearest 25) int rumble_step(int v) { return (std::min(std::max(v, 0), 300) + 12) / 25 * 25; } std::string ini_path() { char exe[MAX_PATH]; const DWORD n = game_module_path(exe, MAX_PATH); std::string dir(exe, n); return dir.substr(0, dir.find_last_of("\\/") + 1) + "triforce_options.ini"; } const char* ini_key(const Row& r) { if (r.value == &opts.output_res) return "output_res"; // (host/nn_applet.c reads it at the start) // (rows renamed since their values were first saved keep their keys: an options file from before still loads) if (r.value == &opts.resolution) return "resolution"; if (r.value == &opts.fps_cap) return "frame_rate_cap"; // (host/nn_vi.c reads it at the start) if (r.value == &opts.upscale) return "upscaling"; if (r.value == &opts.dlss) return "dlss"; // (as opts.dlss and RX_VK_DLSS) // ((Triforce) NX2navi's key, not the name cut at 31 letters; vk_replay.cpp tail_wanted reads it at the start) if (!strcmp(r.name, "Start next frame early")) return "tail_early"; static char k[32]; size_t n = 0; for (const char* p = r.name; *p && n + 1 < sizeof k; p++) k[n++] = *p == ' ' ? '_' : (char)tolower(*p); k[n] = 0; return k; } /// (Triforce) A row kept in triforce_options.ini: every row with a value but the Game language, whose choice is /// language.txt's bool ini_row(const Row& r) { return r.value && r.value != &opts.language; } // ((Triforce, handoff ยง9) The options file's other writers. ini_base: what the game had for each of the file's lines when it last // read (menu_init) or wrote (save) the file; save merges each line it writes by its key with what the file has now // (ini_merge.h) and writes the file whole (file_whole.h: a reader at a start, the host's or the renderer's, never meets half a // file). RX_VK_OPTIONS_MERGE=0: the game's own values written over the file in place, as before) ini_merge::Map ini_base; std::mutex ini_mu; // (save runs on the presenting thread and, for the mouse's sensitivity keys, on the host's: option 7) bool options_merge_on() { static const bool on = !(getenv("RX_VK_OPTIONS_MERGE") && !strcmp(getenv("RX_VK_OPTIONS_MERGE"), "0")); return on; } // (Triforce) the Game language row's file, beside the options file: the game folder's language.txt std::string lang_path() { const std::string ini = ini_path(); return ini.substr(0, ini.find_last_of("\\/") + 1) + "language.txt"; } /// Its bytes as they are (64 KiB at most: a larger file is not that one) bool lang_read(std::string& text) { constexpr size_t kMost = 65536; text.clear(); FILE* f = fopen(lang_path().c_str(), "rb"); if (!f) return false; char part[4096]; for (size_t n; text.size() <= kMost && (n = fread(part, 1, sizeof part, f)) > 0;) text.append(part, n); fclose(f); return text.size() <= kMost; } /// The file written whole beside it and put in its place, so that a write that fails leaves the file as it was bool lang_write(const std::string& text) { const std::string path = lang_path(), fresh = path + ".new"; FILE* f = fopen(fresh.c_str(), "wb"); if (!f) return false; bool ok = fwrite(text.data(), 1, text.size(), f) == text.size(); ok = fclose(f) == 0 && ok; #ifdef _WIN32 ok = ok && MoveFileExA(fresh.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING) != 0; #else ok = ok && rename(fresh.c_str(), path.c_str()) == 0; #endif if (!ok) remove(fresh.c_str()); return ok; } /// The row from the file, at the start: its entries, and the one the file chooses (English (US) when it chooses none, as /// the host answers then) void lang_load() { std::string text; lang_count = 0, lang_saved = -1; if (lang_read(text)) { const gl::File f = gl::read(text); lang_count = gl::offered(f, lang_entries); const int now = f.chosen >= 0 ? f.chosen : gl::kDefault; for (int i = 0; i < lang_count; i++) if (lang_entries[i] == now) lang_saved = i; } if (lang_saved < 0) lang_count = 0; opts.language = std::max(lang_saved, 0); for (Row& r : rows) if (r.value == &opts.language) r.hi = std::max(lang_count - 1, 0); } /// At a save: the row's choice into language.txt, when it is not the file's already. The file is read again first (it may /// have been edited since the start) and only its choice line changes; a language it no longer names is not written, and /// the row goes back to the file's void lang_store() { if (lang_count < 2 || opts.language == lang_saved || opts.language < 0 || opts.language >= lang_count) return; const int language = lang_entries[opts.language]; std::string text; bool ok = false; if (lang_read(text)) { const std::string out = gl::write(text, language); ok = gl::read(out).chosen == language && (out == text || lang_write(out)); } lang_failed = !ok; if (ok) { lang_saved = opts.language; logf("menu: the game's language from the next start: %s (language.txt)", gl::kLanguages[language].code); } else { logf("menu: language.txt could not be written, or no longer names %s: the game's language stays as it was", gl::kLanguages[language].code); opts.language = lang_saved; } } // (hookshot) the controls, kept by the host (host/nn_hid.c reads them back from here): pad_