Triforce v0.7.0 "Sage Of Courage"

The 0.6 crashes after warps and area changes fixed (no write-back into memory the capture leaves out), invisible objects fixed (occlusion gate), DLSS frame generation flicker fixed, achievements, the renderer built with a play profile, faster translated game code, helper threads judged on settled scenes, memory, shader preparation, audio effects, launcher, controls and Linux fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-22 11:59:06 -06:00
parent 70c210cee1
commit e6f2f248f2
529 changed files with 55958 additions and 1898 deletions

View File

@@ -81,14 +81,17 @@ public sealed class GameOptionsFile : IGameOptionValues
return (int)Math.Clamp(v, int.MinValue, int.MaxValue);
}
/// <summary>Each row's value as the game reads the file at its start (menu_init): the last line's, in the row's range;
/// then the rules for a file of an older options_version (the defaults that changed: such a file wrote the old one
/// whether chosen or not), the old dynamic_resolution key, the Microphone without a device's name.</summary>
/// <summary>Each saved value as the game reads the file at its start (menu_init), by its key (every row's with a line of its
/// own, and the merged rows' parts): the last line's, in its range; then the rules for a file of an older options_version
/// (the defaults that changed: such a file wrote the old one whether chosen or not; version 8's moves of the rows that
/// went), the old dynamic_resolution key, the Microphone without a device's name.</summary>
Dictionary<string, int> Effective(Dictionary<string, string> lines, bool exists)
{
var v = new Dictionary<string, int>(StringComparer.Ordinal);
foreach (var r in GameOptionsSchema.All)
foreach (var r in GameOptionsSchema.All.Where(r => !r.IsMerged))
v[r.Key] = exists && lines.TryGetValue(r.Key, out var s) ? r.AsRead(Atoi(s)) : r.Default;
foreach (var p in GameOptionsSchema.Parts.Values)
v[p.Key] = exists && lines.TryGetValue(p.Key, out var s) ? p.AsRead(Atoi(s)) : p.Default;
if (!exists) return v;
foreach (var (key, value) in Migrated(lines)) if (v.ContainsKey(key)) v[key] = value;
if (!lines.ContainsKey(GameOptionsSchema.ResolutionKey) && lines.TryGetValue("dynamic_resolution", out var dyn))
@@ -108,6 +111,20 @@ public sealed class GameOptionsFile : IGameOptionValues
{
if (!lines.TryGetValue(key, out var s) || Atoi(s) != value) list.Add((key, value));
}
// ((Triforce, options_version 8) merged_rows.h migrate: the handheld profile is the Output resolution's 1536x864, the
// shared stick dead zone each stick's own where it had none of its own. The other rows that went move nothing; their
// lines stay until the game's next save drops them. A 436f9ac-based build's 7 has none of these lines: nothing moves)
if (version < 8)
{
if (lines.TryGetValue("handheld_profile", out var hh) && Atoi(hh) != 0) Force(GameOptionsSchema.OutputResKey, GameOptionsSchema.HandheldOutput);
var old = lines.TryGetValue("stick_dead_zone", out var sz) ? Atoi(sz) : 0;
var shared = old is > 0 and < 6 ? GameOptionsSchema.SharedZone[old] : -1;
foreach (var key in new[] { "left_stick_dead_zone", "right_stick_dead_zone" })
{
var own = lines.TryGetValue(key, out var s) ? GameOptionsSchema.Get(key).AsRead(Atoi(s)) : -1;
if (own < 0 && shared != own) list.Add((key, shared));
}
}
if (!hasVersion) Force("game_speed", 1);
if (version < 4) Force("descriptor_reuse", 1);
if (version < 5)
@@ -142,12 +159,21 @@ public sealed class GameOptionsFile : IGameOptionValues
// ---- the values ----
/// <summary>A row's value: the launcher's change, else what the game reads from the file (its default without a line).
/// KeyNotFoundException for a key that is no row (Raw has those).</summary>
/// <summary>A saved value by its key (a row's own line or a merged row's part): the launcher's change, else what the game
/// reads from the file (its default without a line).</summary>
int Value(string key) => set.TryGetValue(key, out var v) ? v : read[key];
/// <summary>A row's value as the game's menu shows it: the launcher's change, else what the game reads from the file (its
/// default without a line). A merged row's: the view of its parts (merged_rows.h); the Render resolution's: NativeStep while
/// the Upscaler is an engine's native AA (its saved value is then left for the engine's other steps). A merged row's part
/// by its own key: its saved value. KeyNotFoundException for any other key (Raw has those).</summary>
public int Get(string key)
{
GameOptionsSchema.Get(key);
return set.TryGetValue(key, out var v) ? v : read[key];
if (GameOptionsSchema.Part(key) != null) return Value(key);
var row = GameOptionsSchema.Get(key);
if (row.Merge != null) return row.Merge.Of(row.Parts!.Select(p => Value(p.Key)).ToArray());
if (key == GameOptionsSchema.ResolutionKey && GameOptionsSchema.FullScale(Value(GameOptionsSchema.UpscalerKey))) return GameOptionsSchema.NativeStep;
return Value(key);
}
/// <summary>A line's value as the file has it (the last line with that key, trimmed), null without one. Any key.</summary>
@@ -157,20 +183,22 @@ public sealed class GameOptionsFile : IGameOptionValues
/// sizes, the Anti-aliasing while an upscaler draws, the Microphone's device).</summary>
public string Label(string key) => GameOptionsSchema.Get(key).Label(Get(key), this);
/// <summary>The values a row offers with the other rows as they are here: the Render resolution's steps for the Upscaler
/// chosen (none with DLAA or a native AA), the Microphone's saved device, the row's own Choices otherwise. The value it has
/// now is always in the list (a hand-edited one where it would sit).</summary>
/// <summary>The values a row offers with the other rows as they are here: the Upscaler's engines (the one chosen by its
/// saved value: an engine's native AA is its engine here), the Render resolution's steps for the Upscaler chosen (Native
/// (100%), NativeStep, among DLSS's and FSR's), the Microphone's saved device, the row's own Choices otherwise. The value it
/// has now is always in the list (a hand-edited one where it would sit).</summary>
public IReadOnlyList<GameOptionChoice> ChoicesOf(string key)
{
var row = GameOptionsSchema.Get(key);
if (row.Kind == GameOptionKind.Slider) return Array.Empty<GameOptionChoice>();
var now = Get(key);
var values = key switch
{
GameOptionsSchema.ResolutionKey => GameOptionsSchema.ResolutionSteps(Get(GameOptionsSchema.UpscalerKey)).ToList(),
GameOptionsSchema.ResolutionKey => GameOptionsSchema.ResolutionSteps(Value(GameOptionsSchema.UpscalerKey)).ToList(),
GameOptionsSchema.UpscalerKey => GameOptionsSchema.UpscalerOrder.Select(e => e == GameOptionsSchema.Engine(now) ? now : e).ToList(),
GameOptionsSchema.MicKey => Raw(GameOptionsSchema.MicDeviceKey) is { Length: > 0 } ? new List<int> { 0, 1, 2 } : new List<int> { 0, 1 },
_ => row.Choices.Select(c => c.Value).ToList(),
};
var now = Get(key);
if (!values.Contains(now)) values.Add(now);
if (key == GameOptionsSchema.GpuKey)
{
@@ -182,57 +210,93 @@ public sealed class GameOptionsFile : IGameOptionValues
return values.Select(v => new GameOptionChoice(v, row.Label(v, this))).ToList();
}
/// <summary>The rows the launcher changed since the file was read, with their new values (Save writes these).</summary>
/// <summary>The saved values the launcher changed since the file was read, by their keys in the file (a merged row's are
/// its parts'), with their new values (Save writes these).</summary>
public IReadOnlyDictionary<string, int> Changes => set;
/// <summary>The file's lines that are no row here, in order, as (key, value): the KeptKeys and pad_/key_ lines, and
/// <summary>The file's lines that are no value here, in order, as (key, value): the KeptKeys and pad_/key_ lines, and
/// any key nobody knows (kept as it is). Lines without a key (blank, a comment) are kept too but not listed.</summary>
public IReadOnlyList<(string Key, string Value)> OtherLines =>
lines.Select(l => (Key: KeyOf(l), Line: l)).Where(x => x.Key != null && GameOptionsSchema.ByKey(x.Key) == null)
lines.Select(l => (Key: KeyOf(l), Line: l)).Where(x => x.Key != null && !GameOptionsSchema.IsValueKey(x.Key))
.Select(x => (x.Key!, x.Line[(x.Key!.Length + 1)..])).ToList();
/// <summary>OtherLines' keys that neither the schema nor KeptKeys knows.</summary>
public IReadOnlyList<string> UnknownKeys => OtherLines.Select(o => o.Key).Where(k => !GameOptionsSchema.IsKept(k)).Distinct().ToList();
/// <summary>Sets a row as the game's menu would (set_row): the value inside its range and on its steps (GameOptionRow.Clamp);
/// the Quality preset sets its rows (PresetValues, the Render resolution then on the Upscaler's nearest step); another
/// Upscaler moves the Render resolution to its nearest step; a row that is not PresetExempt, changed, turns the preset
/// back to Custom. Returns the value set. Nothing is written until Save.</summary>
/// <summary>Sets a row as the game's menu would (set_row): the value inside its range and on its steps (GameOptionRow.Clamp).
/// A merged row sets its parts (merged_rows.h *_set: one of a pair chosen, the other Off). The Upscaler takes an engine as
/// upscaler_rows.h step_engine does: the Render resolution's Native (100%) goes with it (the game's own at 100% becomes the
/// engine's native AA and back), the Render resolution then on the engine's nearest step; an engine's native AA value
/// (DLAA 2, FSR 4's 5, FSR 3.1's 6) is set as it is. The Render resolution's NativeStep makes the Upscaler its engine's
/// native AA (the game's own: 100%); another step with a native AA makes it the engine again (step_resolution). A merged
/// row's part by its own key: in its range. Returns the row's value afterwards. Nothing is written until Save.
/// (options_version 8: no Quality preset turns back to Custom.)</summary>
public int Set(string key, int value)
{
var row = GameOptionsSchema.Get(key);
var v = row.Clamp(value);
if (key == GameOptionsSchema.PresetKey)
if (GameOptionsSchema.Part(key) is { } part)
{
Put(key, v);
foreach (var (k, pv) in GameOptionsSchema.PresetValues(v)) Put(k, pv);
if (v > 0) Put(GameOptionsSchema.ResolutionKey, GameOptionsSchema.SnapResolution(Get(GameOptionsSchema.UpscalerKey), Get(GameOptionsSchema.ResolutionKey)));
return v;
Put(key, part.AsRead(value));
return Value(key);
}
var changed = Get(key) != v;
Put(key, v);
if (key == GameOptionsSchema.UpscalerKey)
Put(GameOptionsSchema.ResolutionKey, GameOptionsSchema.SnapResolution(v, Get(GameOptionsSchema.ResolutionKey)));
if (changed && !row.PresetExempt) Put(GameOptionsSchema.PresetKey, 0);
return v;
var row = GameOptionsSchema.Get(key);
if (row.Merge != null)
{
var parts = row.Parts!;
var split = row.Merge.Split(row.Clamp(value), parts.Select(p => Value(p.Key)).ToArray());
for (var i = 0; i < parts.Count; i++) Put(parts[i].Key, parts[i].AsRead(split[i]));
return Get(key);
}
const string Up = GameOptionsSchema.UpscalerKey, Res = GameOptionsSchema.ResolutionKey;
if (key == Up)
{
var v = row.Clamp(value);
var e = GameOptionsSchema.Engine(v);
if (!GameOptionsSchema.FullScale(v) && e != GameOptionsSchema.Engine(Value(Up)) && GameOptionsSchema.NativeSize(Value(Up), Value(Res)))
{
if (e == 0) Put(Res, 1); // (the game's own at 100%)
else v = GameOptionsSchema.NativeOf(e);
}
else if (!GameOptionsSchema.FullScale(v) && e == GameOptionsSchema.Engine(Value(Up))) v = Value(Up); // (its engine already: as it is)
Put(Up, v);
Put(Res, GameOptionsSchema.SnapResolution(v, Value(Res)));
return Get(key);
}
if (key == Res)
{
var up = Value(Up);
if (value == GameOptionsSchema.NativeStep)
{
if (GameOptionsSchema.Engine(up) == 0) Put(Res, 1);
else Put(Up, GameOptionsSchema.NativeOf(GameOptionsSchema.Engine(up)));
return Get(key);
}
if (GameOptionsSchema.FullScale(up)) Put(Up, GameOptionsSchema.Engine(up));
Put(Res, row.Clamp(value));
return Get(key);
}
Put(key, row.Clamp(value));
return Get(key);
}
void Put(string key, int v)
{
if (read[key] == v) set.Remove(key); // (what the game reads from the file already: nothing to write)
// (what the game reads from the file already: nothing to write. ((Triforce) 11-22) But for the GPU device row's card chosen
// again while the file has no name for it, or another one (a number saved before 11-20, in Windows' order): its number and
// name are written, as the game finds the card by the name first; nothing was written before and the number decided)
if (read[key] == v && !(key == GameOptionsSchema.GpuKey && GpuNameDiffers(v))) set.Remove(key);
else set[key] = v;
}
/// <summary>The benchmark's recommendations (key to value): the Quality preset first when it is one of them, then each
/// other row with Set's rules (so a row the preset set to the same value leaves it as it is; one that differs, and is not
/// PresetExempt, makes it Custom, as in the game). KeyNotFoundException, and nothing set, for a key that is no row.
/// Returns the rows' values afterwards, for the keys given. Nothing is written until Save.</summary>
bool GpuNameDiffers(int v) =>
GameOptionsSchema.GpuNameOf(v) is { } name && (Raw(GameOptionsSchema.GpuNameKey) ?? "").Trim() != name;
/// <summary>The benchmark's recommendations (key to value), each with Set's rules, in the order given. KeyNotFoundException,
/// and nothing set, for a key that is no row (nor a merged row's part). Returns the values afterwards, for the keys given.
/// Nothing is written until Save.</summary>
public IReadOnlyDictionary<string, int> Apply(IReadOnlyDictionary<string, int> values)
{
foreach (var k in values.Keys) GameOptionsSchema.Get(k);
if (values.TryGetValue(GameOptionsSchema.PresetKey, out var p)) Set(GameOptionsSchema.PresetKey, p);
foreach (var (k, v) in values)
if (k != GameOptionsSchema.PresetKey) Set(k, v);
foreach (var k in values.Keys) if (GameOptionsSchema.Part(k) == null) GameOptionsSchema.Get(k);
foreach (var (k, v) in values) Set(k, v);
return values.Keys.ToDictionary(k => k, Get, StringComparer.Ordinal);
}
public IReadOnlyDictionary<string, int> Apply(Dictionary<string, int> values) => Apply((IReadOnlyDictionary<string, int>)values);
@@ -243,7 +307,7 @@ public sealed class GameOptionsFile : IGameOptionValues
/// get its value, every other line stays exactly as the file has it (so a line changed outside since Load is kept, as
/// the game's merge keeps it), a changed row the file has no line for is added before options_version. A file of an
/// older options_version is brought up to the current one as the game would read it (the values its rules give are
/// written, options_version=7), so the game does not read the launcher's values by the old rules. The whole file is
/// written, options_version=8), so the game does not read the launcher's values by the old rules. The whole file is
/// written beside it as .new and then put in its place: a reader never meets half a file, and a failure leaves the old
/// one (IOException). Nothing to write: nothing written. The caller refuses while the game runs (Game.IsRunning).
/// Afterwards this object holds the file as written.</summary>
@@ -283,7 +347,7 @@ public sealed class GameOptionsFile : IGameOptionValues
else outLines.Add(l);
}
var missing = write.Keys.Where(k => !done.Contains(k) && k != GameOptionsSchema.VersionKey)
.OrderBy(k => GameOptionsSchema.ByKey(k) is { } r ? IndexOf(r) : int.MaxValue).Select(k => k + "=" + write[k]).ToList();
.OrderBy(k => GameOptionsSchema.RowOfLine(k) is { } r ? IndexOf(r) : int.MaxValue).Select(k => k + "=" + write[k]).ToList();
var at = outLines.FindIndex(l => KeyOf(l) == GameOptionsSchema.VersionKey);
if (at < 0) at = outLines.Count;
outLines.InsertRange(at, missing);