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

View File

@@ -1,14 +1,17 @@
"""Check that a save which still holds the first adult night's time lock is repaired outside Hyrule Field.
"""Check that a save holding the first adult night's time lock where the game can never let it go is repaired, and only there.
The game holds the clock at 20:00 while `HrlField_isFirstNightTime_Adult` (MurmurHash3 0x8592aa82) is 1 and quest
0x4dbca27f is not Ready (f_8347c020, called from f_803edf70). The flag is only meaningful in Hyrule Field's first adult
night; a save in the Market, the castle or anywhere else with the flag still 1 can never leave night.
`oot_inventory_refresh` runs twice a second while a save is loaded and reads the map for it, so the repair lives there:
outside Hyrule Field, clear the flag with the game's own Bool and log it once.
The game holds the clock at 20:00 while the Bool 0x8592aa82 is 1 and quest 0x4dbca27f (Meet_DekuTree) is past its step
Ready (f_8347c020, called from f_803edf70). 0x8592aa82 is `HrlField_HasEnteredFirstTime_Adult` by its MurmurHash3 (it was
named HrlField_isFirstNightTime_Adult here, which is 0xf1024b60). Sheik's cutscene sets it the first time Link becomes an
adult (Dm_TimeTemple_0055) and the adult Market's gate into Hyrule Field clears it on arrival
(Dm_SY_BancChangeArrive_HyruleField_02): the night is the adult Market's until then, the game's own. A child holding it
(no child's way out clears it) or an adult in Hyrule Field's map holding it (out without that arrival) is held for good.
`oot_inventory_refresh` runs twice a second while a save is loaded and reads the map and age for it, so the repair lives
there: clear the flag for those two through the game's own Bool setter (the live value and the save's copy: the live byte
alone came back as 1 at the next load) and log it once; an adult anywhere else keeps it.
This cuts the real `oot_inventory_refresh` (and `oot_first_night_fix` when the source has it) out of host/hos_main.c and
runs it against made-up save state, with no game and no romfs. Without the repair the flag stays 1 and the first case
fails; with it the flag is cleared. Run it with:
runs it against made-up save state, with no game and no romfs. Run it with:
python -I tests/test_oot_first_night.py --cc gcc
"""
@@ -30,11 +33,13 @@ FIXTURE = r'''
typedef struct { uint64_t x[32]; } Ctx;
static int flag = 1; /* HrlField_isFirstNightTime_Adult */
static int flag = 1; /* HrlField_HasEnteredFirstTime_Adult, the live value */
static int saved = 1; /* (its copy in the save) */
static int child = 1; /* Sequence_IsChildhood: 1 child, 0 adult */
static int age_known = 1;
static int event_playing; /* the game's event manager has an active event */
static const char *map_name = "Market_Child";
static int cleared;
static int cleared, live_only;
static void hos_log(const char *fmt, ...) { (void)fmt; }
static void rx_option_set(int id, int value) { (void)id; (void)value; }
@@ -42,16 +47,15 @@ static int oot_item_get(Ctx *c, const char *name) { (void)c; (void)name; return
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) { *value = child; return 1; }
if (hash == 0xcea220d3u && age_known) { *value = child; return 1; }
if (hash == 0x8592aa82u) { *value = flag; return 1; }
return 0;
}
/* (the live byte alone: never for this flag, the save would keep 1) */
__attribute__((unused)) static int oot_gamedata_set_bool(Ctx *c, uint32_t hash, int value) {
(void)c;
if (hash != 0x8592aa82u) return 0;
if (flag != value) cleared++;
flag = value;
return 1;
(void)c, (void)value;
if (hash == 0x8592aa82u) live_only++;
return 0;
}
static int oot_gamedata_string(Ctx *c, uint32_t hash, char *buf, size_t size) {
(void)c;
@@ -59,10 +63,22 @@ static int oot_gamedata_string(Ctx *c, uint32_t hash, char *buf, size_t size) {
snprintf(buf, size, "%s", map_name);
return 1;
}
/* (the event manager, and its +104: the event playing) */
/* (the event manager, and its +104: the event playing; the game data manager) */
#define OOT_EVENTMGR_SLOT 0x84c9e090ULL
__attribute__((unused)) static uint64_t oot_singleton(Ctx *c, uint64_t slot) { (void)c; return slot == OOT_EVENTMGR_SLOT ? 0x1000 : 0; }
#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 != 0x8592aa82u || !is_bool) return 0;
if (flag != (int)value) cleared++;
flag = saved = (int)value;
return 1;
}
#define OOT_CHEAT_ITEM_BASE 100
#define OOT_CHEAT_AGE_ID 200
@@ -75,66 +91,79 @@ static const char *const oot_item_names[OOT_ITEM_COUNT] = {"Item_A", "Item_B"};
// REFRESH
static void check(const char *what, int want_flag, int want_cleared) {
if (flag != want_flag || cleared != want_cleared) {
fprintf(stderr, "FAIL: %s: flag %d (want %d), clears %d (want %d)\n", what, flag, want_flag, cleared, want_cleared);
if (flag != want_flag || saved != want_flag || cleared != want_cleared || live_only) {
fprintf(stderr, "FAIL: %s: flag %d saved %d (want %d), clears %d (want %d), live-only writes %d\n", what, flag, saved,
want_flag, cleared, want_cleared, live_only);
exit(1);
}
}
static void at(Ctx *c, int64_t *now, int set, int is_child, const char *map) {
*now += 500000000LL;
flag = saved = set, child = is_child, map_name = map, cleared = 0;
oot_inventory_refresh(c, *now);
}
int main(void) {
Ctx c = {0};
int64_t now = 0;
#ifdef SWITCH_OFF
/* HOS_OOT_FIRST_NIGHT_FIX=0: the repair is off for the whole run. */
flag = 1, map_name = "Market_Child", cleared = 0;
oot_inventory_refresh(&c, now);
at(&c, &now, 1, 1, "Market_Child");
check("the switch off leaves the flag", 1, 0);
at(&c, &now, 1, 0, "HyruleField_Adult");
check("the switch off leaves the flag in the Field", 1, 0);
puts("PASS: HOS_OOT_FIRST_NIGHT_FIX=0 leaves the flag alone");
return 0;
#else
/* The report's state: the adult first-night flag left set in a save that is in the Market. */
flag = 1, map_name = "Market_Child", cleared = 0;
oot_inventory_refresh(&c, now);
check("the flag is cleared outside Hyrule Field", 0, 1);
/* #1064: a child back from his first adult visit before the gate, in the Market: no child's way out clears it. */
at(&c, &now, 1, 1, "Market_Child");
check("a child in the Market", 0, 1);
at(&c, &now, 1, 1, "HyruleField_Child");
check("a child in the Field", 0, 1);
/* Hyrule Field is where the first night belongs: the repair must not touch it. */
now += 500000000LL;
flag = 1, map_name = "HyruleField", cleared = 0;
oot_inventory_refresh(&c, now);
check("the flag is left alone in Hyrule Field", 1, 0);
/* The report's save: an adult at Lon Lon Ranch, in Hyrule Field's map, held at 20:00 for good. */
at(&c, &now, 1, 0, "HyruleField_Adult");
check("an adult in the Field", 0, 1);
/* The first night itself: an adult in the Market or the Temple of Time keeps it, the gate's arrival clears it. */
at(&c, &now, 1, 0, "Market_Adult");
check("an adult in the Market", 1, 0);
at(&c, &now, 1, 0, "GanonCastle");
check("an adult outside Ganon's castle", 1, 0);
/* Age not known: nothing to decide on. */
age_known = 0;
at(&c, &now, 1, 1, "Market_Child");
check("the age not known", 1, 0);
age_known = 1;
/* A save that is already clear is not written again. */
now += 500000000LL;
flag = 0, map_name = "Market_Child", cleared = 0;
oot_inventory_refresh(&c, now);
at(&c, &now, 0, 1, "Market_Child");
check("a clear flag is left clear", 0, 0);
/* No map name this refresh: nothing to decide on. */
now += 500000000LL;
flag = 1, map_name = "", cleared = 0;
oot_inventory_refresh(&c, now);
at(&c, &now, 1, 1, "");
check("an empty map leaves the flag", 1, 0);
/* An event running (the escape's cutscene, say) leaves the flag for a later refresh. */
now += 500000000LL;
flag = 1, map_name = "Market_Child", event_playing = 1, cleared = 0;
oot_inventory_refresh(&c, now);
/* An event running (the gate's own arrival, say) leaves the flag for a later refresh... */
event_playing = 1;
at(&c, &now, 1, 0, "HyruleField_Adult");
check("an event running leaves the flag", 1, 0);
/* The event over, the next refresh clears it. */
/* ...and the event over, the next refresh clears it, if the event has not. */
now += 500000000LL;
event_playing = 0, cleared = 0;
oot_inventory_refresh(&c, now);
check("after the event it clears", 0, 1);
/* A map change after the Field: the next refresh clears it. */
now += 500000000LL;
flag = 1, map_name = "Market_Child", cleared = 0;
oot_inventory_refresh(&c, now);
check("a later map clears it", 0, 1);
/* Twice a second: a refresh within the half second does nothing. */
flag = saved = 1, cleared = 0;
oot_inventory_refresh(&c, now + 100000000LL);
check("within the half second", 1, 0);
puts("PASS: the first adult night's time lock is cleared outside Hyrule Field, and only there");
puts("PASS: the first adult night's time lock is cleared for a child and for an adult in Hyrule Field, through the "
"game's setter, and kept for an adult in the Market");
return 0;
#endif
}
@@ -155,7 +184,10 @@ def main():
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")
fix = re.search(r"^static int oot_first_night_fix\(Ctx \*c, const char \*map\) \{.*?^\}", host, re.M | re.S)
body = FIXTURE.replace("// FIX", fix.group() if fix else "").replace("// REFRESH", refresh)
# (the adult's map repair is asked from the same place: tests/test_oot_adult_map.py checks it; here it finds no flag)
maps = re.search(r"^static int oot_adult_map_fix\(Ctx \*c, const char \*map\) \{.*?^\}", host, re.M | re.S)
fixes = "\n\n".join(m.group() for m in (fix, maps) if m)
body = FIXTURE.replace("// FIX", fixes).replace("// REFRESH", refresh)
with tempfile.TemporaryDirectory(prefix="oot-first-night-") as tmp:
source = Path(tmp) / "test.c"
source.write_text(body, encoding="utf-8")