Files
Triforce-Source/host/oot_wide_hud.h
ruckus7382sfgsgdf 4fa4f9188b Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
2026-11-25 10:21:32 -06:00

72 lines
4.7 KiB
C

/* (Triforce) Where the game's 2D interface goes on a picture wider than 16:9: the rules alone, for
tests/test_wide_hud.py. host/oot_wide_hud.c reads the game's memory and the settings; nx2/oot_wide.py has the hook.
The game lays its interface out on a 16:9 grid and draws each layout (a "screen": the hearts, the action buttons, the
map, a menu, a fade) through one full-screen projection. It sets a layout's projection once, when the layout is made,
not each frame; the hook hands it over then. Two things are done with it on a wider picture:
- kept: as it is, the layout stretched over the whole picture (the item wheel's and the menus' backgrounds, which
redraw a capture of the whole picture, and the fades, which are one colour);
- middle: times the squeeze (16:9 over the picture's ratio), so the layout keeps its shape in the middle 16:9 of the
picture. Everything else, as NX2navi's patch does it.
(oot_hud_row can also move a whole layout out to one side, which the lab's HOS_WIDE_SHIFT uses to find out what a
screen draws. No layout of the game's is placed that way: see below.)
The Insert menu's "Ultrawide HUD" row on Screen edges places the side HUD, notices, and edge-anchored action states at their
authored offsets from the picture's edges. Those are moved inside their layouts, by oot_hud_out, because a projection
cannot do it: PlayerStatus_00 holds the hearts (on a pane at the grid's top left corner) and the item slot (on one at
its top right) together, and MapMenu_00 is the small map and the pause menu's whole-screen map in one layout, whose
projection is not set again as the menu opens (tried: the menu's map sat off to the right). nx2/prompt_assets.py
HUD_SIDE_PANES lists the panes, host/prompts.c build_layouts writes them as the game loads its layouts, so the row is
read once, at the start. Layouts that follow something in the 3D world (the targeting pointer, an enemy's bar, a
speech balloon) stay in the middle. Only the right-hand action-button state moves. */
#ifndef OOT_WIDE_HUD_H
#define OOT_WIDE_HUD_H
#include <stdint.h>
enum { OOT_HUD_MIDDLE = 0, OOT_HUD_LEFT = -1, OOT_HUD_RIGHT = 1 };
/* The screens that keep the whole picture, by their class (the first word of the screen object), a bit each: bit k of
the keep mask keeps screen k whole (the Insert menu's Ultrawide menus row clears the menus' bit 1; the two fades
are never squeezed: one colour in the middle alone leaves the picture showing at the sides). */
#define OOT_HUD_KEEP_N 5
static const uint64_t oot_hud_keep_classes[OOT_HUD_KEEP_N] = {
0x84c0d098ULL, /* the item wheel's background */
0x84c04fb0ULL, /* the pause and system menus' background */
0x84c061c8ULL, /* the event fade */
0x84c07b30ULL, /* the loading fade */
/* ((Triforce) the system overlay (UISystemOverlayScreen): the system menus' header and button guides, which this game's
options line up with squeezed into the middle 16:9 (gpu/vk/game_grid.h), and, from the item wheel's first opening on,
the wheel's background as well. Its bit 4 is set only while the wheel's background is drawn (vk_framegen.cpp
wide_sides): that background then covers the whole picture, as screen 0's does; at every other time the overlay is
squeezed, as before */
0x84c0f4a0ULL,
};
static inline uint32_t oot_hud_keep_bit(uint64_t screen_class) {
for (int k = 0; k < OOT_HUD_KEEP_N; k++)
if (oot_hud_keep_classes[k] == screen_class) return 1u << k;
return 0;
}
#define OOT_HUD_HALF 1920.0f /* (half the 16:9 grid's width, in the layouts' units) */
/* How far out, in the layouts' units, a pane at a side of the 16:9 grid goes to sit at that side of a picture whose
squeeze is q: the same distance oot_hud_row moves a whole layout (1 - q of the clip space's half, q per unit). */
static inline float oot_hud_out(float q) {
return q > 0.0f && q < 1.0f ? OOT_HUD_HALF * (1.0f / q - 1.0f) : 0.0f;
}
/* A layout's projection for a picture whose squeeze is q (0 < q <= 1). The game keeps the matrix by columns: `first` is
its first column (m00 m10 m20 m30: what x is multiplied by) and `move` the first number of its fourth column (m03,
what is added to clip x). keep: the layout keeps the whole picture. side: where it goes when it is not kept.
(The fourth number of `first` is m30, not the move: a move put there bends the picture, and the layouts it was first
tried on left the screen altogether.) */
static inline void oot_hud_row(float first[4], float *move, float q, int keep, int side) {
if (keep || !(q > 0.0f) || q >= 1.0f) return;
for (int k = 0; k < 4; k++) first[k] *= q;
/* (clip space is 2 wide: the 16:9 middle leaves 1 - q free on each side) */
*move = *move * q + (float)side * (1.0f - q);
}
#endif