Triforce v0.7.1

Crash fixes (a load crash from the virtual cores' escape, the upscaler-before-the-bloom crash, out of memory at a file's open), slow motion after a movie fixed, three save files with per-save achievements (ZakyPew), ten more achievements and their own menu group, N64 Classic, native ultrawide output (Kaefergeneral), the community AMD frame-time fixes, the helper threads' calm-scene tuner and benchmark test, update and Linux launcher fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-23 13:12:59 -06:00
parent e6f2f248f2
commit 861702476a
153 changed files with 12615 additions and 1093 deletions

View File

@@ -1,20 +1,21 @@
"""The HUD on a picture wider than 16:9 (host/oot_wide_hud.h, host/oot_wide_hud.c, nx2/prompt_assets.py HUD_SIDE_PANES).
With the Insert menu's Ultrawide HUD row on Screen edges the hearts and the item slot sit in the picture's top corners
and the small map at its right edge; on Middle everything keeps the middle 16:9, as before. The rules checked here,
Screen edges moves the side-anchored HUD panes and animation states. Middle keeps the HUD in the middle 16:9. The rules checked here,
without the game:
- A layout in the middle: its projection times the squeeze, nothing moved. A kept one (a fade, a menu's background):
untouched. A 16:9 picture (squeeze 1) or no squeeze: untouched.
- A layout at an edge (the lab's switch): a point at the 16:9 grid's right edge lands on the picture's right edge, one
at its left edge on the picture's left edge, and the layout keeps its shape.
- A pane moved in a layout (the hearts', the item slot's, the small map's) goes as far as a whole layout moved by its
- A pane moved in a layout goes as far as a whole layout moved by its
projection: a corner pane lands on the picture's corner through the middle projection.
- prompts/wide.bin: one entry per pane and copy of each layout, and one per animation key that puts a pane at the small
map's place (the keys at 0 and other curves are left); a layout that is not the one known gives none.
- prompts/wide.bin: one entry per pane and copy of each layout, and one per bound x key at an edge, with the endpoint delta
adjusted where needed. A changed layout is skipped independently.
python -I -B tests/test_wide_hud.py
"""
from contextlib import redirect_stderr
from io import StringIO
import shutil
import struct
import subprocess
@@ -109,20 +110,49 @@ def layout(name, panes, curves=()):
for k in range(n):
struct.pack_into("<Q", b, names_at + 8 * k, offs[k])
struct.pack_into("<Q", b, recs_at + 8 * k, rec0 + 0x44 * k)
struct.pack_into("<f", b, rec0 + 0x44 * k + 0x10, 1.)
struct.pack_into("<i", b, rec0 + 0x44 * k + 0x28, 0 if k else -1)
struct.pack_into("<f", b, rec0 + 0x44 * k + 0x1c, xs[k])
for last, keys in curves:
bindings = {"DoCommand_00": [("PosType", 0x01600f7f)], "MapMenu_00": [("MapType", 0x0165177f), ("DungeonMiniMapPattern", 0x0165377f)],
"SaveLoadIcon_00": [("EnableText", 0x01600f7f)]}
for i, (last, keys) in enumerate(curves):
b += bytes(-len(b) % 8)
values = len(b)
b += struct.pack("<ff", last, 0.0)
b += struct.pack("<QII", len(b) + 16, 2 * len(keys), 4)
for value, slope in keys:
b += struct.pack("<ff", value, slope)
if i < len(bindings.get(name, [])):
anim, path = bindings[name][i]
if name == "MapMenu_00":
path = 0x01605f7f if anim == "MapType" else 0x0160677f
b += b"\0"
text = len(b)
b += anim.encode() + b"\0"
token = len(b)
b += path.to_bytes(6, "little")
b += bytes(-len(b) % 8)
desc = len(b)
channels = 1 if name == "SaveLoadIcon_00" else 2
b += struct.pack("<Q4H", token, 0, 65535, channels, 14)
curve = len(b)
b += struct.pack("<QQ", 0, values)
curves_at = [curve]
if channels == 2:
y_curve = len(b)
b += struct.pack("<QQ", 0, y_curve + 16)
b += struct.pack("<ffQIIff", 0, 0, y_curve + 40, 2, 4, -690, 0)
curves_at.append(y_curve)
tables = len(b)
b += struct.pack("<Q", desc) + struct.pack(f"<{channels}Q", *curves_at)
b += struct.pack("<QQIIQII", text, tables, 1, 8, tables+8, channels, 8)
return bytes(b)
GOOD = [("N_VRS_00", 1626.0), ("N_ScaleL_00", -1920.0), ("N_ScaleR_00", 1920.0), ("N_SubItemBaseFishing_00", 1270.0)]
MAP = [("N_VRS_00", 1536.0), ("N_MiniMapCap_00", 1470.0), ("N_LocalMap_00", 0.0), ("N_ItemIcon_00", 1666.0),
("N_Field_01", 1490.0), ("N_Dungeon_01", 1536.0), ("N_MiniMapReplace_00", 1470.0), ("P_MiniMapFrame_00", 1536.0),
("S_Floor_00", 1706.0), ("P_CapDungeon_00", 1536.0), ("N_PatternFieldMini_01", 0.0)]
("S_Floor_00", 1706.0), ("P_CapDungeon_00", 1536.0), ("N_MapIcon_00", 0.0), ("N_PatternDungeonMini_01", 0.0)]
# (the icons' layers: at 0 for the whole-screen map's patterns, at the small map's place for its own; then two curves that
# are not places: one with a slope, one with another value)
MAP_CURVES = [(0.0, [(0.0, 0.0), (0.0, 0.0), (1490.0, 0.0), (1490.0, 0.0), (0.0, 0.0)]),
@@ -134,7 +164,16 @@ MAP_CURVES = [(0.0, [(0.0, 0.0), (0.0, 0.0), (1490.0, 0.0), (1490.0, 0.0), (0.0,
def archive(status=None, the_map=None):
one = layout("PlayerStatus_00", GOOD) if status is None else status
two = layout("MapMenu_00", MAP, MAP_CURVES) if the_map is None else the_map
return b"SARC" + bytes(60) + layout("Other_00", [("N_ScaleL_00", -1920.0)]) + one + two + one + two
extra = (layout("ActionGuideTips_00", [("N_Guide_00", -1140)]) +
layout("Location_00", [("N_SmallDisplay_00", -1720), ("N_Large_00", 0)]) +
layout("EventSkip_00", [("W_GuideBg_00", 2110), ("Pa_Skip_00", 1796)]) +
layout("ChallengeAttention_00", [("N_Challenge_00", 660), ("T_Guide_00", 1716), ("T_Icon_00", 1770)]) +
layout("PaNumDisplay_00", [("P_NumBase_00", 1360), ("P_NumBaseLine_00", 1360), ("P_BaseDecide_00", 1360),
("N_IconPos_00", 1454), ("A_Num_00", 1482), ("N_PlusMinus_00", 1528)]) +
layout("NumDisplay_00", [("Pa_Parts_00", 0), ("Pa_Parts_01", 0), ("A_Bottle_00", 1300)]) +
layout("DoCommand_00", [("N_PosType_00", 234)], [(232, [(234, 0), (724, 0), (724, 0), (466, 0)])]) +
layout("SaveLoadIcon_00", [("N_InOut_00", -1720)], [(-3460, [(1740, 0), (1740, 0), (-1720, 0)])]))
return b"SARC" + bytes(60) + layout("Other_00", [("N_ScaleL_00", -1920.0)]) + one + two + extra + one + two + extra
class WideHudTest(unittest.TestCase):
@@ -158,12 +197,12 @@ class WideHudTest(unittest.TestCase):
got = prompt_assets.wide_panes(blarc)
# (the hearts' layout: four panes; the map's: eight panes, the two keys at 1490, the two at 1536 and that curve's
# value past its last key; two copies of each)
self.assertEqual(len(got), 2 * (4 + 8 + 2 + 2 + 1))
self.assertEqual(len(got), 2 * (4 + 8 + 2 + 2 + 1 + 17))
for off, side, x in got:
self.assertEqual(struct.unpack_from("<f", blarc, off)[0], x)
self.assertNotEqual(x, 0.0)
self.assertEqual({x for _, side, x in got if side < 0}, {-1920.0})
self.assertEqual({x for _, side, x in got if side > 0}, {1920.0, 1626.0, 1270.0, 1536.0, 1470.0, 1490.0, 1706.0})
self.assertEqual({x for _, side, x in got if side < 0}, {-1920.0, -1720.0, -1140.0, -3460})
self.assertEqual({x for _, side, x in got if side > 0}, {1920.0, 1626.0, 1270.0, 1536.0, 1470.0, 1490.0, 1706.0, 2110, 1796, 660, 1716, 1770, 1740, 0, 724, 1300})
first = blarc.index(layout("PlayerStatus_00", GOOD))
self.assertTrue(all(off >= first for off, _, _ in got)) # (the other layout's pane of the same name: left)
self.assertNotIn(1666.0, {x for _, _, x in got}) # (the whole-screen map's own pane: left)
@@ -177,25 +216,99 @@ class WideHudTest(unittest.TestCase):
self.assertEqual(len(raw), 8 + 12 * len(got))
self.assertEqual(struct.unpack_from("<Ib3xf", raw, 8), got[0])
def test_parent_grid(self):
lay = bytearray(layout("HUD", [("Parent", 1520), ("Child", -130)]))
records = list(prompt_assets.layout_panes(lay).values())
struct.pack_into("<i", lay, records[2] + 0x28, 1)
self.assertEqual(prompt_assets.hud_grid_x(lay, records, records[2]), 1390)
self.assertIsNone(prompt_assets.hud_grid_x(lay, records, records[2], {records[1]}))
struct.pack_into("<f", lay, records[1] + 0x10, 2.)
self.assertIsNone(prompt_assets.hud_grid_x(lay, records, records[2]))
def test_keys(self):
lay = layout("MapMenu_00", MAP, MAP_CURVES)
keys = prompt_assets.layout_keys(lay, {1490.0, 1536.0})
self.assertEqual(sorted(struct.unpack_from("<f", lay, o)[0] for o in keys), [1490.0, 1490.0, 1536.0, 1536.0, 1536.0])
self.assertEqual(prompt_assets.layout_keys(lay, {1.0, 2.0}), []) # (a curve with a slope is no place)
self.assertEqual(prompt_assets.layout_keys(lay, {1.0}), []) # (nor one with another value among them)
self.assertEqual(prompt_assets.hud_translation_path(82), 0x0165177f)
self.assertEqual(prompt_assets.hud_translation_path(86), 0x0165377f)
path = prompt_assets.hud_translation_path(list(prompt_assets.layout_panes(lay)).index("N_MapIcon_00"))
keys = prompt_assets.hud_track_keys(lay, "MapType", path, {1490: 1}, 2)
self.assertEqual(list(keys.values()), [(1, 1490)] * 2)
self.assertIsNone(prompt_assets.hud_track_keys(lay, "MapType", 0x0165377f, {1490: 1}, 2))
wrong_attr = lay.replace(struct.pack("<4H", 0, 65535, 2, 14), struct.pack("<4H", 0, 65535, 2, 15))
self.assertIsNone(prompt_assets.hud_track_keys(wrong_attr, "MapType", path, {1490: 1}, 2))
def test_track_guards(self):
name = "MapMenu_00"
sides = prompt_assets.HUD_SIDE_PANES[name]
def rows(blob):
return prompt_assets.wide_layout(blob, name, sides)
def parent(child, ancestor):
lay = bytearray(layout(name, MAP, MAP_CURVES))
panes = prompt_assets.layout_panes(lay)
struct.pack_into("<i", lay, panes[child] + 0x28, list(panes).index(ancestor))
return lay
self.assertTrue(rows(parent("N_PatternDungeonMini_01", "N_MapIcon_00")))
self.assertIsNone(rows(parent("N_MapIcon_00", "N_PatternDungeonMini_01")))
self.assertIsNone(rows(parent("N_Field_01", "N_MapIcon_00")))
lay = layout(name, MAP, MAP_CURVES)
for fields in [(0, 0, 2, 14), (0, 65535, 1, 14), (1, 65535, 2, 14)]:
self.assertIsNone(rows(lay.replace(struct.pack("<4H", 0, 65535, 2, 14), struct.pack("<4H", *fields))))
self.assertTrue(rows(layout(name, MAP, [(0, [(0, 0), (1490, 0), (0, 0)]), *MAP_CURVES[1:]])))
for slopes in [(1, 0), (0, 1)]:
ramp = [(0, slopes[0]), (1490, slopes[1]), (0, 0)]
self.assertIsNone(rows(layout(name, MAP, [(0, ramp), *MAP_CURVES[1:]])))
def test_static_guards(self):
name = "ActionGuideTips_00"
sides = prompt_assets.HUD_SIDE_PANES[name]
def guide(x):
return layout(name, [("N_Guide_00", x)])
self.assertIsNone(prompt_assets.wide_layout(guide(-640), name, sides))
self.assertTrue(prompt_assets.wide_layout(guide(-641), name, sides))
self.assertIsNone(prompt_assets.wide_layout(guide(-641) + bytes.fromhex("7f0f60010000"), name, sides))
duplicate = layout(name, [("N_Guide_00", -642), ("N_Guide_00", -641)])
last = prompt_assets.layout_panes(duplicate)["N_Guide_00"]
self.assertEqual(struct.unpack_from("<f", duplicate, last + 0x1c)[0], -641)
self.assertIsNone(prompt_assets.wide_layout(duplicate, name, sides))
good = archive()
removed = prompt_assets.wide_layout(good, name, sides)
expected = [entry for entry in prompt_assets.wide_panes(good) if entry not in removed]
self.assertEqual(prompt_assets.wide_panes(good.replace(guide(-1140), guide(-640))), expected)
def test_ring_clash_and_independent_layout_failure(self):
good = archive()
def entries(name):
return set(prompt_assets.wide_layout(good, name, prompt_assets.HUD_SIDE_PANES[name]))
action = entries("DoCommand_00")
tips = entries("ActionGuideTips_00")
all_entries = prompt_assets.wide_panes(good)
off = min(action)[0]
ring = [(0, 0, 0, [(off + 3, b"x")])]
bad = good.replace(layout("ActionGuideTips_00", [("N_Guide_00", -1140)]),
layout("ActionGuideTips_00", [("N_Guide_00", -640)]))
for blob, omitted in [(good, action), (bad, action | tips)]:
log = StringIO()
with redirect_stderr(log):
self.assertEqual(prompt_assets.wide_panes(blob, ring), [e for e in all_entries if e not in omitted])
self.assertIn("DoCommand_00: HUD edge position overlaps a Talk ring run", log.getvalue())
self.assertEqual("ActionGuideTips_00: unknown HUD layout" in log.getvalue(), blob == bad)
def test_unknown_layout(self):
self.assertIsNone(prompt_assets.wide_panes(b"SARC" + bytes(60))) # (no such layout)
self.assertIsNone(prompt_assets.wide_panes(archive(status=layout("PlayerStatus_00", GOOD[:3])))) # (a pane missing)
def status(blob):
return prompt_assets.wide_layout(blob, "PlayerStatus_00", prompt_assets.HUD_SIDE_PANES["PlayerStatus_00"])
def map_rows(blob):
return prompt_assets.wide_layout(blob, "MapMenu_00", prompt_assets.HUD_SIDE_PANES["MapMenu_00"])
self.assertTrue(prompt_assets.wide_panes(archive(the_map=b""))) # other layouts survive a missing map
self.assertIsNone(status(archive(status=layout("PlayerStatus_00", GOOD[:3])))) # (a pane missing)
moved = [(n, 1800.0 if n == "N_ScaleR_00" else x) for n, x in GOOD]
self.assertIsNone(prompt_assets.wide_panes(archive(status=layout("PlayerStatus_00", moved)))) # (not at the corner)
self.assertIsNone(status(archive(status=layout("PlayerStatus_00", moved)))) # (not at the corner)
twice = layout("PlayerStatus_00", GOOD + [("N_Other_00", 1270.0)])
self.assertIsNone(prompt_assets.wide_panes(archive(status=twice))) # (a place held elsewhere)
self.assertIsNone(status(archive(status=twice))) # (a place held elsewhere)
other = layout("MapMenu_00", MAP + [("N_Else_00", 1706.0)], MAP_CURVES)
self.assertIsNone(prompt_assets.wide_panes(archive(the_map=other))) # (the same, the map's)
self.assertIsNone(map_rows(archive(the_map=other))) # (the same, the map's)
ramp = layout("MapMenu_00", MAP, MAP_CURVES + [(0.0, [(0.0, 0.0), (1536.0, 3.0)])])
self.assertIsNone(prompt_assets.wide_panes(archive(the_map=ramp))) # (a key that moves there)
self.assertIsNone(prompt_assets.wide_panes(archive(the_map=b""))) # (no map layout)
self.assertIsNone(map_rows(archive(the_map=ramp))) # (a key that moves there)
self.assertIsNone(map_rows(archive(the_map=b""))) # (no map layout)
self.assertIsInstance(prompt_assets.WIDE, float) # (the icons' own constant: a table of this file once took its name)
def test_wired(self):