Triforce v0.9.0

Character tab, faster renderer defaults, HD rumble shipped, and the 11-30 bug pass: ending softlock below 60 fps, adult first-night lock, Intel Arc robust buffers, adult map, randomizer load order.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-30 20:55:14 -06:00
parent 8cb23131f9
commit 822ee913bc
86 changed files with 8128 additions and 438 deletions

241
tests/test_oot_adult_map.py Normal file
View File

@@ -0,0 +1,241 @@
"""Check that an adult who left the Temple of Time without its first walk out gets the map page and the minimap back.
The pause menu's Map page (f_80b47d70, asked by UIMapMenuScreen f_834012c0: "Unavailable right now.", MapMessage_01, when
it answers no) and the HUD's minimap (f_805a2cf0) say yes for the child and, for the adult, only once
HavePlayedEvent.Dm_TimeTemple_0065 is 1 (Bool 0xc1b29b0a; the code reads it as struct HavePlayedEvent 0x2b05cbb9, member
Dm_TimeTemple_0065 0xc367dcdc). The adult Market's map plays that event when Link steps through an Area at the Temple of
Time's door (Market_Adult_Static, Market_Adult_Prefab_50e3's logic); nothing else in the romfs plays it or sets the flag.
An adult who leaves the temple another way (a teleport, the age switch, the no-clip flight) has no maps as an adult for
good (#1576602300313506086). `oot_adult_map_fix`, asked by `oot_inventory_refresh` twice a second while a save is loaded,
sets the flag through the game's own Bool setter (the live value and the save's copy) for an adult outside the Market,
the Chamber of Sages and the dream world, once no event plays, and logs it.
This cuts the real `oot_inventory_refresh`, `oot_first_night_fix` and `oot_adult_map_fix` out of host/hos_main.c and runs
them against made-up save state, with no game and no romfs. Run it with:
python -I tests/test_oot_adult_map.py --cc gcc
"""
import argparse
import os
import re
import subprocess
import tempfile
from pathlib import Path
RUN_ALL_ARGS = ["--cc", "gcc"]
ROOT = Path(__file__).resolve().parents[1]
def murmur3(text):
"""MurmurHash3 x86 32, seed 0: the game's GameData names (as oot_murmur3 in host/hos_main.c)."""
data = text.encode()
h = 0
mask = 0xFFFFFFFF
for i in range(0, len(data) // 4 * 4, 4):
k = int.from_bytes(data[i:i + 4], "little")
k = (k * 0xCC9E2D51) & mask
k = ((k << 15) | (k >> 17)) & mask
k = (k * 0x1B873593) & mask
h ^= k
h = ((h << 13) | (h >> 19)) & mask
h = (h * 5 + 0xE6546B64) & mask
tail = data[len(data) // 4 * 4:]
k = 0
for i in reversed(range(len(tail))):
k ^= tail[i] << (8 * i)
if tail:
k = (k * 0xCC9E2D51) & mask
k = ((k << 15) | (k >> 17)) & mask
k = (k * 0x1B873593) & mask
h ^= k
h ^= len(data)
h ^= h >> 16
h = (h * 0x85EBCA6B) & mask
h ^= h >> 13
h = (h * 0xC2B2AE35) & mask
h ^= h >> 16
return h
NAMES = {
0xC1B29B0A: "HavePlayedEvent.Dm_TimeTemple_0065",
0x2B05CBB9: "HavePlayedEvent",
0xC367DCDC: "Dm_TimeTemple_0065",
0xCEA220D3: "Sequence_IsChildhood",
0x7BDF3694: "Sequence_IsInDreamWorld",
}
FIXTURE = r'''
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct { uint64_t x[32]; } Ctx;
static int played; /* HavePlayedEvent.Dm_TimeTemple_0065, the live value */
static int saved; /* (its copy in the save) */
static int child = 1; /* Sequence_IsChildhood: 1 child, 0 adult */
static int age_known = 1, flag_known = 1;
static int event_playing; /* the game's event manager has an active event */
static const char *map_name = "Market_Child";
static int sets, logs, live_only;
static void hos_log(const char *fmt, ...) { (void)fmt; logs++; }
static void rx_option_set(int id, int value) { (void)id; (void)value; }
static int oot_item_get(Ctx *c, const char *name) { (void)c; (void)name; return 0; }
static int oot_pouch_count(Ctx *c, const char *name) { (void)c; (void)name; return 0; } /* (a save is loaded) */
static int oot_gamedata_bool(Ctx *c, uint32_t hash, int *value) {
(void)c;
if (hash == 0xcea220d3u && age_known) { *value = child; return 1; }
if (hash == 0xc1b29b0au && flag_known) { *value = played; return 1; }
return 0; /* (HrlField_HasEnteredFirstTime_Adult not found: the first night's repair leaves it) */
}
/* (the live byte alone: never for this flag, the save would keep 0) */
__attribute__((unused)) static int oot_gamedata_set_bool(Ctx *c, uint32_t hash, int value) {
(void)c, (void)value;
if (hash == 0xc1b29b0au) live_only++;
return 0;
}
static int oot_gamedata_string(Ctx *c, uint32_t hash, char *buf, size_t size) {
(void)c;
if (hash != 0x1d6189dau) return 0;
snprintf(buf, size, "%s", map_name);
return 1;
}
#define OOT_EVENTMGR_SLOT 0x84c9e090ULL
#define OOT_GAMEDATA_SLOT 0x84c9e180ULL
__attribute__((unused)) static uint64_t oot_singleton(Ctx *c, uint64_t slot) {
(void)c;
return slot == OOT_EVENTMGR_SLOT ? 0x1000 : slot == OOT_GAMEDATA_SLOT ? 0x2000 : 0;
}
__attribute__((unused)) static uint64_t recomp_load64(Ctx *c, uint64_t a) { (void)c; return a == 0x1000 + 104 ? (uint64_t)event_playing : 0; }
/* (the game's SetBool: the live value and the save's copy) */
__attribute__((unused)) static int oot_gd_set(Ctx *c, uint64_t mgr, uint32_t hash, uint32_t value, int is_bool) {
(void)c;
if (mgr != 0x2000 || hash != 0xc1b29b0au || !is_bool) return 0;
sets++;
played = saved = (int)value;
return 1;
}
#define OOT_CHEAT_ITEM_BASE 100
#define OOT_CHEAT_AGE_ID 200
enum { HOS_OPT_SIM_TURF_AREA_TEXT = 410, HOS_OPT_SIM_TURF_AREA };
#define OOT_ITEM_COUNT 2
static const char *const oot_item_names[OOT_ITEM_COUNT] = {"Item_A", "Item_B"};
// FIX
// REFRESH
static void check(const char *what, int want, int want_sets) {
if (played != want || saved != want || sets != want_sets || live_only || (want_sets && logs < want_sets)) {
fprintf(stderr, "FAIL: %s: flag %d saved %d (want %d), sets %d (want %d), logs %d, live-only writes %d\n", what,
played, saved, want, sets, want_sets, logs, live_only);
exit(1);
}
}
static void at(Ctx *c, int64_t *now, int flag, int is_child, const char *map) {
*now += 500000000LL;
played = saved = flag, child = is_child, map_name = map, sets = 0, logs = 0;
oot_inventory_refresh(c, *now);
}
int main(void) {
Ctx c = {0};
int64_t now = 0;
#ifdef SWITCH_OFF
at(&c, &now, 0, 0, "ForestTemple");
check("the switch off leaves the flag", 0, 0);
puts("PASS: HOS_OOT_ADULT_MAP_FIX=0 leaves the flag alone");
return 0;
#else
/* The report's save: an adult in the Forest Temple who never walked out of the Temple of Time's door. */
at(&c, &now, 0, 0, "ForestTemple");
check("an adult in the Forest Temple", 1, 1);
at(&c, &now, 0, 0, "HyruleField_Adult");
check("an adult in Hyrule Field", 1, 1);
at(&c, &now, 0, 0, "IceCavern");
check("an adult in the Ice Cavern", 1, 1);
/* The game's own first walk out is still to come: the Market (the Temple of Time is in it), the Chamber of Sages. */
at(&c, &now, 0, 0, "Market_Adult");
check("an adult in the Market", 0, 0);
at(&c, &now, 0, 0, "SageRoom");
check("an adult in the Chamber of Sages", 0, 0);
at(&c, &now, 0, 0, "DreamWorld");
check("an adult in the dream world", 0, 0);
/* The child's maps never ask for it, and his first walk out is ahead of him. */
at(&c, &now, 0, 1, "KokiriForest_Child");
check("a child", 0, 0);
/* Already played: nothing written. */
at(&c, &now, 1, 0, "ForestTemple");
check("a save that has it", 1, 0);
/* Age or flag not known, no map name: nothing to decide on. */
age_known = 0;
at(&c, &now, 0, 0, "ForestTemple");
check("the age not known", 0, 0);
age_known = 1, flag_known = 0;
at(&c, &now, 0, 0, "ForestTemple");
check("the flag not known", 0, 0);
flag_known = 1;
at(&c, &now, 0, 0, "");
check("no map", 0, 0);
/* An event playing waits for the next refresh. */
event_playing = 1;
at(&c, &now, 0, 0, "ForestTemple");
check("an event playing", 0, 0);
event_playing = 0;
now += 500000000LL;
oot_inventory_refresh(&c, now);
check("after the event", 1, 1);
puts("PASS: an adult outside the Market, the Chamber of Sages and the dream world without the Temple of Time's first "
"walk out gets HavePlayedEvent.Dm_TimeTemple_0065 through the game's setter; the child and the Market are left");
return 0;
#endif
}
'''
def cut(source, pattern, what):
match = re.search(pattern, source, re.M | re.S)
if not match:
raise SystemExit("could not find %s in host/hos_main.c" % what)
return match.group()
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--cc", default="gcc")
args = parser.parse_args()
for value, name in NAMES.items():
if murmur3(name) != value:
raise SystemExit("FAIL: MurmurHash3(%r) is %#010x, not %#010x" % (name, murmur3(name), value))
host = (ROOT / "host/hos_main.c").read_text(encoding="utf-8")
refresh = cut(host, r"^static void oot_inventory_refresh\(Ctx \*c, int64_t now\) \{.*?^\}", "oot_inventory_refresh")
night = cut(host, r"^static int oot_first_night_fix\(Ctx \*c, const char \*map\) \{.*?^\}", "oot_first_night_fix")
maps = cut(host, r"^static int oot_adult_map_fix\(Ctx \*c, const char \*map\) \{.*?^\}", "oot_adult_map_fix")
if "oot_adult_map_fix(c, map)" not in refresh:
raise SystemExit("FAIL: oot_inventory_refresh does not ask oot_adult_map_fix")
body = FIXTURE.replace("// FIX", night + "\n\n" + maps).replace("// REFRESH", refresh)
with tempfile.TemporaryDirectory(prefix="oot-adult-map-") as tmp:
source = Path(tmp) / "test.c"
source.write_text(body, encoding="utf-8")
env = {k: v for k, v in os.environ.items() if k not in ("HOS_OOT_ADULT_MAP_FIX", "HOS_OOT_FIRST_NIGHT_FIX")}
for name, flags, switch in (("on", [], {}), ("off", ["-DSWITCH_OFF"], {"HOS_OOT_ADULT_MAP_FIX": "0"})):
binary = Path(tmp) / ("test-%s.exe" % name)
subprocess.run([args.cc, "-std=gnu11", "-Wall", "-Wextra", "-Werror"] + flags + [str(source), "-o", str(binary)],
check=True)
subprocess.run([str(binary)], check=True, env=dict(env, **switch))
if __name__ == "__main__":
main()