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.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-25 10:21:32 -06:00
parent 861702476a
commit 4fa4f9188b
881 changed files with 179428 additions and 15581 deletions

View File

@@ -31,6 +31,8 @@ static partial class Tests
yield return Sync("tools: unpack the whole zip, refuse unsafe names", ToolsUnpack);
yield return Sync("tools: base list and parts", ToolsParts);
yield return ("tools: update from the fake server with progress", ToolsUpdate);
yield return ("texture pack: download, stop and go on, hashes, names, replace, remove", TexturePackInstall);
yield return ("texture pack: the real pack end to end (TEXPACK_E2E)", TexturePackRealPack);
yield return Sync("build: @@ protocol from a recorded transcript", Protocol);
yield return Sync("build: estimates from history and without", Estimates);
yield return Sync("build: time left, slow first part of the shaders then fast", EtaSlowStart);
@@ -491,6 +493,11 @@ static partial class Tests
var o = Report.NoName(text, @"C:\Users\Ann", @"C:\Users\ANN~1");
Equal(@"%USERPROFILE%\AppData\x and %USERPROFILE%//Games and C:\Users\Anna\y and %USERPROFILE%\Temp", o, "the account's folder read as %USERPROFILE%");
Equal("b\nc", Report.Tail("a\nb\nc\n\n", 2).Replace("\r", ""), "tail");
// ((Triforce) 11-24) the switches set, by their names alone, in order; the PC's threads and RAM
Equal("Switches set: HOOKSHOT_JOBS, HOS_LOG_FILE, RX_VK_AA (their values are left out)",
Report.Switches(new[] { "PATH", "RX_VK_AA", "HOS_LOG_FILE", "HOOKSHOT_JOBS", "RX_", "USERNAME", "RX_VK_AA" }), "the switches set");
Equal("Switches set: none", Report.Switches(new[] { "PATH", "TEMP" }), "no switch set");
Check(Report.Pc().StartsWith("PC: " + Environment.ProcessorCount + " threads"), "the PC's threads");
}
static void LanguagesTest()

View File

@@ -102,6 +102,16 @@ static partial class Tests
foreach (var line in s.Split('\n'))
{
var code = line.Split("//")[0];
// ((Triforce) 11-24) arrays, pad_speaker[12] = {0, ...}: each element by its index, and the name alone where every
// element is the same (toggle[HOS_SW_ZL]: a symbol for an index)
var arr = Regex.Match(code, @"^\s*int\s+(\w+)\[\d+\]\s*=\s*\{([^}]*)\}\s*;");
if (arr.Success)
{
var vals = arr.Groups[2].Value.Split(',').Select(x => int.Parse(x.Trim())).ToList();
for (var i = 0; i < vals.Count; i++) d[arr.Groups[1].Value + "[" + i + "]"] = vals[i];
if (vals.Distinct().Count() == 1) d[arr.Groups[1].Value + "[]"] = vals[0];
continue;
}
var m = Regex.Match(code, @"^\s*int\s+(.*);");
if (!m.Success) continue;
foreach (var part in m.Groups[1].Value.Split(','))
@@ -122,9 +132,14 @@ static partial class Tests
Check(table.Count > 100, "the table read: " + table.Count + " entries");
var symbols = new Dictionary<string, int>
{
["kLastOutput"] = 9, ["OUTPUT_MIN_W"] = 640, ["OUTPUT_MAX_W"] = 7680, ["OUTPUT_MIN_H"] = 360, ["OUTPUT_MAX_H"] = 2880, ["ur::kValues - 1"] = 6, ["ur::kUpscalers - 1"] = 6, ["ur::kModels - 1"] = 3, ["aa_rows::kValues - 1"] = 3,
["kLastOutput"] = 9, ["OUTPUT_MIN_W"] = 640, ["OUTPUT_MAX_W"] = 7680, ["OUTPUT_MIN_H"] = 360, ["OUTPUT_MAX_H"] = 2880, ["ur::kValues - 1"] = 6, ["ur::kUpscalers - 1"] = 9, ["ur::kModels - 1"] = 3, ["aa_rows::kValues - 1"] = 3,
["2 + kMaxMics"] = 18, ["HOS_PROMPT_N"] = 6, ["mr7::FG_DLSS_LAST"] = 12, ["framegen_rows::kRowMax"] = 9,
// ((Triforce) 11-22..25: N64 Classic, the FPS counter's levels, Frame generation by, FSR 4 model, ReShade, Menu language)
["n64_rules::FAITHFUL"] = 1, ["n64_rules::REMEMBERED"] = 2, ["n64_rules::kPresets - 1"] = 2, ["fps_levels::kMax"] = 6,
["framegen_rows::kByMax"] = 1, ["ur::kFsr4Models - 1"] = 1, ["reshade::last_builtin_preset"] = 26, ["i18n::lang_count()"] = 14,
};
// (an array element by a symbol's index, toggle[HOS_SW_ZL]: the array's one value)
int Dflt(string field) => defaults.TryGetValue(field, out var v) ? v : defaults[Regex.Replace(field, @"\[.*\]$", "[]")];
int Num(string s, string what) => int.TryParse(s, out var v) ? v : symbols.TryGetValue(s, out v) ? v : throw new TestFailed(what + ": a symbol the test does not know, " + s);
var tabs = new Dictionary<string, GameOptionTab>
{
@@ -137,6 +152,8 @@ static partial class Tests
// parts' defaults, by the schema's own rules)
var hidden = table.Where(r => r.Tab == "TAB_HIDDEN" && r.Value != "nullptr").ToList();
var partDefaults = new Dictionary<string, int>(StringComparer.Ordinal);
// ((Triforce) 11-24/25) the game's own state among them (auto_tune, auto_for, n64_classic_last): kept keys, no part
hidden = hidden.Where(r => !GameOptionsSchema.KeptKeys.ContainsKey(GameOptionsSchema.IniKey(r.Name))).ToList();
foreach (var r in hidden)
{
var key = GameOptionsSchema.IniKey(r.Name);
@@ -150,7 +167,7 @@ static partial class Tests
}
Equal(string.Join(",", hidden.Select(r => GameOptionsSchema.IniKey(r.Name)).OrderBy(k => k, StringComparer.Ordinal)),
string.Join(",", GameOptionsSchema.Parts.Keys.OrderBy(k => k, StringComparer.Ordinal)), "the parts are the hidden rows");
var left = new[] { "&opts.language", "&opts.pad_layout" }; // (Game language: language.txt's; Layout preset: KeptKeys)
var left = new[] { "&opts.language", "&opts.pad_layout", "&output_pick", "&reshade_menu::user_pick" }; // (+ 11-24: the Output device and the User preset file, the game's own lists of this PC's devices and files) // (Game language: language.txt's; Layout preset: KeptKeys)
var sections = new Dictionary<string, string>();
var names = new List<string>();
foreach (var r in table)
@@ -177,7 +194,7 @@ static partial class Tests
else
{
Check(!row.IsMerged && GameOptionsSchema.IniKey(r.Name) == row.Key, r.Name + ": its own line, key " + row.Key);
Equal(defaults[r.Value["&opts.".Length..]], row.Default, r.Name + ": default");
Equal(Dflt(r.Value["&opts.".Length..]), row.Default, r.Name + ": default");
}
}
Equal(string.Join("|", names), string.Join("|", GameOptionsSchema.All.Select(r => r.Name)), "the rows, in the menu's order");
@@ -235,15 +252,15 @@ static partial class Tests
}
else Equal(0, r.Choices.Count, r.Name + ": a slider has no choice list");
}
Equal("Screen,Ultrawide,HDR,RenoDX,Overlay", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Display)), "Display's sections");
Equal("Upscaling,Anti-aliasing,Frame generation,Frame rate & latency,Textures,Advanced", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Graphics)), "Graphics' sections");
Equal("Controller,Mouse & keyboard,Rumble,Gameplay,Motion,Controls", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Controls)), "Controls' sections");
Equal("Sound,Microphone", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Audio)), "Audio's sections");
Equal("Game,Online", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.System)), "System's sections (with rows)");
Equal("Screen,Ultrawide,HUD,HDR,RenoDX,Accessibility,Overlay", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Display)), "Display's sections");
Equal("Evil HD,This PC,Upscaling,Anti-aliasing,N64 Classic,Frame generation,Frame rate & latency,Textures,Post-processing,Detail,Advanced", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Graphics)), "Graphics' sections");
Equal("Controller,Mouse & keyboard,Rumble,Gameplay,Motion,Hold to toggle,Controls", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Controls)), "Controls' sections");
Equal("Sound,Microphone,Controller speaker", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Audio)), "Audio's sections");
Equal("Achievements,Game,Saves & reports,Online", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.System)), "System's sections (with rows)");
string L(string key, int v) => GameOptionsSchema.Get(key).Label(v);
string Cs(string key) => string.Join("|", GameOptionsSchema.Get(key).Choices.Select(c => c.Value + "=" + c.Label));
Equal("-3=30|-2=40|-1=45|0=60 (the console's)|1=90|2=120|3=144|4=165|5=240|6=Monitor's rate", Cs("frame_rate_cap"), "fps cap");
Equal("-3=30|-2=40|-1=45|0=60 (the console's)|1=90|2=120|3=144|4=165|5=240|6=Monitor's rate|7=Uncapped", Cs("frame_rate_cap"), "fps cap");
Equal("7=1536x864 (handheld)|3=1920x1080|0=2048x1152|1=2560x1440|2=3840x2160|4=5120x1440|6=5120x2160|5=5120x2880|8=Screen|9=Custom (2560x1440)", Cs("output_res"),
"output sizes, smallest first, then Screen and Custom");
Equal("0=Game|1=NVIDIA DLSS|3=AMD FSR 3.1|4=AMD FSR 4", Cs("dlss"), "upscalers: the engines, in the menu's order");
@@ -254,7 +271,7 @@ static partial class Tests
Equal("0=Off|1=Expanded|2=Native|3=Native + RenoDX", Cs(GameOptionsSchema.HdrKey), "HDR, RenoDX merged in");
Equal("0=Off|1=Even|2=Steady, any rate|3=Steady, refresh steps", Cs(GameOptionsSchema.PacingKey), "frame pacing, steady merged in");
Equal("0=Auto|1=Switch|2=Xbox|3=PlayStation 4|4=PlayStation 5|5=Steam Deck|6=Keyboard & mouse", Cs("button_prompts"), "prompts");
Equal("0=Insert or F1|1=F1 only", Cs("menu_shortcut"), "menu shortcut");
Equal("0=Insert or F1|1=F1 only|2=Insert, F1 or Esc|3=Insert, F1 or touchpad|4=Insert, F1, Esc or touchpad", Cs("menu_shortcut"), "menu shortcut");
// (Low latency by the card's maker: NVIDIA's Reflex where it is not known)
var vendorBefore = GameOptionsSchema.LatencyVendorOf;
try
@@ -312,7 +329,7 @@ static partial class Tests
Equal("75% (3840x1620)", wide.Label("resolution"), "of the whole 5120x2160");
wide.Set("output_res", 2);
Equal("21:9", wide.Label("ultrawide"), "a 16:9 size: the row's shape");
Equal(4, wide.ChoicesOf("ultrawide").Count, "and its four choices");
Equal(5, wide.ChoicesOf("ultrawide").Count, "and its five choices (4:3 since N64 Classic)");
Equal("75% (3312x1398)", wide.Label("resolution"), "the row's 21:9 at the 4K output: kept to 3840x2160's pixels");
wide.Set("ultrawide", 0);
Equal("75% (2880x1620)", wide.Label("resolution"), "the game's own picture");
@@ -482,7 +499,8 @@ static partial class Tests
var info = new FileInfo(path);
var (len, time) = (info.Length, info.LastWriteTimeUtc);
var f = GameOptionsFile.Load(RealGame);
Check(f.Exists && f.Version == GameOptionsSchema.CurrentVersion, "read, version " + f.Version);
// (the game writes 10 since 11-24, a version the launcher leaves as it is: CurrentVersion)
Check(f.Exists && f.Version >= GameOptionsSchema.CurrentVersion, "read, version " + f.Version);
// (every key is a row or a kept one: these, knowingly. options_version: the format; menu_size: the old Menu size row;
// layout_preset: rebinds the pad_ lines in the game; the Debug tab's; pad_* and key_*: the Controls page's bindings)
Equal("", string.Join(",", f.UnknownKeys), "no key nobody knows");
@@ -497,7 +515,7 @@ static partial class Tests
if (r.Kind == GameOptionKind.Choice)
Check(f.ChoicesOf(r.Key).Any(c => c.Value == v && c.Label == label), r.Name + ": " + v + " = \"" + label + "\" is one of its choices");
else
Check(Regex.IsMatch(label, @"^(-?\d+( nits|%)?|\d\.\d\d|Off|Muted|Default \(24%\))$"), r.Name + ": a slider's label \"" + label + "\"");
Check(Regex.IsMatch(label, @"^(-?\d+( nits|%| ms)?|\d\.\d\d|Off|Muted|Default \(24%\)|(TV|Controller) waits \d+ ms|100% \(the game's\))$"), r.Name + ": a slider's label \"" + label + "\"");
Check(r.IsMerged || v == GameOptionsSchema.NativeStep || f.Raw(r.Key) == null || v == r.AsRead(GameOptionsFile.Atoi(f.Raw(r.Key)!)),
r.Name + ": the file's value as the game reads it");
}

View File

@@ -0,0 +1,128 @@
using System.Security.Cryptography;
using System.Text;
using Triforce.Logic;
using static Triforce.LogicTests.T;
namespace Triforce.LogicTests;
static partial class Tests
{
// ((Triforce, 11-25) Evil HD's texture pack: the launcher's download into the game folder (Logic/TexturePack.cs))
static string PackManifest(string id, params (string Name, byte[] Zip, int Files)[] parts)
{
var ps = string.Join(",", parts.Select(p => "{\"name\":\"" + p.Name + "\",\"size\":" + p.Zip.Length + ",\"sha256\":\"" +
Convert.ToHexStringLower(SHA256.HashData(p.Zip)) + "\",\"files\":" + p.Files + ",\"unpacked\":" + p.Zip.Length + "}"));
return "{\"id\":\"" + id + "\",\"textures\":3,\"files\":4,\"unpacked\":100,\"download\":" + parts.Sum(p => p.Zip.Length) + ",\"parts\":[" + ps + "]}";
}
static async Task TexturePackInstall()
{
using var s = new FakeServer();
var root = NewRoot("texpack");
var ctx = Ctx(root);
var game = Path.Combine(root, "game");
Directory.CreateDirectory(game);
var p1 = Zip(("00000000000000a1.png", "one"), ("00000000000000a1_m1.png", "one-1"));
var p2 = Zip(("00000000000000b2.png", "two"));
var p3 = Zip(("00000000000000c3.png", "three"));
var json = PackManifest("pack-1", ("pack-1-01.zip", p1, 2), ("pack-1-02.zip", p2, 1), ("pack-1-03.zip", p3, 1));
s.Add("/manifest.json", json);
s.Add("/pack-1-01.zip", p1);
s.Add("/pack-1-03.zip", p3); // (part 2 not there yet: the install stops at it)
var before = Environment.GetEnvironmentVariable("TRIFORCE_TEXPACK_URL");
Environment.SetEnvironmentVariable("TRIFORCE_TEXPACK_URL", s.Url);
try
{
using var http = Downloader.CreateHttp();
var tp = new TexturePack(ctx);
Equal(TexturePackHave.None, tp.Have(game), "nothing yet");
var m = await tp.ManifestAsync(http, CancellationToken.None);
Equal(3, m.Parts.Count, "the manifest's parts");
Equal(p1.Length + p2.Length + p3.Length, (int)tp.Remaining(game, m), "all of it to download");
var failed = false;
try { await tp.InstallAsync(http, game, m, null, CancellationToken.None); } catch (HttpRequestException) { failed = true; }
Check(failed, "a missing part stops the install");
Equal(TexturePackHave.Partial, tp.Have(game, m), "part 1 in: partial");
Equal("one", File.ReadAllText(Path.Combine(TexturePack.Folder(game), "00000000000000a1.png")), "part 1's pictures unpacked");
Check(!File.Exists(Path.Combine(ctx.DownloadsFolder, "texpack", "pack-1-01.zip")), "a part's zip goes once it is unpacked");
// (the part comes: the install goes on from it, part 1 not fetched again)
s.Add("/pack-1-02.zip", p2);
var asked = s.Seen.Count(x => x.Contains("pack-1-01.zip"));
var seen = new List<TexturePackProgress>();
await tp.InstallAsync(http, game, m, seen.Add, CancellationToken.None);
Equal(asked, s.Seen.Count(x => x.Contains("pack-1-01.zip")), "part 1 not downloaded again");
Equal(TexturePackHave.Installed, tp.Have(game, m), "every part in: installed");
Equal("three", File.ReadAllText(Path.Combine(TexturePack.Folder(game), "00000000000000c3.png")), "the last part's pictures");
Check(seen.Count > 0 && seen[^1].Fraction == 1, "progress ends at 1");
Check(!Directory.EnumerateFiles(TexturePack.Folder(game), "*.new").Any(), "no half-written picture left");
// (a part whose bytes are not the manifest's: refused, its zip deleted, the folder left as it was)
var game2 = Path.Combine(root, "game2");
Directory.CreateDirectory(game2);
var good = Zip(("00000000000000d4.png", "four"));
var bad = PackManifest("pack-2", ("pack-2-01.zip", good, 1));
var hurt = (byte[])good.Clone();
hurt[hurt.Length / 2] ^= 0x5a; // (the same size, one byte changed: only the hash tells)
s.Add("/pack-2-01.zip", hurt);
var m2 = TexturePack.Parse(bad);
Throws<InvalidDataException>(() => tp.InstallAsync(http, game2, m2, null, CancellationToken.None).GetAwaiter().GetResult(), "a wrong hash");
Check(!File.Exists(Path.Combine(ctx.DownloadsFolder, "texpack", "pack-2-01.zip")), "the bad part is deleted, to be fetched anew");
Check(!File.Exists(Path.Combine(TexturePack.Folder(game2), "00000000000000d4.png")), "nothing unpacked from it");
// (a zip with a name a pack has not: nothing is written outside the folder)
var game3 = Path.Combine(root, "game3");
Directory.CreateDirectory(game3);
var evil = Zip(("../escape.png", "x"));
s.Add("/pack-3-01.zip", evil);
var m3 = TexturePack.Parse(PackManifest("pack-3", ("pack-3-01.zip", evil, 1)));
Throws<InvalidDataException>(() => tp.InstallAsync(http, game3, m3, null, CancellationToken.None).GetAwaiter().GetResult(), "a file a pack does not have");
Check(!File.Exists(Path.Combine(game3, "escape.png")), "nothing escapes the folder");
// (another pack in the folder is replaced; Remove takes the folder away)
await tp.InstallAsync(http, game, TexturePack.Parse(PackManifest("pack-4", ("pack-1-03.zip", p3, 1))), null, CancellationToken.None);
Check(!File.Exists(Path.Combine(TexturePack.Folder(game), "00000000000000a1.png")), "the older pack's pictures go");
Equal(TexturePackHave.Installed, tp.Have(game), "the new pack installed");
tp.Remove(game);
Equal(TexturePackHave.None, tp.Have(game), "removed");
Throws<FormatException>(() => TexturePack.Parse("{\"id\":\"x\",\"parts\":[]}"), "a manifest with no parts");
Throws<FormatException>(() => TexturePack.Parse("{\"id\":\"x\",\"parts\":[{\"name\":\"../a.zip\",\"size\":1,\"sha256\":\"" + new string('0', 64) + "\"}]}"), "a part named outside");
}
finally { Environment.SetEnvironmentVariable("TRIFORCE_TEXPACK_URL", before); }
}
/// <summary>The real pack end to end, only with TEXPACK_E2E=&lt;its address&gt; (and TEXPACK_E2E_REF=&lt;a pack folder&gt; to compare a
/// sample with): installed into a test game folder, every file there, the sample's bytes the same. Skipped otherwise.</summary>
static async Task TexturePackRealPack()
{
var url = Environment.GetEnvironmentVariable("TEXPACK_E2E");
if (string.IsNullOrEmpty(url)) { Console.WriteLine(" (skipped: TEXPACK_E2E not set)"); return; }
var root = NewRoot("texpack-e2e");
var ctx = Ctx(root);
var game = Path.Combine(root, "game");
Directory.CreateDirectory(game);
var before = Environment.GetEnvironmentVariable("TRIFORCE_TEXPACK_URL");
Environment.SetEnvironmentVariable("TRIFORCE_TEXPACK_URL", url);
try
{
using var http = Downloader.CreateHttp();
var tp = new TexturePack(ctx);
var m = await tp.ManifestAsync(http, CancellationToken.None);
var t0 = DateTime.UtcNow;
var lastPart = 0;
await tp.InstallAsync(http, game, m, p => { if (p.Part != lastPart) { lastPart = p.Part; Console.WriteLine(" " + p.Text + " (" + (int)(p.Fraction * 100) + "%)"); } }, CancellationToken.None);
Console.WriteLine(" installed in " + (int)(DateTime.UtcNow - t0).TotalSeconds + " s");
var files = Directory.GetFiles(TexturePack.Folder(game), "*.png");
Equal(m.Files, files.Length, "every picture of the pack");
Equal(TexturePackHave.Installed, tp.Have(game, m), "installed");
var reference = Environment.GetEnvironmentVariable("TEXPACK_E2E_REF");
if (!string.IsNullOrEmpty(reference))
foreach (var f in files.Where((_, i) => i % 997 == 0))
Check(File.ReadAllBytes(f).AsSpan().SequenceEqual(File.ReadAllBytes(Path.Combine(reference, Path.GetFileName(f)))), Path.GetFileName(f) + ": the same bytes");
}
finally
{
Environment.SetEnvironmentVariable("TRIFORCE_TEXPACK_URL", before);
try { Directory.Delete(root, true); } catch (Exception) { }
}
}
}