3 Commits

Author SHA1 Message Date
ruckus7382sfgsgdf
23a743a977 Triforce v0.3.7
Setup's Convert saves page finds NX2navi saves by itself. Nothing else changed since v0.3.6's main.
2026-11-14 22:39:28 -06:00
ruckus7382sfgsgdf
40aa5f5595 Readme: the opening lines match the page
The readme's heading, the three pieces, the install title and the credits no longer name the game
or the console. The trademark notice at the end stays.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 21:18:51 -06:00
ruckus7382sfgsgdf
aff80bd56f Linux: the options' tabs inside the game's own Options screen
On Linux the game's Options screen was never named for the renderer, so the options' tabs did not
come and there was no way to Triforce's options at all. host/oot_menu.c names it on every system
now. The Linux AppImage workflow can be started with the version its build names itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 01:36:27 -06:00
8 changed files with 240 additions and 35 deletions

View File

@@ -9,6 +9,13 @@ on:
tags: ['*'] tags: ['*']
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
inputs:
# (a build that replaces a release's Linux file names that release: a game built from it compares its version with
# the latest release's tag by name (host/hos_update.c), and git describe's v0.3.6-1-g... would be told of v0.3.6)
version:
description: "The version the AppImage names itself (empty: git describe's)"
required: false
default: ''
permissions: permissions:
contents: read contents: read
concurrency: concurrency:
@@ -95,6 +102,8 @@ jobs:
ls -la work work/image ls -la work work/image
- name: AppImage - name: AppImage
env:
HOOKSHOT_VERSION: ${{ inputs.version }} # (empty but for a started run that names one: appimage.sh asks git then)
run: scripts/linux/appimage.sh run: scripts/linux/appimage.sh
# (AMD FSR 4's Linux side, a build option the AppImage leaves off (gpu/vk/vk_fsr4.cpp: dlopen, the older backend # (AMD FSR 4's Linux side, a build option the AppImage leaves off (gpu/vk/vk_fsr4.cpp: dlopen, the older backend

View File

@@ -13,7 +13,15 @@
and hands it to the focus manager (*(screen+32)+96, its vtable +48), when the manager takes the player's input. and hands it to the focus manager (*(screen+32)+96, its vtable +48), when the manager takes the player's input.
HOS_MENU_TRACE=1: the focus changes, the screens and what the mouse does logged. */ HOS_MENU_TRACE=1: the focus changes, the screens and what the mouse does logged. */
#include "hos.h" #include "hos.h"
#if defined(_WIN32) /* (Triforce) The game's own Options screen (the layout SystemOption_00; the title's Options and the pause menu's are the one
screen), by its vtable (HOS_MENU_TRACE in a headless run, 2026-11-10: the screen of 15 entries that starts to run when
Options is chosen, from the title and from the pause menu alike, and stops with Back; L and R do nothing on it). While
it runs the renderer is told each frame (rx_option_set HOS_OPT_GAME_OPTIONS): the menu draws its tabs over this
screen's header, the game's own list the first of them (gpu/vk/vk_menu.cpp), and nn_hid.c passes Back on when one of
our tabs is left with it. HOS_OPTIONS_TABS=0 keeps the renderer untold */
#define OPTIONS_SCREEN_VTABLE 0x84c0f108ULL
void rx_option_set(int id, int value); /* rx_backend.c */
#if defined(_WIN32) && !defined(HOS_OOT_MENU_NO_MOUSE) /* (the macro: tests/test_oot_menu_mouse.py builds the other half on Windows) */
#include <windows.h> #include <windows.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
@@ -231,15 +239,7 @@ static int panel_page(uint64_t screen) { return panel_page_vt(peek64(screen)); }
search of memory, in Lord Jabu-Jabu's Belly): +0x1368 the floor chosen (2F 1, 1F 0, B1 -1), +0x136c how search of memory, in Lord Jabu-Jabu's Belly): +0x1368 the floor chosen (2F 1, 1F 0, B1 -1), +0x136c how
many floors, +0x1370 the lowest; the top is the lowest + the count - 1. Kept as the screens are seen */ many floors, +0x1370 the lowest; the top is the lowest + the count - 1. Kept as the screens are seen */
#define HUD_SCREEN_VTABLE 0x84c08300ULL #define HUD_SCREEN_VTABLE 0x84c08300ULL
/* (Triforce) The game's own Options screen (the layout SystemOption_00; the title's Options and the pause menu's are the one
screen), by its vtable (HOS_MENU_TRACE in a headless run, 2026-11-10: the screen of 15 entries that starts to run when
Options is chosen, from the title and from the pause menu alike, and stops with Back; L and R do nothing on it). While
it runs the renderer is told each frame (rx_option_set HOS_OPT_GAME_OPTIONS): the menu draws its tabs over this
screen's header, the game's own list the first of them (gpu/vk/vk_menu.cpp), and nn_hid.c passes Back on when one of
our tabs is left with it. HOS_OPTIONS_TABS=0 keeps the renderer untold */
#define OPTIONS_SCREEN_VTABLE 0x84c0f108ULL
static volatile LONG64 options_seen_ns; static volatile LONG64 options_seen_ns;
void rx_option_set(int id, int value); /* rx_backend.c */
int hos_oot_options_front(void) { int hos_oot_options_front(void) {
const LONG64 t = InterlockedCompareExchange64(&options_seen_ns, 0, 0); const LONG64 t = InterlockedCompareExchange64(&options_seen_ns, 0, 0);
return t && (LONG64)hos_now_ns() - t < 200000000LL; return t && (LONG64)hos_now_ns() - t < 200000000LL;
@@ -836,7 +836,32 @@ void hos_oot_menu_tick(Ctx *c, uint64_t screen) {
if (screen == pause_screen_now()) InterlockedIncrement(&ticks); if (screen == pause_screen_now()) InterlockedIncrement(&ticks);
} }
#else #else
/* Not Windows: the mouse in the game's menus is the Windows window's (display.c), not here. The game's own Options
screen is named all the same, each frame it runs, so the options' tabs sit in it as on Windows: they are the only way
to our options since the keys that opened them over the game went (gpu/vk/vk_menu.cpp overlay_allowed), and with this
left out a Linux build had none at all (2026-11-14). The screen is the one whose update the lifted game is running
(nx2/oot_patches.py patch_menu_tick), so its first word, the vtable, is there to read */
#include <stdlib.h>
#include <string.h>
#include "../gpu/vk/vk_api.h" /* (HOS_OPT_GAME_OPTIONS) */
static int64_t options_seen_ns; /* (the screens' updates run on several of the game's threads: read and written whole) */
void hos_oot_menu_focus(Ctx *c, uint64_t screen, uint64_t pane, uint64_t lr) { (void)c, (void)screen, (void)pane, (void)lr; } void hos_oot_menu_focus(Ctx *c, uint64_t screen, uint64_t pane, uint64_t lr) { (void)c, (void)screen, (void)pane, (void)lr; }
void hos_oot_menu_tick(Ctx *c, uint64_t screen) { (void)c, (void)screen; } void hos_oot_menu_tick(Ctx *c, uint64_t screen) {
int hos_oot_options_front(void) { return 0; } (void)c;
uint64_t vt = 0;
if (screen < 0x100000 || screen >= HOS_GUEST_SPACE - 8) return;
memcpy(&vt, GP(screen), 8);
if (vt != OPTIONS_SCREEN_VTABLE) return;
static int tabs = -1;
if (tabs < 0) {
const char *e = getenv("HOS_OPTIONS_TABS");
tabs = !(e && *e == '0');
}
__atomic_store_n(&options_seen_ns, hos_now_ns(), __ATOMIC_RELAXED);
if (tabs) rx_option_set(HOS_OPT_GAME_OPTIONS, 1);
}
int hos_oot_options_front(void) {
const int64_t t = __atomic_load_n(&options_seen_ns, __ATOMIC_RELAXED);
return t && hos_now_ns() - t < 200000000LL;
}
#endif #endif

View File

@@ -7,15 +7,15 @@
</p> </p>
<p align="center"> <p align="center">
<b>Ocarina of Time for Nintendo Switch 2, running natively on your PC.</b><br> <b>Your game, native on your PC.</b><br>
<sub>No emulator: the game's code is recompiled into a real Windows program and its graphics redrawn on Vulkan.</sub> <sub>No emulator: Triforce builds a real Windows program on your PC, from your own copy of the game, and draws its graphics on Vulkan.</sub>
</p> </p>
<p align="center"> <p align="center">
<a href="https://triforceproject.com"><img src="https://img.shields.io/badge/Download-Triforce%20Setup-D4A72C?style=for-the-badge&labelColor=111111" alt="Download Triforce Setup"></a> <a href="https://triforceproject.com"><img src="https://img.shields.io/badge/Download-Triforce%20Setup-D4A72C?style=for-the-badge&labelColor=111111" alt="Download Triforce Setup"></a>
<img src="https://img.shields.io/badge/Windows-10%20%7C%2011-D4A72C?style=for-the-badge&labelColor=111111" alt="Windows 10 | 11"> <img src="https://img.shields.io/badge/Windows-10%20%7C%2011-D4A72C?style=for-the-badge&labelColor=111111" alt="Windows 10 | 11">
<img src="https://img.shields.io/badge/Renderer-Vulkan%201.3-1E62E8?style=for-the-badge&labelColor=111111" alt="Vulkan 1.3"> <img src="https://img.shields.io/badge/Renderer-Vulkan%201.3-1E62E8?style=for-the-badge&labelColor=111111" alt="Vulkan 1.3">
<img src="https://img.shields.io/badge/Recompiled-No%20emulator-2FAA3A?style=for-the-badge&labelColor=111111" alt="No emulator"> <img src="https://img.shields.io/badge/Native-No%20emulator-2FAA3A?style=for-the-badge&labelColor=111111" alt="No emulator">
<img src="https://img.shields.io/badge/License-GPL--3.0%2B-C8202E?style=for-the-badge&labelColor=111111" alt="GPL-3.0+"> <img src="https://img.shields.io/badge/License-GPL--3.0%2B-C8202E?style=for-the-badge&labelColor=111111" alt="GPL-3.0+">
</p> </p>
@@ -35,20 +35,20 @@
## <img src="assets/readme/gold.svg" alt="" width="26"> The three pieces ## <img src="assets/readme/gold.svg" alt="" width="26"> The three pieces
**Triforce** is a native PC version of the Switch 2 *Ocarina of Time*. Every piece has one job: to make Hyrule on your **Triforce** is a native PC version of your game. Every piece has one job: to make it look and play on your PC exactly
PC look and play exactly the way it does on the console. the way it does on the console.
| | Piece | What it does | | | Piece | What it does |
|:-:|---|---| |:-:|---|---|
| <img src="assets/readme/ruby.svg" alt="" width="20"> | **Power** · the recompiler | Turns the game's own ARM64 code into a Windows program ahead of time. No emulation at runtime, no CPU guessing. | | <img src="assets/readme/ruby.svg" alt="" width="20"> | **Power** · the recompiler | Turns the game's own ARM64 code into a Windows program ahead of time. No emulation at runtime, no CPU guessing. |
| <img src="assets/readme/sapphire.svg" alt="" width="20"> | **Wisdom** · the system | Plays the part of the console's operating system: files, saves, audio, controllers, threads and timing. | | <img src="assets/readme/sapphire.svg" alt="" width="20"> | **Wisdom** · the system | Plays the part of the console's operating system: files, saves, audio, controllers, threads and timing. |
| <img src="assets/readme/emerald.svg" alt="" width="20"> | **Courage** · the renderer | Rebuilds the Switch 2 graphics on Vulkan, with the game's own lighting, fog, water and foliage. | | <img src="assets/readme/emerald.svg" alt="" width="20"> | **Courage** · the renderer | Rebuilds the console's graphics on Vulkan, with the game's own lighting, fog, water and foliage. |
What makes Triforce's Hyrule look right: What makes the game look right in Triforce:
- <img src="assets/readme/emerald.svg" alt="" width="16"> **Living forest:** trees with full canopies, ferns, grass, - <img src="assets/readme/emerald.svg" alt="" width="16"> **Living forest:** trees with full canopies, ferns, grass,
drifting leaves and fireflies, all drawn by the game's own GPU culling. drifting leaves and fireflies, all drawn by the game's own GPU culling.
- <img src="assets/readme/sapphire.svg" alt="" width="16"> **True light:** ambient light probes keep Link, signs and - <img src="assets/readme/sapphire.svg" alt="" width="16"> **True light:** ambient light probes keep the hero, signs and
plants lit in the shade; the pond's water and the game's own fog are as the console shows them, with no tuned plants lit in the shade; the pond's water and the game's own fog are as the console shows them, with no tuned
workarounds on top. workarounds on top.
- <img src="assets/readme/ruby.svg" alt="" width="16"> **Steady play:** no freeze after loading a save, no exposure - <img src="assets/readme/ruby.svg" alt="" width="16"> **Steady play:** no freeze after loading a save, no exposure
@@ -78,7 +78,7 @@ itself is assembled on your PC, from your copy, in one guided build.
| <img src="assets/readme/emerald.svg" alt="" width="18"> Disk space | About 2 GB for Setup and its tools, and about 60 GB free while building | | <img src="assets/readme/emerald.svg" alt="" width="18"> Disk space | About 2 GB for Setup and its tools, and about 60 GB free while building |
| <img src="assets/readme/gold.svg" alt="" width="18"> Your game | Program `0400486024DEC000`, update v131072, build `e0f3ccfa`, as a `.nup` or as `romfs` + `exefs` folders. Other versions are refused. | | <img src="assets/readme/gold.svg" alt="" width="18"> Your game | Program `0400486024DEC000`, update v131072, build `e0f3ccfa`, as a `.nup` or as `romfs` + `exefs` folders. Other versions are refused. |
### Four steps to Hyrule ### Four steps to play
**1 · Download.** Get **`TriforceSetup.exe`** from the [newest release](https://triforceproject.com) **1 · Download.** Get **`TriforceSetup.exe`** from the [newest release](https://triforceproject.com)
and run it. and run it.
@@ -146,7 +146,7 @@ In game, **F10** or **Alt+Enter** switches between a window and fullscreen. **F1
## <img src="assets/readme/ruby.svg" alt="" width="26"> Controls ## <img src="assets/readme/ruby.svg" alt="" width="26"> Controls
Play with a controller, or with keyboard and mouse. The **Controls** tab of the game's Options sets what presses Play with a controller, or with keyboard and mouse. The **Controls** tab of the game's Options sets what presses
each Switch button: one controller input and up to two keys. each of the console's buttons: one controller input and up to two keys.
Moving (<kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd>) and the camera (arrow keys, or <kbd>I</kbd> <kbd>J</kbd> Moving (<kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd>) and the camera (arrow keys, or <kbd>I</kbd> <kbd>J</kbd>
<kbd>K</kbd> <kbd>L</kbd>) are fixed. <kbd>K</kbd> <kbd>L</kbd>) are fixed.
@@ -202,7 +202,7 @@ adds game files. Deeper layouts such as `mods/contents/<title id>/<name>/romfs`
1. **Translate:** `nx2/lift.py` turns the game's ARM64 machine code into C. 1. **Translate:** `nx2/lift.py` turns the game's ARM64 machine code into C.
2. **Compile:** `nx2/build.py` builds that C together with `host/`, which stands in for the console's operating system. 2. **Compile:** `nx2/build.py` builds that C together with `host/`, which stands in for the console's operating system.
3. **Replay:** `host/nvn_native.c` captures every NVN2 graphics call the game makes, and `gpu/vk/` replays it on Vulkan. 3. **Replay:** `host/nvn_native.c` captures every NVN2 graphics call the game makes, and `gpu/vk/` replays it on Vulkan.
4. **Shaders:** Switch 2 Ampere shaders are lowered to Maxwell (`lower_to_maxwell.h`), then translated to SPIR-V. 4. **Shaders:** the console's Ampere shaders are lowered to Maxwell (`lower_to_maxwell.h`), then translated to SPIR-V.
The [development guide](docs/development.md) and [design notes](docs/design.md) go deeper. The [development guide](docs/development.md) and [design notes](docs/design.md) go deeper.
@@ -244,15 +244,15 @@ style and what a good pull request looks like.
*Seven Sages sealed the Triforce. These ones helped forge it.* *Seven Sages sealed the Triforce. These ones helped forge it.*
> **Triforce is built off Hookshot**, NotRexed's native recompilation of the Switch 2 *Ocarina of Time*. > **Triforce is built off Hookshot**, NotRexed's native recompilation project.
- **Evil:** Triforce's creator and lead. Brought Kokiri Forest back to life with - **Evil:** Triforce's creator and lead. Brought the forest back to life with
the GPU culling fixes for trees, ferns, grass, falling leaves, fireflies and the tree canopies; fixed the ambient the GPU culling fixes for trees, ferns, grass, falling leaves, fireflies and the tree canopies; fixed the ambient
light probes, the pond's water, the game's own fog, the freeze after loading a save and the exposure flicker; made the light probes, the pond's water, the game's own fog, the freeze after loading a save and the exposure flicker; made the
rendering diagnostics tools and Triforce Setup. rendering diagnostics tools and Triforce Setup.
- **NotRexed:** Hookshot, the recompiler this build started from, as well as BlueShell (Mario Kart World), - **NotRexed:** Hookshot, the recompiler this build started from, as well as BlueShell (Mario Kart World),
Skybound (Tears of the Kingdom) and the a64-kit tools. Skybound (Tears of the Kingdom) and the a64-kit tools.
- **Eden** and **Eglantine:** the shader recompiler and the Switch 2 shader work. - **Eden** and **Eglantine:** the shader recompiler and the console shader work.
- **suyu:** the graphics decoders and the AArch64 translator. - **suyu:** the graphics decoders and the AArch64 translator.
- **seedds (nxnative):** how task and mesh shaders really behave. - **seedds (nxnative):** how task and mesh shaders really behave.
- **zortos293 (Lichii):** Ampere shader lowering, and the compare-exchange retry fix. - **zortos293 (Lichii):** Ampere shader lowering, and the compare-exchange retry fix.
@@ -260,9 +260,9 @@ style and what a good pull request looks like.
- **kinnay (zbic)**, **Opus** and **SDL:** decompression, sound and controller input. - **kinnay (zbic)**, **Opus** and **SDL:** decompression, sound and controller input.
- **sostenesfreitas (ocarina-recomp):** an early README layout, and notes that confirmed the mesh stage's control - **sostenesfreitas (ocarina-recomp):** an early README layout, and notes that confirmed the mesh stage's control
section. section.
- **MythosOfs (Orchid):** the original fog and exposure workaround for Ocarina of Time. - **MythosOfs (Orchid):** the original fog and exposure workaround.
- **Carlos Lopez (clshortfuse) and [RenoDX](https://github.com/clshortfuse/renodx):** the HDR tone mapping, eye - **Carlos Lopez (clshortfuse) and [RenoDX](https://github.com/clshortfuse/renodx):** the HDR tone mapping, eye
adaptation and colour grading of the optional RenoDX HDR build, from RenoDX's mod for Ocarina of Time. adaptation and colour grading of the optional RenoDX HDR build, from RenoDX's mod for this game.
- **Mesa (NAK):** the map of Ampere's instruction encoding. - **Mesa (NAK):** the map of Ampere's instruction encoding.
- **Everyone who sent fixes:** SkippySteve (a great many of them), klimovich008, d3zessete, chrispository, vzeol, - **Everyone who sent fixes:** SkippySteve (a great many of them), klimovich008, d3zessete, chrispository, vzeol,
monsterlag, leonidasmark, Segmentree, Zorkats, ShyVortex, hiKareeem, gab9281, i900gaming and more. monsterlag, leonidasmark, Segmentree, Zorkats, ShyVortex, hiKareeem, gab9281, i900gaming and more.

View File

@@ -650,7 +650,7 @@
</StackPanel> </StackPanel>
<TextBlock Text="Convert saves" Style="{StaticResource Title}"/> <TextBlock Text="Convert saves" Style="{StaticResource Title}"/>
<TextBlock Style="{StaticResource Body}" Margin="0,12,0,0" <TextBlock Style="{StaticResource Body}" Margin="0,12,0,0"
Text="Bring your saves from an emulator into Triforce, or take Triforce's back out. Whatever gets replaced is backed up first."/> Text="Bring your saves from NX2navi or an emulator into Triforce, or take Triforce's back out. Whatever gets replaced is backed up first."/>
</StackPanel> </StackPanel>
<Grid Grid.Row="1" Margin="0,24,0,0"> <Grid Grid.Row="1" Margin="0,24,0,0">
<StackPanel Orientation="Horizontal" Margin="-22,0,0,0"> <StackPanel Orientation="Horizontal" Margin="-22,0,0,0">

View File

@@ -1,12 +1,13 @@
// Saves of this game (Ocarina of Time, 0400486024DEC000), wherever they are: Triforce keeps them in <game>\user\save\<uid>, emulators // Saves of this game (Ocarina of Time, 0400486024DEC000), wherever they are: Triforce keeps them in <game>\user\save\<uid>, emulators
// in their NAND (Eden, yuzu, suyu, sudachi, citron, torzu, EvilOOT: nand\user\save\0000000000000000\<user>\0400486024DEC000) or // in their NAND (Eden, yuzu, suyu, sudachi, citron, torzu, EvilOOT: nand\user\save\0000000000000000\<user>\0400486024DEC000) or
// Ryujinx's bis\user\save\<index>\0. The files are the same everywhere (account.sav, option.sav, slot_00..05\caption.sav + // Ryujinx's bis\user\save\<index>\0, NX2navi in its game folder's profile (NaviSave). The files are the same everywhere
// progress.sav), so converting is a copy, with what gets replaced backed up first. // (account.sav, option.sav, slot_00..05\caption.sav + progress.sav), so converting is a copy, with what gets replaced backed up first.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
namespace TriforceSetup; namespace TriforceSetup;
@@ -45,8 +46,56 @@ static class Saves
return s; return s;
} }
/// The save an NX2navi game would load, given its game folder or that folder's profile folder. NX2navi keeps the save in
/// <game>\profile\save\<account> (32 hex digits) and commits through <game>\profile\save-tx: a finished commit there
/// (ready-<n>, the highest n) is newer than the account folder until the game's next start swaps it in. Null when the folder is
/// no NX2navi game or holds no save
public static string? NaviSave(string dir)
{
try
{
foreach (var profile in new[] { Path.Combine(dir, "profile"), dir })
{
var saves = Path.Combine(profile, "save");
if (!Directory.Exists(saves)) continue;
var tx = Path.Combine(profile, "save-tx");
if (Directory.Exists(tx))
{
// (the game names them with ten digits, ready-0000000001: its runtime/fs_host.c "ready-%010u", an unsigned 32-bit n)
var ready = Directory.GetDirectories(tx, "ready-*")
.Select(d => (Dir: d, M: Regex.Match(Path.GetFileName(d), @"^ready-(\d{1,10})$")))
.Where(r => r.M.Success && IsSaveSet(r.Dir))
.OrderByDescending(r => long.Parse(r.M.Groups[1].Value)).FirstOrDefault();
if (ready.Dir != null) return ready.Dir;
}
var account = Directory.GetDirectories(saves)
.Where(d => Regex.IsMatch(Path.GetFileName(d), "^[0-9a-fA-F]{32}$") && IsSaveSet(d))
.OrderByDescending(d => Describe("", d).Last).FirstOrDefault();
if (account != null) return account;
}
}
catch (Exception) { }
return null;
}
/// The game folder NX2navi's launcher built into, from its settings (<launcher>\data\launcher.json, "game_dir"); null when
/// the launcher is not there or never built a game
static string? NaviGameDir(string launcher)
{
try
{
var file = Path.Combine(launcher, "data", "launcher.json");
if (!File.Exists(file)) return null;
var json = File.ReadAllText(file).TrimStart('\uFEFF');
var parsed = new System.Web.Script.Serialization.JavaScriptSerializer().DeserializeObject(json) as Dictionary<string, object>;
return parsed != null && parsed.TryGetValue("game_dir", out var g) && g is string { Length: > 0 } game ? game : null;
}
catch (Exception) { return null; }
}
/// Every save of this game found on the PC: the emulators' usual folders, the folders of programs the desktop and Start menu start /// Every save of this game found on the PC: the emulators' usual folders, the folders of programs the desktop and Start menu start
/// (portable emulators keep a "user" folder beside them), and Ryujinx's numbered saves that hold this game's files /// (portable emulators keep a "user" folder beside them), Ryujinx's numbered saves that hold this game's files, and NX2navi's
/// games (its launcher's own game folder and the one its settings name, <drive>:\Games\NX2navi, and beside a shortcut's program)
public static List<SaveSet> FindEmulatorSaves() public static List<SaveSet> FindEmulatorSaves()
{ {
var found = new List<SaveSet>(); var found = new List<SaveSet>();
@@ -73,7 +122,24 @@ static class Saves
if (!Directory.Exists(saves)) return; if (!Directory.Exists(saves)) return;
foreach (var s in SafeDirs(saves)) Add(name, Path.Combine(s, "0")); foreach (var s in SafeDirs(saves)) Add(name, Path.Combine(s, "0"));
} }
void Navi(string game) // (an NX2navi game folder)
{
if (NaviSave(game) is { } save) Add("NX2navi", save);
}
void NaviLauncher(string launcher) // (the folder of NX2navi's launcher: its own game folder, and the one it was told to use)
{
Navi(Path.Combine(launcher, "game"));
if (NaviGameDir(launcher) is { } game) Navi(game);
}
var appData = Install.TestRoot != null ? Path.Combine(Install.TestRoot, "Roaming") : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); var appData = Install.TestRoot != null ? Path.Combine(Install.TestRoot, "Roaming") : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var local = Install.TestRoot != null ? Path.Combine(Install.TestRoot, "Local") : Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
NaviLauncher(Path.Combine(local, "Programs", "NX2navi"));
if (Install.TestRoot == null)
foreach (var drive in DriveInfo.GetDrives())
{
try { if (drive.DriveType == DriveType.Fixed && drive.IsReady) Navi(Path.Combine(drive.RootDirectory.FullName, "Games", "NX2navi")); }
catch (Exception) { }
}
foreach (var e in Emulators) foreach (var e in Emulators)
{ {
var root = Path.Combine(appData, e); var root = Path.Combine(appData, e);
@@ -87,6 +153,8 @@ static class Saves
var name = Path.GetFileNameWithoutExtension(exe) + " (" + dir + ")"; var name = Path.GetFileNameWithoutExtension(exe) + " (" + dir + ")";
Nand(name, Path.Combine(dir, "user")); Nand(name, Path.Combine(dir, "user"));
Ryujinx(name, Path.Combine(dir, "portable")); Ryujinx(name, Path.Combine(dir, "portable"));
Navi(dir); // (a shortcut to the game itself)
NaviLauncher(dir); // (a shortcut to NX2navi's launcher)
} }
return found.OrderByDescending(s => s.Last).ToList(); return found.OrderByDescending(s => s.Last).ToList();
} }
@@ -143,6 +211,9 @@ static class Saves
public static string? FindIn(string dir) public static string? FindIn(string dir)
{ {
if (IsSaveSet(dir)) return dir; if (IsSaveSet(dir)) return dir;
// (an NX2navi game folder or its profile: the save the game would load, which a search by depth would not pick when a
// finished commit waits beside the account folder)
if (NaviSave(dir) is { } navi) return navi;
var queue = new Queue<(string, int)>(); var queue = new Queue<(string, int)>();
queue.Enqueue((dir, 0)); queue.Enqueue((dir, 0));
var looked = 0; var looked = 0;
@@ -161,9 +232,10 @@ static class Saves
/// A game or emulator that has these saves open: it would write over the copy when it closes /// A game or emulator that has these saves open: it would write over the copy when it closes
public static string? RunningGame() public static string? RunningGame()
{ {
foreach (var n in new[] { "Triforce", "hookshot", "EvilOOT", "eden", "yuzu", "suyu", "sudachi", "citron", "torzu", "Ryujinx" }) // ("ocarina" is the program NX2navi builds)
foreach (var n in new[] { "Triforce", "hookshot", "EvilOOT", "eden", "yuzu", "suyu", "sudachi", "citron", "torzu", "Ryujinx", "ocarina" })
foreach (var p in Process.GetProcessesByName(n)) foreach (var p in Process.GetProcessesByName(n))
if (Install.TestRoot == null || InTestRoot(p)) return n; if (Install.TestRoot == null || InTestRoot(p)) return n == "ocarina" ? "NX2navi" : n;
return null; return null;
} }

View File

@@ -80,6 +80,22 @@ static class Program
Log("convert-saves " + args[cv + 1] + " -> " + args[cv + 2] + ", backup " + (b ?? "none")); Log("convert-saves " + args[cv + 1] + " -> " + args[cv + 2] + ", backup " + (b ?? "none"));
return 0; return 0;
} }
// (testing: --find-saves writes every save of the game the Convert saves page would list to setup.log; --find-saves <folder>
// the save Choose a folder would take from that folder)
var fs = Array.IndexOf(args, "--find-saves");
if (fs >= 0)
{
if (fs + 1 < args.Length && !args[fs + 1].StartsWith("--"))
{
var set = Saves.FindIn(args[fs + 1]);
Log("find-saves " + args[fs + 1] + ": " + (set ?? "none"));
return set != null ? 0 : 1;
}
var sets = Saves.FindEmulatorSaves();
foreach (var set in sets) Log("find-saves: " + set.Name + ", " + set.Slots + " slot(s), " + set.Folder);
Log("find-saves: " + sets.Count + " found");
return 0;
}
// (testing: --check-game <.nup | exefs folder> writes the version check's answer to setup.log) // (testing: --check-game <.nup | exefs folder> writes the version check's answer to setup.log)
var cg = Array.IndexOf(args, "--check-game"); var cg = Array.IndexOf(args, "--check-game");
if (cg >= 0 && cg + 1 < args.Length) if (cg >= 0 && cg + 1 < args.Length)

View File

@@ -1,4 +1,4 @@
// The Convert saves page: an emulator's saves into Triforce, or Triforce's out to an emulator (Saves.cs). // The Convert saves page: an emulator's or NX2navi's saves into Triforce, or Triforce's out to one of them (Saves.cs).
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -145,7 +145,7 @@ sealed partial class Shell
} }
if (pick == null) if (pick == null)
{ {
SavesInfo.Text = (found.Count == 0 ? "No emulator saves of this game were found. " : "") + SavesInfo.Text = (found.Count == 0 ? "No saves of this game from an emulator or NX2navi were found. " : "") +
(into ? "Use Choose a folder to point at the saves (the folder with option.sav and slot_00 to slot_05)." (into ? "Use Choose a folder to point at the saves (the folder with option.sav and slot_00 to slot_05)."
: "Use Choose a folder to point at the emulator's save folder for this game (0400486024DEC000)."); : "Use Choose a folder to point at the emulator's save folder for this game (0400486024DEC000).");
return; return;

View File

@@ -47,6 +47,7 @@ int64_t hos_now_ns(void);
VK_API_H = r""" VK_API_H = r"""
#pragma once #pragma once
enum { HOS_MOUSE_LEFT = 1, HOS_MOUSE_RIGHT = 2, HOS_MOUSE_MIDDLE = 4 }; enum { HOS_MOUSE_LEFT = 1, HOS_MOUSE_RIGHT = 2, HOS_MOUSE_MIDDLE = 4 };
enum { HOS_OPT_GAME_OPTIONS = 48 };
""" """
FIXTURE = r""" FIXTURE = r"""
@@ -72,6 +73,7 @@ static int pointer_hidden; /* (the cursor hidden while the pad is in use: the
static int menu_frees, menu_gone; /* (the game's menus' mouse: freed for a menu's frame; their close told) */ static int menu_frees, menu_gone; /* (the game's menus' mouse: freed for a menu's frame; their close told) */
void hos_mouse_game_menu(void) { menu_frees++; } void hos_mouse_game_menu(void) { menu_frees++; }
void hos_mouse_game_menu_gone(void) { menu_gone++; } void hos_mouse_game_menu_gone(void) { menu_gone++; }
void rx_option_set(int id, int value) { (void)id, (void)value; } /* (the Options screen named: the renderer's) */
int hos_mouse_wheel_take(void) { const int w = wheel_next; wheel_next = 0; return w; } /* (the wheel only, mouse kept) */ int hos_mouse_wheel_take(void) { const int w = wheel_next; wheel_next = 0; return w; } /* (the wheel only, mouse kept) */
int hos_mouse_game_pointer(int *x, int *y, int *w, int *h, uint32_t *pressed, int *wheel) { int hos_mouse_game_pointer(int *x, int *y, int *w, int *h, uint32_t *pressed, int *wheel) {
*x = ptr_x, *y = ptr_y, *w = 3840, *h = 2160, *pressed = pressed_next, *wheel = wheel_next; *x = ptr_x, *y = ptr_y, *w = 3840, *h = 2160, *pressed = pressed_next, *wheel = wheel_next;
@@ -299,6 +301,87 @@ int main(void) {
""" """
# The game's own Options screen named for the renderer (its tabs sit in it): every system's, the mouse or not. On Windows
# the file's other half is compiled for this (HOS_OOT_MENU_NO_MOUSE), which is the half Linux gets
OPTIONS_FIXTURE = r"""
#include "hos.h"
#include "../gpu/vk/vk_api.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
uint8_t *fake_heap;
static int64_t now_ns = 1000000000;
int64_t hos_now_ns(void) { return now_ns; }
void hos_log(const char *fmt, ...) { (void)fmt; }
static int told, told_id, told_value;
void rx_option_set(int id, int value) { told++, told_id = id, told_value = value; }
void hos_oot_menu_focus(Ctx *c, uint64_t screen, uint64_t pane, uint64_t lr);
void hos_oot_menu_tick(Ctx *c, uint64_t screen);
int hos_oot_options_front(void);
static int fails;
#define CHECK(x) do { if (!(x)) { printf("FAIL line %d: %s\n", __LINE__, #x); fails++; } } while (0)
int main(void) {
fake_heap = calloc(1, 4 << 20);
Ctx ctx;
memset(&ctx, 0, sizeof ctx);
const uint64_t options = FAKE_BASE + 0x1000, other = FAKE_BASE + 0x2000;
const uint64_t options_vt = 0x84c0f108ULL, other_vt = 0x84c0bc18ULL;
memcpy(GP(options), &options_vt, 8);
memcpy(GP(other), &other_vt, 8);
CHECK(!hos_oot_options_front());
hos_oot_menu_tick(&ctx, 0); /* (no screen) */
hos_oot_menu_tick(&ctx, 8); /* (not a guest address) */
hos_oot_menu_tick(&ctx, HOS_GUEST_SPACE - 4); /* (its vtable would end past the guest's space) */
hos_oot_menu_tick(&ctx, other); /* (another screen: the pause menu's vtable) */
hos_oot_menu_focus(&ctx, other, other + 64, 0);
CHECK(told == 0 && !hos_oot_options_front());
hos_oot_menu_tick(&ctx, options);
CHECK(told == 1 && told_id == HOS_OPT_GAME_OPTIONS && told_value == 1);
CHECK(hos_oot_options_front());
now_ns += 100000000; /* (0.1 s on, no frame of it between: still in front) */
CHECK(hos_oot_options_front());
hos_oot_menu_tick(&ctx, options);
CHECK(told == 2);
now_ns += 300000000; /* (0.3 s with none: closed) */
hos_oot_menu_tick(&ctx, other);
CHECK(told == 2 && !hos_oot_options_front());
/* (the screen's memory is another screen's later: its vtable as it is now) */
memcpy(GP(options), &other_vt, 8);
hos_oot_menu_tick(&ctx, options);
CHECK(told == 2 && !hos_oot_options_front());
if (!fails) printf("PASS\n");
return fails != 0;
}
"""
class OotOptionsScreenTests(unittest.TestCase):
def test_names_the_options_screen_without_the_mouse(self):
compiler = shutil.which("gcc") or shutil.which("clang")
if not compiler:
self.skipTest("no C compiler")
with tempfile.TemporaryDirectory(prefix="hookshot-oot-options-") as tmp:
tmp = Path(tmp)
(tmp / "host").mkdir()
(tmp / "gpu" / "vk").mkdir(parents=True)
(tmp / "host" / "hos.h").write_text(HOS_H, encoding="utf-8")
(tmp / "gpu" / "vk" / "vk_api.h").write_text(VK_API_H, encoding="utf-8")
shutil.copy(ROOT / "host" / "oot_menu.c", tmp / "host" / "oot_menu.c")
(tmp / "host" / "t.c").write_text(OPTIONS_FIXTURE, encoding="utf-8")
binary = tmp / "t.exe"
other_half = ["-DHOS_OOT_MENU_NO_MOUSE"] if sys.platform == "win32" else []
build = subprocess.run([compiler, "-std=gnu11", "-Wall", "-O1", "-g", str(tmp / "host" / "t.c")] +
["-c", "-o", str(tmp / "t.o")], text=True, capture_output=True)
self.assertEqual(build.returncode, 0, build.stderr)
build = subprocess.run([compiler, "-std=gnu11", "-Wall", "-O1", "-g"] + other_half +
["-c", str(tmp / "host" / "oot_menu.c"), "-o", str(tmp / "m.o")], text=True, capture_output=True)
self.assertEqual(build.returncode, 0, build.stderr)
build = subprocess.run([compiler, str(tmp / "t.o"), str(tmp / "m.o"), "-o", str(binary)], text=True, capture_output=True)
self.assertEqual(build.returncode, 0, build.stderr)
run = subprocess.run([str(binary)], text=True, capture_output=True, timeout=30)
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
class OotMenuMouseTests(unittest.TestCase): class OotMenuMouseTests(unittest.TestCase):
def test_points_and_clicks_the_menus(self): def test_points_and_clicks_the_menus(self):
if sys.platform != "win32": if sys.platform != "win32":