mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-29 04:18:49 -04:00
Triforce v0.8.5
A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
@@ -53,6 +53,18 @@ import re
|
||||
import sys
|
||||
import whole_write # (rewrites written beside and moved over: issue 1197)
|
||||
|
||||
# ((Triforce, 11-26, LX-2 on v0.8.3) A lift with the flags as each function's locals (nx2/local_flags.py, on by default)
|
||||
# reads and writes c->z as fz_ (likewise fn_, fc_, fv_), and its scalar FCMP calls a64_fcmp32k, in nx2/local_flags.py's
|
||||
# profile form (the flags from _fk, then the exact compare under "if (!_fk)"; match it only as far as the _fk local, as
|
||||
# HORSE_TEST_LOCAL does): an edit that matches a flag by its text takes both forms, or it finds nothing in such a lift and
|
||||
# only warns. local_form(text): the text as such a lift writes it, by the kit's own rule
|
||||
# (third_party/a64-kit/lift/a64_lift.py FLAG_REF)
|
||||
FLAG_REF = re.compile(r"(?<![\w>.])c->([nzcv])\b")
|
||||
|
||||
|
||||
def local_form(text):
|
||||
return FLAG_REF.sub(r"f\1_", text)
|
||||
|
||||
DECL = "extern volatile int hos_fixed_resolution;\nextern volatile int hos_dynres_runs;\nextern volatile uint32_t hos_fixed_scale_bits;\n"
|
||||
OLD = "if (!((c->x[8] >> 0) & 1)) { goto L_8082640c; }"
|
||||
NEW = "if (hos_fixed_resolution || !((c->x[8] >> 0) & 1)) { goto L_8082640c; }\n hos_dynres_runs++;"
|
||||
@@ -170,7 +182,7 @@ def patch_mouse_camera(source):
|
||||
return None
|
||||
if "hos_mouse_camera(c->x[0]);" in source: # (made before: a lift patched again)
|
||||
return source
|
||||
at = start + len(CAM_HEAD)
|
||||
at = head_end(source, start + len(CAM_HEAD)) # ((Triforce, 11-27) after the flags' declaration: KIT_LOCALS)
|
||||
source = source[:at] + " hos_mouse_camera(c->x[0]); /* (nx2/oot_patches.py: native mouse look) */\n" + source[at:]
|
||||
return source.replace('#include "a64.h"\n', '#include "a64.h"\nextern void hos_mouse_camera(uint64_t camera);\n', 1)
|
||||
|
||||
@@ -622,6 +634,27 @@ HORSE_BRANCH = "if (!c->n) { goto L_82c5ae48; }\n"
|
||||
HORSE_SKIP = (" if (hos_oot_horse_whole_step((uint32_t)c->vreg[10][0], " + SOUND_SLOT + " + 2192)) { goto L_82c5ae48; }"
|
||||
" /* (nx2/oot_patches.py: a horse's jump blend above 60 fps) */\n")
|
||||
HORSE_DECL = "extern int hos_oot_horse_whole_step(uint32_t step_bits, uint64_t slot);\n"
|
||||
# ((Triforce, 11-26, LX-2) the same test and branch in a lift with the flags as locals: the FCMP's fast compare into its _fk
|
||||
# local (the kit's vectorize_fcmp with A64_LOCAL_FLAGS) and the N flag read as fn_. (11-27) As far as that local: what follows
|
||||
# it is the kit's "if (_fk) ..." or, as nx2/local_flags.py writes it for the hot profile, the flags and "if (!_fk) ...")
|
||||
HORSE_TEST_LOCAL = HORSE_TEST.replace("{ if (!a64_fcmp32(c,c->vreg[10],c->vreg[9])) ",
|
||||
"{ const uint32_t _fk = a64_fcmp32k(c,c->vreg[10],c->vreg[9]); ", 1)
|
||||
HORSE_BRANCH_LOCAL = local_form(HORSE_BRANCH)
|
||||
# ((Triforce, 11-27, LX-2) the line a lift with the flags as locals adds after the head of every function that uses a flag: the
|
||||
# kit's localize_regs, after any registers' locals. A patch that counts a function's first lines has to leave it out)
|
||||
FLAG_DECL = " uint8_t fn_ = c->n, fz_ = c->z, fc_ = c->c, fv_ = c->v;\n"
|
||||
# ((Triforce, 11-27, LX-2) the guest locals' lines the kit writes right after a function's head: the registers' (A64_LOCAL_REGS)
|
||||
# and the flags' (FLAG_DECL). nx2/split_giants.py takes them only as the body's first lines (locals_of): a hook at the head of
|
||||
# a function it cuts (split_giants.MIN_KB or more: the player camera's update, the zstd decoder's) goes after them (head_end),
|
||||
# or the giant is left whole, as the player camera's update was with the mouse look)
|
||||
KIT_LOCALS = re.compile(r"(?: uint64_t x\d+_ = c->x\[\d+\](?:, x\d+_ = c->x\[\d+\])*;\n)?(?:%s)?" % re.escape(FLAG_DECL))
|
||||
|
||||
|
||||
def head_end(source, at):
|
||||
"""Where a hook at a function's head goes: at (just after the head's line), past the kit's guest locals' lines"""
|
||||
return KIT_LOCALS.match(source, at).end()
|
||||
|
||||
|
||||
# A rigid body's update before the physics step, f_804f5030, on its path for a body driven to a target (x20 the controller, x23
|
||||
# the body): the game sets the target (+0x3c) to the body's position plus this frame's move and asks for (target - position) /
|
||||
# dt. Above 60 fps Havok's solve delivers only part of it (0.86 at 120 fps), the next target starts from where the body ended
|
||||
@@ -827,12 +860,15 @@ def patch_horse_jump(s):
|
||||
return s, 0
|
||||
head, end = at
|
||||
body = s[head:end]
|
||||
if body.count(HORSE_SKIP + HORSE_BRANCH) == 1:
|
||||
forms = ((HORSE_TEST, HORSE_BRANCH), (HORSE_TEST_LOCAL, HORSE_BRANCH_LOCAL)) # (the flags in the context, or locals)
|
||||
if any(body.count(HORSE_SKIP + branch) == 1 for _, branch in forms):
|
||||
return s, 1
|
||||
if body.count(HORSE_TEST) != 1 or HORSE_SKIP in body:
|
||||
form = [f for f in forms if body.count(f[0]) == 1]
|
||||
if len(form) != 1 or HORSE_SKIP in body:
|
||||
return s, 0
|
||||
line_end = body.find("\n", body.index(HORSE_TEST) + len(HORSE_TEST))
|
||||
if line_end < 0 or not body.startswith(HORSE_BRANCH, line_end + 1):
|
||||
test, branch = form[0]
|
||||
line_end = body.find("\n", body.index(test) + len(test))
|
||||
if line_end < 0 or not body.startswith(branch, line_end + 1):
|
||||
return s, 0
|
||||
body = body[:line_end + 1] + HORSE_SKIP + body[line_end + 1:]
|
||||
s = s[:head] + body + s[end:]
|
||||
@@ -942,7 +978,10 @@ def patch_cloth_solve(s):
|
||||
if body.count(CLOTH_SOLVE_OLD) != 1:
|
||||
return s, 0
|
||||
first = body.index(CLOTH_SOLVE_OLD)
|
||||
if body[:first].count("\n") > 2: # (the first store is the job's own first line, after the head and a hint)
|
||||
# (the first store is the job's own first line, after the head and a hint; a lift with the flags as locals puts their
|
||||
# declaration between the head and the hint (the kit's localize_regs, A64_LOCAL_FLAGS), which is no line of the job's own:
|
||||
# (Triforce, 11-27, LX-2 on v0.8.4) counted, it left the gate out and the cloth solving at every frame above 60 fps)
|
||||
if body[:first].replace(FLAG_DECL, "", 1).count("\n") > 2:
|
||||
return s, 0
|
||||
s = s[:head] + body[:first] + CLOTH_SOLVE_NEW + body[first:] + s[end:]
|
||||
if CLOTH_SOLVE_DECL not in s:
|
||||
@@ -1209,12 +1248,13 @@ def patch_host_zstd(s):
|
||||
head, end = at
|
||||
body = s[head:end]
|
||||
hook = ZSTD_HOOK % name
|
||||
if body.startswith(head_text + hook):
|
||||
first = head_end(body, len(head_text)) # ((Triforce, 11-27) after the kit's locals' lines: KIT_LOCALS)
|
||||
if body.startswith(hook, first):
|
||||
done += 1
|
||||
elif hook not in body:
|
||||
plain = _unmarked(body)
|
||||
if all(plain.count(_unmarked(line)) == 1 for line in shape):
|
||||
s = s[:head] + head_text + hook + body[len(head_text):] + s[end:]
|
||||
s = s[:head] + body[:first] + hook + body[first:] + s[end:]
|
||||
done += 1
|
||||
if done and ZSTD_DECL not in s:
|
||||
s = s.replace('#include "a64.h"\n', '#include "a64.h"\n' + ZSTD_DECL, 1)
|
||||
@@ -1251,12 +1291,17 @@ RGBA16F_DECL = "int hos_scene_rgba16f(void);\n"
|
||||
RGBA16F_OLD = (" c->x[9] = 0x1aULL;\n c->x[9] &= 0xFFFFFFFFULL;\n"
|
||||
" { uint64_t _r = (!c->z) ? c->x[10] : c->x[9]; _r &= 0xFFFFFFFFULL; c->x[9] = _r; }\nL_80672354:;")
|
||||
RGBA16F_NEW = RGBA16F_OLD.replace("c->x[9] = 0x1aULL;", "c->x[9] = hos_scene_rgba16f() ? 0x2cULL : 0x1aULL;", 1)
|
||||
# ((Triforce, 11-23, LX-2) the same csel with the flags as the function's locals, nx2/local_flags.py's default: the Z flag
|
||||
# is read as fz_. Without this form the patch was found 0 times in such a lift)
|
||||
RGBA16F_OLD_LOCAL = RGBA16F_OLD.replace("(!c->z)", "(!fz_)", 1)
|
||||
RGBA16F_NEW_LOCAL = RGBA16F_NEW.replace("(!c->z)", "(!fz_)", 1)
|
||||
|
||||
|
||||
def patch_scene_format(s):
|
||||
if RGBA16F_OLD not in s:
|
||||
return None
|
||||
return s.replace(RGBA16F_OLD, RGBA16F_NEW, 1).replace('#include "a64.h"\n', '#include "a64.h"\n' + RGBA16F_DECL, 1)
|
||||
for old, new in ((RGBA16F_OLD, RGBA16F_NEW), (RGBA16F_OLD_LOCAL, RGBA16F_NEW_LOCAL)):
|
||||
if old in s:
|
||||
return s.replace(old, new, 1).replace('#include "a64.h"\n', '#include "a64.h"\n' + RGBA16F_DECL, 1)
|
||||
return None
|
||||
|
||||
|
||||
# (from TomShafford/Hookshot 55d68e8cd6 and 65c1998222) f_804566e0's two calls of f_80522050, the GPU memory a model's material
|
||||
@@ -1567,6 +1612,7 @@ def patch_text_size(s):
|
||||
# the parameter base that path gives it (x26) and the code goes on where the other yaw paths join, at 0x80645ad8. The stick's
|
||||
# turn (state 4), the game's own recentre (state 2), the authored overrides, the pitch and the collision stay as they are.
|
||||
CAM_FOLLOW_ANCHOR = "L_8064720c:;\nif (!c->z) { goto L_806492c4; }\n"
|
||||
CAM_FOLLOW_ANCHOR_LOCAL = local_form(CAM_FOLLOW_ANCHOR) # ((Triforce, 11-26, LX-2) the Z flag as a local: fz_)
|
||||
CAM_FOLLOW_JOIN = "L_80645ad8:;\n"
|
||||
CAM_FOLLOW_HOOK = (" if (hos_disable_camera_centering()) { c->x[25] = c->x[26]; A64_POLL(c); goto L_80645ad8; }"
|
||||
" /* (nx2/oot_patches.py: the Camera centering row) */\n")
|
||||
@@ -1581,11 +1627,12 @@ def patch_camera_centering(s):
|
||||
return s, 0
|
||||
head, end = at
|
||||
body = s[head:end]
|
||||
if body.count(CAM_FOLLOW_ANCHOR) != 1 or body.count(CAM_FOLLOW_JOIN) != 1:
|
||||
anchor = CAM_FOLLOW_ANCHOR if CAM_FOLLOW_ANCHOR in body else CAM_FOLLOW_ANCHOR_LOCAL # (the flags in the context, or locals)
|
||||
if body.count(anchor) != 1 or body.count(CAM_FOLLOW_JOIN) != 1:
|
||||
return s, 0
|
||||
if CAM_FOLLOW_HOOK in body:
|
||||
return s, int(body.count(CAM_FOLLOW_ANCHOR + CAM_FOLLOW_HOOK) == 1)
|
||||
at = head + body.index(CAM_FOLLOW_ANCHOR) + len(CAM_FOLLOW_ANCHOR)
|
||||
return s, int(body.count(anchor + CAM_FOLLOW_HOOK) == 1)
|
||||
at = head + body.index(anchor) + len(anchor)
|
||||
s = s[:at] + CAM_FOLLOW_HOOK + s[at:]
|
||||
if CAM_FOLLOW_DECL not in s:
|
||||
s = s.replace('#include "a64.h"\n', '#include "a64.h"\n' + CAM_FOLLOW_DECL, 1)
|
||||
@@ -1717,6 +1764,10 @@ def patch_cct_speed(s):
|
||||
continue
|
||||
start, end = at
|
||||
body = s[start:end]
|
||||
if anchor != head and anchor.startswith(head) and anchor not in body:
|
||||
# ((Triforce, 11-27, LX-2 on v0.8.4) an anchor that goes on past the head: a lift with the flags as locals has their
|
||||
# declaration between (FLAG_DECL), and f_80964bf0's place was found 3 times, not 4: the tool did not scale it)
|
||||
anchor = head + FLAG_DECL + anchor[len(head):]
|
||||
if body.count(anchor + hook) == 1:
|
||||
done += 1
|
||||
elif body.count(anchor) == 1:
|
||||
@@ -1803,6 +1854,8 @@ OC_TICK_GATES = (
|
||||
"if (c->x[0] == 0) { { A64_POLL(c); hos_oc_wait = 0; goto L_828a92e4; } }"
|
||||
" /* (nx2/oot_patches.py: the wait's owner refused: no wait, and the pads are the game's again) */"),
|
||||
)
|
||||
# ((Triforce, 11-26, LX-2) the gates in a lift with the flags as locals: the mode check's Z read as fz_, before and after)
|
||||
OC_TICK_GATES_LOCAL = tuple((local_form(old), local_form(new)) for old, new in OC_TICK_GATES)
|
||||
OC_DONE_OLD = "recomp_store32(c,c->x[19] + 24,c->x[9]);"
|
||||
OC_DONE_NEW = (OC_DONE_OLD + "\n hos_oc_wait = 0;"
|
||||
" /* (nx2/oot_patches.py: the wait action finished) */")
|
||||
@@ -1823,6 +1876,9 @@ def patch_ocarina_wait(s):
|
||||
return None
|
||||
end = s.find("\nvoid f_", at + len(head))
|
||||
body = s[at:end if end >= 0 else len(s)]
|
||||
if head == OC_TICK_HEAD and not any(old in body or new in body for old, new in OC_TICK_GATES[:1]):
|
||||
# (no gate in the context's form: a lift with the flags as locals, whose gates read fz_)
|
||||
pairs = [OC_TICK_GATES_LOCAL[OC_TICK_GATES.index(pr)] if pr in OC_TICK_GATES else pr for pr in pairs]
|
||||
out = body
|
||||
for old, new in pairs:
|
||||
if new in out:
|
||||
|
||||
Reference in New Issue
Block a user