// 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. // (Triforce, options_version 7, the owner: "group them correctly, such as HDR should be its own group, the upscaling should be // its own group ... Add the in-game filigree to group them" and "multiple settings that do multiple things and they contradict // each other ... If a setting can be implemented in some other way, then remove the setting entirely") Each tab's rows come in // groups, each under a heading drawn as the game's list separator with the group's title (MENU_HEADING, ui::heading); a row // that does nothing with the others as they are is not shown (row_shown). The rows that chose one thing twice are one row each // (merged_rows.h: HDR with RenoDX, Frame generation with DLSS's, Frame pacing with Steady, Low latency for Reflex or Anti-Lag // 2, the Upscaler's native AA as the Render resolution's Native (100%)), and the Quality preset, the Window scaling filter, // the Reflex frame limit, the Handheld profile and the shared Stick dead zone are gone, their jobs done otherwise. #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_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 "vk_present_rect.h" // ((Triforce, options_version 7) where the picture goes in the window: the filter it takes) #include "text_spread.h" // ((Triforce, 11-19) the title entry's shadow and glow as the game's entries' #include "game_grid.h" // ((Triforce, 11-19) where the game's layouts are in the window: the Mods entry on its list) #include "merged_rows.h" // ((Triforce, options_version 7) the rows that each choose two saved values, and the older files' migration) #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 "mods_entry_anim.h" // ((Triforce, 11-19) the Mods entry under the title's list: the game's entries' animations) #include "focus_anim.h" // ((Triforce, 11-19) Mods and Quit under the System list, Quit's dialog: the game's buttons' and dialogs') #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) TAB_HIDDEN = TAB_PAGE + 1 // ((Triforce, options_version 7) saved values a merged row stands for: never shown, merged_rows.h) }; 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) // (a change here left the Quality preset alone: the controls, the window, the counter, frame generation. (Triforce, // options_version 7) The preset is gone and nothing reads it; the rows keep their shape) bool preset_exempt = false; 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. (FG-1) Named by the version AMD's library makes // the frames with: "AMD FSR (3.1.6)" on an RX 6000 or 7000, "AMD FSR (4.0.2)" on an RX 9000) static const char* t[] = {"Off", "Auto", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "AMD FSR"}; const int shown = std::clamp(framegen_rows::shown(v, fsr4fg::offered_known()), 0, (int)framegen_rows::kRowMax); // ((Triforce) as known: menu_ahead) if (shown != framegen_rows::FSR4) return t[shown]; static char label[32]; return framegen_rows::row_label(label, sizeof label, fsr4fg::version()); } 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."; } 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) namespace mr7 = merged_rows; /// ((Triforce, options_version 7) the HDR row: opts.hdr with RenoDX HDR as its fourth value, merged_rows.h) const char* tx_hdr_mode(int v) { return v == mr7::HDR_RENODX ? "Native + RenoDX" : tx_hdr(v); } MENU_HINTS(hn_hdr_mode, 0, "The usual SDR picture.", "The game's SDR picture shown on an HDR display: its white at Paper white, its highlights up to Peak brightness.", "The game's own HDR, told your display's Paper white and Peak brightness.", "The game's own HDR with RenoDX's tone mapping, eye adaptation and color grading in place of the game's (the RenoDX " "rows below). RenoDX is by Carlos Lopez (clshortfuse), under the MIT license.") 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, options_version 7) the Frame pacing row: Frame pacing and Steady frame rate in one, merged_rows.h) const char* tx_pacing(int v) { static const char* const t[] = {"Off", "Even", "Steady, any rate", "Steady, refresh steps"}; return t[std::clamp(v, 0, 3)]; } MENU_HINTS(hn_pacing, 0, "Each frame as soon as it is ready.", "Frames at an even interval: less stutter, at up to a frame of delay.", "The game paced to a rate this PC holds here, under the Frame rate cap, each frame shown evenly: for a display with " "G-SYNC or FreeSync, or VSync off. Applies after a restart.", "As Steady, any rate, kept to whole divisions of the refresh rate (at 240 Hz: 120, 80, 60): for VSync without G-SYNC or " "FreeSync. Applies after a restart.") // (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. (Triforce, // options_version 7) The Window scaling filter row is gone: those sizes choose the filter there, upscaler_rows.h auto_filter) std::atomic present_sizes{0}; // ((Triforce, options_version 7) The Low latency row: NVIDIA Reflex on an NVIDIA card, AMD Anti-Lag 2 on an AMD one, one row // for either (merged_rows.h); none where neither runs. With DLSS frame generation Reflex is Streamline's) mr7::Vendor latency_vendor() { return reflex_available() || mkwvk::dlssg::reflex_on() ? mr7::LATENCY_NVIDIA : antilag_available() ? mr7::LATENCY_AMD : mr7::LATENCY_NONE; } const char* tx_latency(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[std::clamp(v, 0, mr7::latency_hi(latency_vendor()))]; } /// Low latency: the value with NVIDIA Reflex (variants 0 to 2: each value's line), with AMD Anti-Lag 2 (3), or that Reflex runs /// through Streamline with DLSS frame generation (4) const char* hn_latency(int v, int variant) { static const char* const nv[] = {"Off.", "NVIDIA Reflex: each frame starts as late as it can, for less input delay.", "As On, and the graphics card's clocks are kept up as well."}; static const char* const amd[] = {"Off.", "AMD Anti-Lag 2: each frame starts as late as it can, for less input delay. Not " "used with frame generation."}; 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 graphics card's clocks up as well."; if (variant < 0) { if (mkwvk::dlssg::reflex_on()) return sl; return latency_vendor() == mr7::LATENCY_AMD ? amd[std::clamp(v, 0, 1)] : nv[std::clamp(v, 0, 2)]; } return variant == 0 ? nv[std::clamp(v, 0, 2)] : variant == 1 ? amd[std::clamp(v, 0, 1)] : variant == 2 ? sl : 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(); } /// ((Triforce, options_version 7) the engine alone: an engine's native AA is the Render resolution row's Native (100%)) const char* tx_upscaler(int) { static const char* t[ur::kUpscalers] = {"Game", "NVIDIA DLSS", "NVIDIA DLSS", "AMD FSR 3.1", "AMD FSR 4", "AMD FSR 4", "AMD FSR 3.1"}; // ((Triforce, FSR4-7) FSR 4 by the version AMD's library runs here, "AMD FSR 4.1", once it has been asked. up is the // engine (ur::engine), so FSR 4's Native AA reads as its engine too, "AMD FSR 4.1": the Render resolution says Native) const int up = ur::engine(std::clamp(upscaler(), 0, ur::kUpscalers - 1)); if (ur::is_fsr4(up)) return fsr4_name(up == ur::FSR4_AA); return t[up]; } /// 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] = { // ((Triforce, options_version 7) one line per engine: an engine's native AA is the Render resolution's Native (100%), // whose own line says so, and its value reads as its engine here (v = ur::engine(v) below). (S7) DLSS's line, DLAA's // too, names AMD's RCAS before the HUD; (FSR3-03) FSR 3.1 gives what moves by itself its own motion: no trails said) "The game's own upscaler.", "NVIDIA's, on RTX graphics cards. Sharpness sharpens its 3D before the HUD, with AMD's RCAS. Things that move by " "themselves can trail for now.", nullptr, "AMD's, on any graphics card, built from AMD's own shaders.", "AMD's machine-learned upscaler, with AMD's files beside the game. Things that move by themselves can trail for now.", nullptr, nullptr, }; 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 and driver: it needs a Radeon RX 6000, 7000 or 9000 and AMD's " "driver 26.10.1 or newer.", }; // ((Triforce, FSR4-1) the engine chosen, off after failing again and again: the game's own stands in for it. FSR 4 by the // version AMD's library ran, as the Upscaler row names it (fsr4_name: "AMD FSR 4.1"; "AMD FSR 4" until it was asked). // (The reasons above are for an FSR 4 that does not run here, whose version no library has given: its plain name) static char fsr4_stood_in[160]; snprintf(fsr4_stood_in, sizeof fsr4_stood_in, "The game's own stands in: %s failed four times in a row (the log says " "why). Set the Upscaler again to try it anew.", fsr4_name(false)); const char* const stood_in[2] = { "The game's own stands in: NVIDIA DLSS failed four times in a row (the log says why). Set the Upscaler again to try " "it anew.", fsr4_stood_in, }; // (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(); if (const int in = temporal_stood_in(); v == ur::GAME && in != ur::GAME) return stood_in[ur::is_fsr4(in) ? 1 : 0]; } 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 if (variant < DLSS_WHY_COUNT + FSR_WHY_COUNT + 1) return stood_in[variant - (DLSS_WHY_COUNT + FSR_WHY_COUNT - 1)]; else return nullptr; } else if (variant > 0) { return nullptr; } v = ur::engine(v); // ((Triforce, options_version 7) a native AA is its engine's: the Render resolution says Native) // (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: set for this run by RX_VK_DLSS_PRESET. ((Triforce, options_version 7) The row /// shows only while NVIDIA DLSS is the Upscaler: row_shown) 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 env = "Set for this run by RX_VK_DLSS_PRESET."; if (variant < 0) variant = dlss_preset_env() ? 1 : 0; if (variant == 1) 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) // ((Triforce, options_version 7) 7 is 1536x864, the game's handheld profile, which was a row of its own (Handheld profile) that // overrode this one: host/nn_applet.c runs the game undocked for it. kOutputOrder shows it first, the smallest) constexpr Out kOutputs[] = {{2048, 1152}, {2560, 1440}, {3840, 2160}, {1920, 1080}, {5120, 1440}, {5120, 2880}, {5120, 2160}, {1536, 864}}; constexpr int kLastOutput = std::size(kOutputs) - 1; static_assert(kLastOutput == merged_rows::kHandheldOutput, "the Output resolution row's handheld profile is merged_rows.h's"); 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[] = {7, 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 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 (ur::full_scale(up)) return "Native (100%)"; // ((Triforce, options_version 7) DLAA, FSR 4's and FSR 3.1's native AA) 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 (ur::full_scale(up)) // ((Triforce, options_version 7) Native (100%): the engine's native anti-aliasing) // ((Triforce, FSR4-2) chosen in play, the engine scales the smaller 3D up to the output until the next start) return "The 3D at the output's full size, its edges smoothed by the upscaler: the sharpest, and the slowest. The 3D " "takes its full size at the next start."; 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."; case 67: return "DLSS's Quality mode: its sharpest from a smaller 3D."; case 58: return "DLSS's Balanced mode, between Quality and Performance."; case 50: return "DLSS's Performance mode: faster, and softer."; case 33: return "DLSS's Ultra Performance mode: its fastest, and its softest."; 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, from frames the game's SMAA has not been over: nothing to set " "here. The choice is kept for the game's own upscaler.", "AMD FSR smooths the 3D's edges itself, from frames the game's SMAA has not been over: 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) { // ((Triforce, options_version 7) the rows that showed fixed where they could do nothing (Reflex, Anti-Lag, the window's // filter, the Render resolution with a native AA) are hidden there, or gone: row_shown) return (value == &opts.aa && aa_rows::fixed(upscaler(), aa_env_choice() >= 0)) || (value == &opts.dlss && ur::upscaler_fixed(upscalers_available())) || (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); if (v == merged_rows::kHandheldOutput) return "1536x864 (handheld)"; 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) // ((Triforce) 11-20) the GPU device row's card by its name (triforce_options.ini gpu_device_name, written beside the number by // the launcher and by save below; empty: none saved, or Auto). pick_device finds the card by it (gpu_choice.h pick) std::string gpu_want; 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]; } // (Triforce) a stick's own dead zone: XInput's own (~24%, the default), or 0% to 50%. ((Triforce, options_version 7) The shared // Stick dead zone row is gone: an older file's is each stick's own now, merged_rows.h migrate) const char* tx_own_dead_zone(int v) { return v < 0 ? "Default (24%)" : 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; } 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) { // ((Triforce, FG-1, FG-2, FG-5) AMD's library of either version, the HUD kept out of what it moves, and paused while // HDR Native or RenoDX's RGBA16F scene holds it from every present (fsr4fg::held, not the HDR row alone: HDR Native // without an HDR display is no pause, and RenoDX's scene stays for the run whatever the row says now). There the // renderer's own makes the frame, as at 2x (framegen_rows.h held_made). The last variant is that pause) static const char* const ok = "One made frame between each two of the game's, by AMD's frame generation library (its version " "is on the row) from the scene's depth and motion, the HUD kept where the game drew it."; static const char* const native = "Paused with HDR Native or RenoDX: AMD's needs the picture without the HUD, which only the " "game encodes there. The renderer's own makes the one frame, as at 2x; HDR Expanded works."; static const char* const no[framegen_rows::FG_WHY_COUNT] = { nullptr, "AMD FSR is not in this build: the renderer's own makes the one frame, as at 2x.", "AMD's frame generation 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 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) if (w == framegen_rows::FG_OK) return framegen_rows::held_whole_run(fsr4fg::held()) ? native : ok; return 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] : variant == (int)framegen_rows::FG_WHY_COUNT ? native : 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)]; } /// ((Triforce, options_version 7) The Frame generation row: the renderer's own and AMD FSR 4's (opts.framegen), then NVIDIA /// DLSS 2x to 4x (opts.dlssg), which was a row of its own: merged_rows.h) const char* tx_framegen_row(int v) { static const char* const dlss[] = {"NVIDIA DLSS 2x", "NVIDIA DLSS 3x", "NVIDIA DLSS 4x"}; return v >= mr7::FG_DLSS ? dlss[std::clamp(v - mr7::FG_DLSS, 0, 2)] : tx_framegen(v); } /// Frame generation: the renderer's own and AMD FSR 4's lines (hn_framegen), and for NVIDIA DLSS what runs, or that it starts /// with the next start (hn_dlssg) const char* hn_framegen_row(int v, int variant) { if (v < mr7::FG_DLSS) return hn_framegen(v, variant); if (variant > 1) return nullptr; if (variant == 0) return "NVIDIA DLSS frame generation, from the scene's depth and motion, with NVIDIA Reflex: RTX 40 and 50 cards."; if (variant == 1) return hn_dlssg(1, 0); return mkwvk::dlssg::asked() ? mkwvk::dlssg::status() : "Starts with the next start of the game."; } 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 game's handheld profile, as if the console were undocked: lighter on the graphics card, and softer.") // ((Triforce, options_version 7) the Window scaling filter row is gone, and with it its hint: the sizes choose the filter, // upscaler_rows.h window_filter. FSR 1's RCAS follows the Sharpness row: none at 0, vk_framegen.cpp framegen_scale) /// Sharpness: off at 0; ((Triforce, S1, S7) else where it sharpens: the upscaler's 3D before the HUD (variant 1), or the /// finished picture at the window (2). Variants: every line it can show const char* hn_sharpness(int v, int variant) { static const char* const t[3] = {"Off: the picture as it is.", "The upscaler sharpens the 3D before the HUD: the HUD and text stay as they are.", "The finished picture at the window, the HUD and text with it."}; if (variant < 0) variant = v == 0 ? 0 : temporal_sharpens_3d() ? 1 : 2; return variant < 3 ? t[variant] : nullptr; } 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 Xbox's for a controller that has no name, as with " "XInput alone. When the game starts with no controller: those of the device you used last in the game before, " "the keys' and the mouse's the first time.", 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. These menus show the buttons of a controller you use.") // (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"); // ((Triforce, options_version 7) The rows that each choose two saved values (merged_rows.h): their values as the rows show // them, made from the saved ones before each tick and each drawing (merged_sync) and written back to them by set_row // (merged_store). Never saved themselves (ini_row): the saved values keep their own keys, in the hidden rows below) struct Merged { int hdr = 0, framegen = 0, pacing = 0, latency = 0; }; Merged merged; bool is_merged(const int* v) { return v == &merged.hdr || v == &merged.framegen || v == &merged.pacing || v == &merged.latency; } // ((Triforce, options_version 7, the owner: "group them correctly, such as HDR should be its own group, the upscaling should be // its own group, etc. Add the in-game filigree to group them, separate them") A group's heading: the game's separator with // the group's title under it (ui::heading). The selection steps over it, the mouse has nothing on it, and it is hidden while // every row of its group is (row_shown). The Debug tab has its own layout and its one heading, Developer (debug_rows) #define MENU_HEADING(tab, title) {tab, title, nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true} Row rows[] = { // ---- Display ---- MENU_HEADING(TAB_DISPLAY, "Screen"), {TAB_DISPLAY, "Fullscreen", &opts.fullscreen, 0, 1, 1, tx_onoff, "The game fills the whole screen, without the window's border. F10 and Alt+Enter do the same.", nullptr, false, true}, {TAB_DISPLAY, "Output resolution", &opts.output_res, 0, kLastOutput, 1, tx_output_res, "The size of the game's whole frame, HUD included, before it is scaled to the window. 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}, MENU_HEADING(TAB_DISPLAY, "Ultrawide"), {TAB_DISPLAY, "Aspect ratio", &opts.ultrawide, 0, 3, 1, tx_ultrawide, "The shape of the picture: the game's own 16:9, or 16:10, 21:9 or 32:9 for a screen of that shape. A screen of another " "shape shows it between black bars. Applies after a restart.", hn_ultrawide, true}, // (Triforce: host/oot_wide_hud.c. Shown with a shape wider than 16:9: row_shown) {TAB_DISPLAY, "HUD position", &opts.wide_hud, 0, 1, 1, tx_wide_hud, "Where the hearts, the item buttons and the map sit. Middle: in the middle 16:9, as on a normal screen. Screen edges: " "in the screen's corners. Applies after a restart.", nullptr, true, true}, {TAB_DISPLAY, "Menu sides", &opts.wide_menus, 0, 2, 1, tx_wide_menus, "What is beside the pause, item and map menus, loading screens and movies, which are 16:9. Changes at once.", hn_wide_menus}, MENU_HEADING(TAB_DISPLAY, "HDR"), // (HDR and RenoDX HDR in one row: merged_rows.h. Off, Expanded and Native change at once, as the HDR row did; Native + // RenoDX, which the scene's format and RenoDX's shaders are chosen for at the start (host/nn_vi.c hos_scene_rgba16f), // after a restart: restart_value_of) {TAB_DISPLAY, "HDR", &merged.hdr, 0, 3, 1, tx_hdr_mode, "HDR10 on an HDR display (Windows: Use HDR on in the display settings). Native + RenoDX applies after a restart.", hn_hdr_mode, true, true}, {TAB_DISPLAY, "Paper white", &opts.hdr_white, 80, 400, 10, tx_nits, "How bright white is: around 200 nits for a normal room, higher for 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, "Peak brightness", &opts.hdr_peak, 400, 10000, 100, tx_nits, "The brightest highlights: set it to your display's peak brightness.", nullptr, false, true}, {TAB_DISPLAY, "UI brightness", &opts.rdx_ui_white, 80, 400, 10, tx_nits, "How bright the HUD's and the menus' white is with RenoDX. The scene's white is Paper white.", nullptr, false, true}, // (local, RenoDX port: vk_renodx.cpp. Shown with HDR Native + RenoDX, where its shaders run; the rows of one tone mapper // while it is chosen, rdx_applies. Ranges and steps as NX2navi's menu has them) MENU_HEADING(TAB_DISPLAY, "RenoDX"), {TAB_DISPLAY, "Tonemapper", &opts.rdx_tonemap, 0, 2, 1, tx_rdx_tonemap, "How the scene's light is brought to the display. Vanilla: the game's own curve. PsychoV35: keeps hue and saturation " "into the highlights. RenoDRT: carries the game's SDR look up to the peak brightness.", nullptr, false, true}, {TAB_DISPLAY, "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.", nullptr, false, true}, {TAB_DISPLAY, "Color space", &opts.rdx_space, 0, 2, 1, tx_rdx_space, "The colors the picture is taken to be in. Vanilla: the game's own. BT.709: as the SDR picture. DCI-P3: more " "saturated.", nullptr, false, true}, {TAB_DISPLAY, "Exposure", &opts.rdx_exposure, 0, 200, 5, tx_percent, "The scene's brightness before tone mapping. 100% is the game's.", nullptr, false, true}, {TAB_DISPLAY, "Middle gray", &opts.rdx_midgray, 0, 2, 1, tx_rdx_midgray, "What the scene's middle gray is held to. Render: as rendered. Vanilla: where the game's curve puts it. Eye " "adaptation: it follows what is on screen over a few seconds.", nullptr, false, true}, {TAB_DISPLAY, "Match tone slope", &opts.rdx_match_slope, 0, 1, 1, tx_onoff, "PsychoV35: the mid tones get the contrast of the game's own curve. Off: PsychoV35's own, softer.", nullptr, false, true}, {TAB_DISPLAY, "Tone slope", &opts.rdx_tone_slope, 0, 100, 1, tx_rdx_grade, "PsychoV35: how steep the tone curve is through middle gray. 50 leaves it unchanged.", nullptr, false, true}, {TAB_DISPLAY, "Hue clip", &opts.rdx_hue_clip, 0, 100, 5, tx_percent, "PsychoV35: how much bright colors turn as they do where the SDR picture clips, fire towards yellow and white. 0% " "keeps their hue.", nullptr, false, true}, {TAB_DISPLAY, "Highlight saturation", &opts.rdx_highlight_sat, 0, 100, 1, tx_rdx_grade, "RenoDRT: how strong the colors of the brightest parts are. 50 leaves them unchanged.", nullptr, false, true}, {TAB_DISPLAY, "Blowout", &opts.rdx_blowout, 0, 100, 1, tx_rdx_grade, "RenoDRT: turns the brightest parts towards white. 0 keeps their color.", nullptr, false, true}, {TAB_DISPLAY, "Flare", &opts.rdx_flare, 0, 100, 1, tx_rdx_grade, "RenoDRT: lifts the darkest parts as a little stray light would. 0 keeps black black.", nullptr, false, true}, {TAB_DISPLAY, "Hue correction", &opts.rdx_hue, 0, 100, 5, tx_percent, "RenoDRT: how much bright colors keep the hue they had before tone mapping.", nullptr, false, true}, {TAB_DISPLAY, "Color grading", &opts.rdx_grade, 0, 100, 5, tx_percent, "RenoDRT: how much of the game's own color grading is kept. 0% is the scene without it.", nullptr, false, true}, {TAB_DISPLAY, "Highlights", &opts.rdx_highlights, 0, 100, 5, tx_rdx_grade, "The bright parts of the scene. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "Shadows", &opts.rdx_shadows, 0, 100, 5, tx_rdx_grade, "The dark parts of the scene. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "Contrast", &opts.rdx_contrast, 0, 100, 5, tx_rdx_grade, "The scene's contrast. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "Saturation", &opts.rdx_saturation, 0, 100, 5, tx_rdx_grade, "The scene's color. 50 is neutral.", nullptr, false, true}, {TAB_DISPLAY, "Bloom", &opts.rdx_bloom, 0, 100, 5, tx_rdx_grade, "The glow around bright things. 50 is the game's. RenoDX is by Carlos Lopez (clshortfuse), under the MIT license.", nullptr, false, true}, MENU_HEADING(TAB_DISPLAY, "Overlay"), // (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, "Frames per second in the top right corner. Full: a performance panel in its place: the GPU's and the CPU's load, " "temperatures and memory, the frame rate and its lows, the frame times and their graph, the waits per frame and the " "picture's settings.", hn_fps, false, true}, // ---- Graphics: the picture, top to bottom ---- MENU_HEADING(TAB_GRAPHICS, "Upscaling"), // (the Upscaler only in a build with DLSS or FSR 4, or where AMD FSR 3.1 runs: row_shown. An engine's native anti-aliasing // is the Render resolution's Native (100%), upscaler_rows.h) {TAB_GRAPHICS, "Upscaler", &opts.dlss, 0, ur::kUpscalers - 1, 1, tx_upscaler, "What draws 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: 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 size the 3D is drawn at; the upscaler fills in the rest. Applies after a restart.", hn_resolution, true}, // (Triforce, 11-13: vk_temporal.cpp pre_wanted. Shown with DLSS or FSR: row_shown) {TAB_GRAPHICS, "Upscale before bloom", &opts.upscale_pre, 0, 1, 1, tx_onoff, "On: the upscaler works on the scene before the game's glow and tone mapping, which are then made at full size. " "Applies after a restart.", nullptr, true, true}, {TAB_GRAPHICS, "Sharpness", &opts.sharpness, 0, 100, 10, tx_percent, "With DLSS, DLAA or AMD FSR as the Upscaler, the 3D before the HUD (FSR's own sharpening; AMD's RCAS for DLSS); with " "the game's own upscaler, the picture at the window. 0 is off. Too much shows halos around edges.", hn_sharpness}, // (Triforce, after NX2navi's aa setting: aa_rows.h, vk_aa.cpp. Taken at each frame. Shown with the game's own upscaler: // DLSS and FSR smooth the edges themselves) MENU_HEADING(TAB_GRAPHICS, "Anti-aliasing"), {TAB_GRAPHICS, "Anti-aliasing", &opts.aa, 0, aa_rows::kValues - 1, 1, tx_aa, "How the 3D's edges are smoothed: the game's own SMAA, none, FXAA, or SMAA at its Ultra preset. Changes at once.", hn_aa, false, true}, MENU_HEADING(TAB_GRAPHICS, "Frame generation"), // (Frame generation and DLSS frame generation in one row, merged_rows.h: the renderer's own, AMD FSR 4 where its library // makes the frames, NVIDIA DLSS where it can run (vk_dlssg.cpp: read at the start, so it takes a restart)) {TAB_GRAPHICS, "Frame generation", &merged.framegen, 0, mr7::FG_DLSS_LAST, 1, tx_framegen_row, "Makes frames between the game's own, for smoother motion, at a little input delay. Fast motion and camera cuts can " "show artifacts. NVIDIA DLSS applies after a restart.", hn_framegen_row, true, true}, MENU_HEADING(TAB_GRAPHICS, "Frame rate & latency"), {TAB_GRAPHICS, "Frame rate cap", &opts.fps_cap, -3, 6, 1, tx_fps_cap, // (6: Monitor's rate, fps_cap.h kMonitor) "The most frames the game renders a second; made frames come on top. 60 is the safe choice: past it some cutscenes and " "bosses can misbehave. 30, 40 and 45 are for a PC that holds one of them where 60 swings. Monitor's rate: the refresh " "rate of the screen the game starts on. Applies after a restart.", nullptr, true, true}, // (Triforce, after NX2navi's VSync switch: the swapchain's present mode, made again at once. present_mode.h, vk_main.cpp) {TAB_GRAPHICS, "VSync", &opts.vsync, 0, 1, 1, tx_onoff, "Whether a finished frame waits for the screen's next refresh. Off: a little less delay, and the picture can tear. " "Changes at once.", hn_vsync, false, true}, // (Frame pacing and Steady frame rate in one row, merged_rows.h: host/pace_steady.h, host/nn_vi.c steady_period) {TAB_GRAPHICS, "Frame pacing", &merged.pacing, 0, 3, 1, tx_pacing, "When each frame is shown. Steady paces the game to a rate this PC holds where you are: steadier, at some frame rate.", hn_pacing, true}, // (NVIDIA Reflex and AMD Anti-Lag 2 in one row, by the card's maker, merged_rows.h; none where neither runs) {TAB_GRAPHICS, "Low latency", &merged.latency, 0, 2, 1, tx_latency, "Each frame starts as late as it can, for less input delay: NVIDIA Reflex on NVIDIA cards, AMD Anti-Lag 2 on AMD ones.", hn_latency}, MENU_HEADING(TAB_GRAPHICS, "Textures"), {TAB_GRAPHICS, "Texture filtering", &opts.aniso, 0, 4, 1, tx_aniso, // (Triforce: vk_draw.cpp sampler_for) "Keeps ground, paths and walls sharp where they slope away from the camera. Game: what the game asks for; 16x is the " "sharpest, at a small cost."}, // (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. Applies after a restart.", hn_tex_detail, true}, // ((Triforce, 11-18, v0.5.1) 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. Its own group, as // v0.5.1's Advanced section had it, after the picture's) MENU_HEADING(TAB_GRAPHICS, "Advanced"), {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}, // ---- System: the game's ---- MENU_HEADING(TAB_SYSTEM, "Game"), // (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, of those your game has (language.txt in the game folder). Applies after a restart.", hn_language, true, true}, {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}, // (host/nn_vi.c realtime_step, hos_vi_native_interval: Per frame is the console's, paced to the game's own interval) {TAB_SYSTEM, "Game speed", &opts.realtime, 0, 1, 1, tx_speed, "How the game keeps time when it runs below 60 fps.", hn_speed}, // ---- Audio ---- MENU_HEADING(TAB_AUDIO, "Sound"), // (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.", 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 from your game files.", 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}, MENU_HEADING(TAB_AUDIO, "Microphone"), {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}, MENU_HEADING(TAB_SYSTEM, "Saves & reports"), // (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 that you put into the game folder's save-import folder. It becomes your " "save at the next start; the save it replaces is kept. For an emulator's save: Convert saves in Triforce Setup."}, // (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, your " "settings, the end of the log and your save. F8 does the same while you play."}, MENU_HEADING(TAB_SYSTEM, "Online"), {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}, // (Triforce, after NX2navi's Cheats tab: the cheats of the mods' cheat files, a row each once the host has named them) MENU_HEADING(TAB_SYSTEM, "Mod cheats"), // (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) // ---- Controls (Motion opens the 6 TAB_MOTION rows, Controls its page with the 2 TAB_PAGE rows) ---- MENU_HEADING(TAB_CONTROLS, "Controller"), {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}, // (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, "How far the left stick moves before the game sees it, in percent of its travel on each axis: lower for a precise " "stick, higher for one that drifts. 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, "How far the right stick moves before the game sees it, in percent of its travel 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: 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. Applies after a restart.", nullptr, true, true}, {TAB_CONTROLS, "Invert camera X", &opts.invert_cam_x, 0, 1, 1, tx_onoff, "Swaps left and right for the right stick's camera.", nullptr, false, true}, {TAB_CONTROLS, "Invert camera Y", &opts.invert_cam_y, 0, 1, 1, tx_onoff, "Swaps up and down for the right stick's camera.", nullptr, false, true}, MENU_HEADING(TAB_CONTROLS, "Mouse & keyboard"), {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. 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}, // (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: held with the movement keys, they push the 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 stick while the Walk key is held: 1.00 would be all the way.", nullptr, false, true}, {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}, MENU_HEADING(TAB_CONTROLS, "Rumble"), // (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.", 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: 1.00 is the game's. Lower makes the many weak rumbles easier to feel; higher quiets them. A Switch " "controller's HD rumble is not changed.", 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.", nullptr, false, true}, MENU_HEADING(TAB_CONTROLS, "Gameplay"), // (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 while Link moves (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, the next press or stopping ends it. Hold: Link sprints while the button is held.", nullptr, false, true}, {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: Switch Pro controllers " "and pads in Switch mode, DualSense and DualShock 4.", 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 turn of the controller. 100% is the console's.", 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 tilt of the controller. 100% is the console's.", nullptr, false, true}, {TAB_MOTION, "Invert motion X", &opts.gyro_inv_x, 0, 1, 1, tx_onoff, "Swaps the motion aim's left and right.", nullptr, false, true}, {TAB_MOTION, "Invert motion Y", &opts.gyro_inv_y, 0, 1, 1, tx_onoff, "Swaps the motion aim's up and down.", 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; " "Low keeps the smallest movements.", nullptr, false, true}, MENU_HEADING(TAB_CONTROLS, "Motion & buttons"), {TAB_CONTROLS, "Motion", nullptr, 0, 0, 0, nullptr, // (hookshot: opens the Motion page, the TAB_MOTION rows) "Aiming with the controller's gyroscope: on or off, its sensitivity and its inverts."}, // (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.", hn_prompts, true, true}, {TAB_CONTROLS, "Controls", nullptr, 0, 0, 0, nullptr, // (hookshot: opens its page) "The layout preset, the button prompts, and which button and keys press each of the Switch's buttons."}, // ---- 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) {TAB_DEBUG, "Robust buffers", &opts.robust, 0, 2, 1, tx_robust, // ((Triforce, options_version 7) from the Graphics tab) "Bounds-checked buffer reads: a read past a buffer's end is dropped instead of stopping the GPU. Applies after a " "restart. On AMD and Intel cards, changing it prepares every shader again at the next start (a long first start on " "AMD); on NVIDIA cards it does not. Switching back is quick when the shaders of the setting before were kept (one " "earlier set is kept when the disk has room for it).", hn_robust, true}, // ---- (Triforce, options_version 7) The saved values the merged rows above stand for (merged_rows.h): no tab shows them. // Each keeps its key in triforce_options.ini (the row's name: ini_key), loaded and saved as before, for the renderer and the // host read them, some before the menu (host/nn_vi.c renodx_hdr= and steady_frame_rate=, vk_dlssg.cpp // dlss_frame_generation=). Their merged rows take the restarts (restart_value_of) ---- {TAB_HIDDEN, "HDR", &opts.hdr, 0, 2, 1, tx_hdr, nullptr}, {TAB_HIDDEN, "RenoDX HDR", &opts.renodx, 0, 1, 1, tx_onoff, nullptr}, {TAB_HIDDEN, "Frame generation", &opts.framegen, 0, framegen_rows::kRowMax, 1, tx_framegen, nullptr}, {TAB_HIDDEN, "DLSS frame generation", &opts.dlssg, 0, 3, 1, tx_dlssg, nullptr}, {TAB_HIDDEN, "Frame pacing", &opts.pace, 0, 1, 1, tx_onoff, nullptr}, {TAB_HIDDEN, "Steady frame rate", &opts.steady_fps, 0, 2, 1, tx_steady_fps, nullptr}, {TAB_HIDDEN, "NVIDIA Reflex", &opts.reflex, 0, 2, 1, tx_latency, nullptr}, {TAB_HIDDEN, "AMD Anti-Lag 2", &opts.antilag, 0, 1, 1, tx_onoff, nullptr}, }; 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) // ((Triforce, 11-20) that screen chosen from the pause menu (the host's word 2): its guides band may end sooner, game_grid.h // kPauseGuideBandRight) std::atomic game_options_from_pause{false}; 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): where they are in the window, as menu_map is // draw_menu's ((11-19) the game's grid: game_grid.h column_of), and whether the mouse has been read since the game's screen // came: a click from before is not the tabs') game_grid::Map game_tab_map; 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_list_frame{0}; // ((Triforce, 11-19) and game_frames then: a slow game frame is not a list gone) std::atomic mods_enter{0}; // (the host's word: 1 the cursor onto the entry, 2 a click on it; 3 a click on Quit, // 4 the cursor onto Quit) std::atomic mods_press{0}; // (presses the host passed on while Mods has the cursor: HOS_MODS_PRESS_*) // ((Triforce, 11-19) and the directions held at its last read (HOS_MODS_PRESS_DIRS bits), and when: repeated as a pad's are) std::atomic mods_held_dirs{0}; std::atomic mods_held_ns{0}; // ((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) // ((Triforce, 11-19) the owner: "the mods and quit tabs do not have any sound effects when selecting them, have no animations // either ... The quit menu submenu also has no animations and sound effects". Mods and Quit fade their cursor in and out as // the System list's own buttons do (focus_anim.h: PaCommonBtnThin_00's Select and UnSelect), and Quit's dialog opens and // closes as the game's SystemWindow_00 (In, Out), its buttons as the same part; it takes input once its In has played) focus_anim::Focus mods_focus[2]; // (Mods, Quit) focus_anim::Focus quit_focus[3]; // (the dialog's buttons) int64_t quit_open_ns = 0; // (prof_now when the dialog opened: its In; 0 shut) int64_t quit_shut_ns = 0; // (when B or Cancel closed it: its Out; 0 none playing) bool quit_fresh = false; // (just opened: its buttons as they stand, the first one chosen) bool quit_ended = false; // (Quit Game or Restart Game chosen at this tick: the game goes, no cursor sound after) /// (Quit's dialog opens: In from now, Quit Game chosen) void quit_open() { quit_ask = true, quit_sel = 0, quit_open_ns = prof_now(), quit_shut_ns = 0, quit_fresh = true; } /// (B or Cancel: it closes with its Out; Quit keeps the cursor) void quit_cancel() { quit_ask = false, quit_open_ns = 0, quit_shut_ns = prof_now(); } /// (it goes with the entries, their list gone or the menu shut: no Out) void quit_gone() { quit_ask = false, quit_open_ns = 0, quit_shut_ns = 0; } /// (its Out still playing) bool quit_closing() { return !quit_ask && quit_shut_ns && prof_now() - quit_shut_ns < focus_anim::kOutNs; } bool quit_entry_shown() { return (mods_list_bits.load(std::memory_order_relaxed) & HOS_MODS_LIST_TITLE) == 0; } std::atomic game_frames{0}; // (the game's frames shown: menu_note_frame) /// ((Triforce, 11-19) the lab's "one DOWN from Options on the title did nothing and logged nothing": with the game's window /// behind another one its frames came 80 to 235 ms apart, and a list told of at each of them counted as gone after 150 ms, so /// the host's word that the cursor goes onto Mods was dropped (and the host's own 80 ms, host/oot_menu.c hos_oot_mods_down, /// gave the Down to the game, which has nothing under its last button). A list told of at the game's last frame or the one /// before is there however long ago that was: the age the entry's animations take (0 then)) int64_t mods_list_age() { const int64_t t = mods_list_ns.load(std::memory_order_relaxed); if (!t) return INT64_MAX; const int64_t frames = game_frames.load(std::memory_order_relaxed) - mods_list_frame.load(std::memory_order_relaxed); return frames >= 0 && frames <= 2 ? 0 : prof_now() - t; } bool mods_list_fresh() { return mods_list_age() < 150000000LL; } // ((Triforce, 11-19) the title's list, the owner: "make it the same as the other options, with the green filigree, the same // animations: when you select it, it just pops in". The entry is drawn as the game's own entries (draw_title_mods, with // mods_entry_anim.h's times): it fades with the list, and A on it plays the game's Decide before the Mods screen opens) bool mods_title_list() { return (mods_list_bits.load(std::memory_order_relaxed) & HOS_MODS_LIST_TITLE) != 0; } /// (the title's entry as it goes with its list: drawn a little past the list's last word, fading) bool mods_title_fading() { return mods_title_list() && mods_list_age() < mods_entry::kListShownNs; } int64_t mods_decide_ns = 0; // (A on the title's entry: when, while its Decide plays; 0 none) float mods_entry_px[5] = {}; // (the Mods entry as last drawn, the menu's column's pixels: its hit x0 y0 x1 y1, and the pitch) bool mods_decided = false; // (its Decide ended this tick: the Mods screen opened with no sound of its own, it had the press's) // ((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]; /// What of a row takes the restart: its value; ((Triforce, options_version 7) of a merged row only what of it is read at the /// start: HDR's Native + RenoDX (the scene's RGBA16F target and RenoDX's shaders, host/nn_vi.c hos_scene_rgba16f and /// vk_temporal.cpp, from hdr_at_start and renodx_at_start; Off, Expanded and Native change at once: the swapchain is made /// again at the next present, and the game asks nn::vi for the display's HDR as it goes), Frame generation's NVIDIA DLSS /// (vk_dlssg.cpp), Frame pacing's Steady (host/nn_vi.c), and the Render resolution's Native (100%) with its share int restart_value_of(const Row& r) { if (r.value == &merged.hdr) return opts.hdr == 2 && opts.renodx ? 1 : 0; if (r.value == &merged.framegen) return opts.dlssg; if (r.value == &merged.pacing) return opts.steady_fps; if (r.value == &opts.resolution) return opts.resolution + (ur::full_scale(opts.dlss) ? 100 : 0); return *r.value; } 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(restart_value_of(rows[i])) : -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 && restart_value_of(r) != 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]] = restart_value_of(rows[i]); } /// 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 offers AMD FSR 4 only where AMD's library can make the frames (vk_fsr4.h fsr4fg), and /// ((Triforce, options_version 7) NVIDIA DLSS 2x to 4x, which was a row of its own, only where DLSS frame generation can run: /// a build with it, on an NVIDIA RTX card DLSS runs on, or where it was asked for at this start). Asked when the menu opens, as /// the Upscaler's choices are. The saved value's own row (TAB_HIDDEN) ends at 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 step from it as from 8x. As known: the library is asked off the menu's thread (menu_ahead), and the row is /// set again once it has answered int framegen_list[mr7::FG_DLSS_LAST + 1]; int framegen_count = 0; bool dlssg_offered() { return mkwvk::dlssg::built() && (mkwvk::dlssg::asked() || (dev.device && dev.props.vendorID == 0x10DE && dlss_why() == DLSS_OK)); } void framegen_row_sync() { static_assert(framegen_rows::kRowMax == 9 && mr7::FG_DLSS == framegen_rows::kRowMax + 1, "the Frame generation row's own values end at 9, NVIDIA DLSS's follow"); framegen_count = mr7::framegen_choices(framegen_list, fsr4fg::offered_known(), dlssg_offered()); } /// ((Triforce, options_version 7) The merged rows' values, from the saved ones: before each tick's input and each drawing) void merged_sync() { merged.hdr = mr7::hdr_row(opts.hdr, opts.renodx); merged.framegen = mr7::framegen_row(opts.framegen, opts.dlssg); merged.pacing = mr7::pacing_row(opts.pace, opts.steady_fps); merged.latency = mr7::latency_row(latency_vendor(), opts.reflex, opts.antilag); } /// ...and a merged row's new value into the saved ones it stands for void merged_store(const int* v) { if (v == &merged.hdr) mr7::hdr_set(merged.hdr, opts.hdr, opts.renodx); if (v == &merged.framegen) mr7::framegen_set(merged.framegen, opts.framegen, opts.dlssg); if (v == &merged.pacing) mr7::pacing_set(merged.pacing, opts.pace, opts.steady_fps); if (v == &merged.latency) mr7::latency_set(merged.latency, latency_vendor(), opts.reflex, opts.antilag); } /// A merged row's next value from v (dir): its choices here int merged_step(const int* value, int v, int dir) { if (value == &merged.framegen) { if (!framegen_count) framegen_row_sync(); return mr7::step_in(framegen_list, framegen_count, v, dir); } int list[4], n = 0; const int hi = value == &merged.hdr ? (renodx_built() ? 3 : 2) : value == &merged.pacing ? 3 : mr7::latency_hi(latency_vendor()); for (int k = 0; k <= hi; k++) list[n++] = k; return mr7::step_in(list, n, v, dir); } // (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 group_shown(int heading); /// 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, ...; ((Triforce, options_version 7) a group's heading while a row of its group is shown, group_shown) bool row_shown(int i) { const int up = rows[i].value == &opts.upscale_pre || rows[i].value == &opts.dlss_model || rows[i].value == &opts.aa ? upscaler() : ur::GAME; return (rows[i].cheat < 0 || cheats_on()) && (rows[i].value != &opts.dlss || ur::upscaler_shown(dlss_built() || fsr4_built(), fsr3::supported())) && // ((Triforce, options_version 7) the DLSS model with NVIDIA DLSS as the Upscaler alone; Upscale before bloom with any // upscaler but the game's own, which it does nothing with (vk_temporal.cpp pre_wanted); Anti-aliasing with the game's // own alone: DLSS and FSR smooth the edges themselves (aa_rows.h)) (rows[i].value != &opts.dlss_model || (ur::model_shown(dlss_built()) && ur::is_dlss(up))) && (rows[i].value != &opts.upscale_pre || up != ur::GAME) && (rows[i].value != &opts.aa || up == ur::GAME) && // (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. (options_version 7) The UI brightness is one of them: // without RenoDX the HUD's white is the picture's, Paper white) (!rdx_row(rows[i].value) || (opts.hdr == 2 && renodx_built() && opts.renodx && rdx_applies(rows[i].value))) && // ((Triforce, options_version 7) Paper white and Peak brightness with HDR on; the Ultrawide's HUD and menu sides with a // shape wider than 16:9 (21:9 and 32:9: 16:10 is narrower, ultrawide_rows.h); Sprint mode with a sprint button, Walk // scale with a walk key; Low latency where Reflex or Anti-Lag 2 runs) ((rows[i].value != &opts.hdr_white && rows[i].value != &opts.hdr_peak) || opts.hdr != 0) && ((rows[i].value != &opts.wide_hud && rows[i].value != &opts.wide_menus) || ultrawide_row_wider(opts.ultrawide)) && (rows[i].value != &opts.sprint_mode || opts.sprint_button != 0) && (rows[i].value != &opts.walk_scale || opts.walk_key != 0) && (rows[i].value != &merged.latency || latency_vendor() != mr7::LATENCY_NONE) && #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()) && (!rows[i].heading || rows[i].tab == TAB_DEBUG || group_shown(i)); } /// ((Triforce, options_version 7) A group's heading is shown while a row of its group is: the rows of its tab after it, up to the /// next heading there. The Debug tab's Developer heading is debug_rows') bool group_shown(int heading) { for (int j = heading + 1; j < kRows; j++) { if (rows[j].tab != rows[heading].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, and the // readers before the menu find them: host/hos_main.c ultrawide=, host/oot_wide_hud.c ultrawide_hud=. (Triforce, // options_version 7) The rows renamed as their groups came, a group's name taken off theirs) static const char* const kept[][2] = { // (the row's name now, the key its value was saved under) {"Aspect ratio", "ultrawide"}, {"HUD position", "ultrawide_hud"}, {"Menu sides", "ultrawide_menus"}, {"Paper white", "hdr_paper_white"}, {"Peak brightness", "hdr_peak_brightness"}, {"UI brightness", "renodx_ui_brightness"}, {"Tonemapper", "renodx_tonemapper"}, {"Gamma correction", "renodx_gamma_correction"}, {"Color space", "renodx_color_space"}, {"Exposure", "renodx_exposure"}, {"Middle gray", "renodx_midgray"}, {"Match tone slope", "renodx_match_tone_slope"}, {"Tone slope", "renodx_tone_slope"}, {"Hue clip", "renodx_hue_clip"}, {"Highlight saturation", "renodx_highlight_saturation"}, {"Blowout", "renodx_blowout"}, {"Flare", "renodx_flare"}, {"Hue correction", "renodx_hue_correction"}, {"Color grading", "renodx_color_grading"}, {"Highlights", "renodx_highlights"}, {"Shadows", "renodx_shadows"}, {"Contrast", "renodx_contrast"}, {"Saturation", "renodx_saturation"}, {"Bloom", "renodx_bloom"}, }; for (const auto& k : kept) if (r.value && !strcmp(r.name, k[0])) return k[1]; 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.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 && !is_merged(r.value); } // ((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_