Describe what the code does in comments and docs.

Comments say what the code does and why, docs/maxwell.md keeps the Maxwell facts, and fetch_refs.sh clones only the checkout the build reads. Code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-07 03:20:42 -05:00
parent a1871280a3
commit 1b39aabd37
128 changed files with 481 additions and 577 deletions

View File

@@ -1,7 +1,6 @@
# Code patches for NX2navi 1.4.3 main (recomp/patches.py). Ported from MacNativeGames
# games/<game>/runtime/game_patches_v143.c (MIT, Copyright (c) 2026 MacNativeGames contributors) at upstream 73c4821,
# each original word checked against the 1.4.3 main. MacNativeGames branches to veneers after the text; here a
# veneer's body is the site's replacement. The patch page holds three floats the runtime writes at every present
# Code patches for NX2navi 1.4.3 main (recomp/patches.py). Copyright (c) 2026 MacNativeGames contributors (MIT; see
# THIRD_PARTY_NOTICES.md). Each original word is checked against the 1.4.3 main, and each replacement sits in place
# at its site rather than behind a branch to a veneer. The patch page holds three floats the runtime writes at every present
# (frame_rate.c): +0 the 30 Hz ratio (seconds * 30), +4 the frame step in seconds, +8 the step in 60 Hz ticks.
set fps60 NX2NAVI_FPS60 1
@@ -34,7 +33,7 @@ site realtime main 2daa70 1e201820 d503201f # fdiv s0, s1, s0 -> nop
site realtime main 2daa74 1e2c1001 d503201f # fmov s1, #0.5 -> nop
site realtime main 2daa78 1e210800 d503201f # fmul s0, s0, s1 -> nop
# Equipment-switch cooldown (issue #18, found by JieML1100): the player update (main+0x2b0368) steps the countdown at
# Equipment-switch cooldown (issue #18): the player update (main+0x2b0368) steps the countdown at
# player state +0x109c through the timer step (main+0x1b0834, value += ratio * rate) only while it is above FLT_EPSILON,
# but the equipment gate (main+0x31cc7c) blocks weapon, shield and bow changes while it is above 0. Whole 30 Hz steps
# reach exactly 0; a measured ratio leaves a rounding remainder, and one in (0, FLT_EPSILON] is never stepped again and
@@ -56,7 +55,7 @@ site cloth main 28bc98 9400546a @page:x8 bd400104 1e240842 1e240863 9400546a #
# s1 is set again by the fmov two instructions on.
site bounce main 562a64 bd402920 bd402920 bd403921 1e210800 # ldr s0, [x9, #0x28]; ldr s1, [x9, #0x38]; fmul s0, s0, s1
# Fades (MacNativeGames game_patches_v143.c patch_fade_increment, upstream 3e9e7f67): the distance/LOD mesh fades and
# Fades: the distance/LOD mesh fades and
# the pre-actor fades add trunc(2.1 * ratio) to a counter each frame: 2 at 30 fps, 1 at 60, 0 above about 63.5 fps
# (ratio below 1 / 2.1), where a fade stops and its object stays translucent or invisible until a slower frame moves
# it on. Each site floors the increment at 1 without the flags: clz is 32 only for 0, so increment += clz >> 5. The
@@ -68,22 +67,22 @@ site fade main 95dd24 1e380008 1e380008 5ac0110a 53057d4a 0b0a0108 # the same,
site fade main 6155e4 1e38000a 1e38000a 5ac0114b 53057d6b 0b0b014a # fcvtzs w10, s0; clz w11, w10; lsr w11, w11, #5; add w10, w10, w11
site fade main 615660 1e38000a 1e38000a 5ac0114b 53057d6b 0b0b014a # the same, second pre-actor fade path
# Output size (upstream game_patches_v143.c patch_output_res; runtime/resolution.c switches the set on). The swapchain
# Output size (runtime/resolution.c switches the set on). The swapchain
# size nnMain writes comes from page +48; the display configuration's canvas (+0x10) and active output (+0x508) from
# page +32, and the configuration goes to page +40. x9 is dead at the publication point.
site output main bdb578 d280f008 @page:x8 # mov x8, #0x780 -> adrp x8, page (x9 is built in between)
site output main bdb584 f2c08708 f9401908 # movk x8, #0x438, lsl #32 -> ldr x8, [x8, #48]
site output main 3dcb28 d360fc64 @page:x9 f9001533 f9401123 f9000a63 d360fc64 # lsr x4, x3, #32: x3 = [page+32] first
# Scene render size (upstream patch_render_res): every path that picks the size meets at main+0x585e48; the renderer's
# Scene render size: every path that picks the size meets at main+0x585e48; the renderer's
# +0xcc4 / +0xcc8 take two floats from page +16. x3 is scratch in this function; w9 still holds the output size.
site scene main 585e48 1e220160 @page:x3 # scvtf s0, w11 -> adrp x3, page
site scene main 585e50 bd0cc660 2d420460 # str s0, [x19, #0xcc4] -> ldp s0, s1, [x3, #16]
site scene main 585e54 1e220140 bd0cc660 # scvtf s0, w10 -> str s0, [x19, #0xcc4]
site scene main 585e60 bd0cca60 bd0cca61 # str s0, [x19, #0xcc8] -> str s1, [x19, #0xcc8]
# Camera aspect ratio for a game resolution that is not 16:9 (upstream game_patches_v143.c and aspect_patch.h
# aspect_install / aspect_stub; runtime/resolution.c res_init writes the output's width / height to page +56 and
# Camera aspect ratio for a game resolution that is not 16:9
# (runtime/resolution.c res_init writes the output's width / height to page +56 and
# switches the set on). Each site leaves the ratio sead's perspective projection (+0xb0) takes in s0: two camera sites
# (update and setup) load the camera's copy of DefaultAspect 1.777778, two viewport routines divide width by height.
# The replacement loads the ratio from the page instead, so a 21:9 output shows more of the world at the sides with