mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 01:29:57 -04:00
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:
@@ -1,4 +1,4 @@
|
||||
# Adapted from LAS Recomp tools/gen.py @ da35b83 (MIT, Copyright (c) 2026 Peiikai).
|
||||
# Copyright (c) 2026 Peiikai (MIT; see THIRD_PARTY_NOTICES.md).
|
||||
"""Generate C for the ExeFS modules: function discovery, then parallel emission into chunked C files.
|
||||
|
||||
Usage: gen.py --exefs build/extracted/v121/exefs --out generated/v121 [--modules main,subsdk0,sdk] [--jobs N]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Adapted from LAS Recomp tools/lifter.py @ da35b83 (MIT, Copyright (c) 2026 Peiikai).
|
||||
# Copyright (c) 2026 Peiikai (MIT; see THIRD_PARTY_NOTICES.md).
|
||||
"""AArch64 -> C static recompiler.
|
||||
|
||||
Integer, memory, and control flow are translated to C. FP/SIMD instructions (and CRC32) are
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""One loaded NSO module as the generator and its analyses see it: image at a guest base, .text as words,
|
||||
function seeds, and bounded-cache instruction lifting.
|
||||
|
||||
The function seeds and the .eh_frame_hdr reader are adapted from LAS Recomp tools/analyze.py and tools/gen.py
|
||||
@ da35b83 (MIT, Copyright (c) 2026 Peiikai).
|
||||
The function seeds and the .eh_frame_hdr reader: Copyright (c) 2026 Peiikai (MIT; see THIRD_PARTY_NOTICES.md).
|
||||
"""
|
||||
import struct
|
||||
from collections import OrderedDict
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Adapted from LAS Recomp tools/nso.py @ da35b83 (MIT, Copyright (c) 2026 Peiikai).
|
||||
# Copyright (c) 2026 Peiikai (MIT; see THIRD_PARTY_NOTICES.md).
|
||||
"""NSO loader: decompress segments, build the memory image, parse MOD0/dynamic info."""
|
||||
import struct
|
||||
import sys
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Code patches for NX2navi 1.1.0 main (recomp/patches.py). The sites come from MacNativeGames
|
||||
# games/<game>/runtime/game_patches.c (MIT, Copyright (c) 2026 MacNativeGames contributors) at upstream ebe621d, through
|
||||
# its 1.2.1 addresses in game_version.h (2db612b); each one was located again in 1.1.0 by instruction-window matching
|
||||
# and its original words checked against this build's main. The patch page holds two floats the runtime writes at every
|
||||
# Code patches for NX2navi 1.1.0 main (recomp/patches.py). Copyright (c) 2026 MacNativeGames contributors (MIT; see
|
||||
# THIRD_PARTY_NOTICES.md). Each site was located in 1.1.0 from its 1.2.1 address by instruction-window matching and
|
||||
# its original words checked against this build's main. The patch page holds two floats the runtime writes at every
|
||||
# present (frame_rate.c): +0 the 30 Hz ratio (seconds * 30), +4 the frame step in seconds.
|
||||
|
||||
set fps60 NX2NAVI_FPS60 1
|
||||
@@ -11,7 +10,7 @@ set bounce NX2NAVI_HIGHFPS_FIX 1
|
||||
set output NX2NAVI_PATCH_OUTPUT 0
|
||||
set scene NX2NAVI_PATCH_SCENE 0
|
||||
|
||||
# 60 fps: the adaptive present-interval controller (main+0x8f26c8, 1.0.0 0x8f6bec) gets the minimum interval 1.
|
||||
# 60 fps: the adaptive present-interval controller (main+0x8f26c8) gets the minimum interval 1.
|
||||
site fps60 main 90e978 6b08015f 7100055f # clamp: cmp w10, #1 (was cmp w10, w8 = minimum)
|
||||
site fps60 main 90e97c 1a89b10a 1a9fa52a # clamp: csinc w10, w9, wzr, ge (desired = max(desired, 1))
|
||||
site fps60 main 90e9a0 b9401a8a d503201f # lower trigger: nop the stored-candidate load
|
||||
@@ -20,8 +19,8 @@ site fps60 main 90ea40 1a88c1ac 1a9fc5ac # raise path: csinc w12, w13, wzr, gt
|
||||
site fps60 main 90ea94 b9400288 52800028 # lower path: mov w8, #1 (minimum interval 1)
|
||||
site fps60 main 90eab0 2a0a03f5 1a9fa555 # lower path: csinc w21, w10, wzr, ge (result never below 1)
|
||||
|
||||
# Real-time step: the VFR step (main+0x7ede6c, 1.0.0 0x7a83e4) and the global ratio after the controller call
|
||||
# (main+0x8f2394, 1.0.0 0x8f68b8) read ratio and seconds from the patch page instead of interval * 0.5 and interval / 60.
|
||||
# Real-time step: the VFR step (main+0x7ede6c) and the global ratio after the controller call
|
||||
# (main+0x8f2394) read ratio and seconds from the patch page instead of interval * 0.5 and interval / 60.
|
||||
site realtime main 833e4c 1e220020 @page:x9 # scvtf s0, w1 -> adrp x9, page
|
||||
site realtime main 833e50 52a84e08 bd400120 # mov w8, #60.0 -> ldr s0, [x9] (ratio)
|
||||
site realtime main 833e54 1e270101 bd400521 # fmov s1, w8 -> ldr s1, [x9, #4] (seconds)
|
||||
@@ -33,11 +32,11 @@ site realtime main 90e5d4 1e2c1001 bd400120 # fmov s1, #0.5 -> ldr s0, [x9] (gl
|
||||
site realtime main 90e5e4 5e21d800 d503201f # scvtf s0, s0 -> nop
|
||||
site realtime main 90e5e8 1e210800 d503201f # fmul s0, s0, s1 -> nop
|
||||
|
||||
# Hair and cloth (upstream 290ec9f, 8f8022f): the actor animation update builds a second clock {seconds = factor / 30,
|
||||
# Hair and cloth: the actor animation update builds a second clock {seconds = factor / 30,
|
||||
# ratio = factor} per rendered frame. Three inlined places: at the fmul, seconds = measured seconds * factor; at the
|
||||
# store of the factor into the ratio slot, measured ratio * factor. The call of the shared update (1.1.0
|
||||
# main+0x8ecb40, 1.2.1 main+0x89822c) scales s2 (seconds) and s3 (ratio) by the measured ratio. Upstream's
|
||||
# veneer bodies, inlined at the site.
|
||||
# main+0x8ecb40, 1.2.1 main+0x89822c) scales s2 (seconds) and s3 (ratio) by the measured ratio. The
|
||||
# replacement bodies are inlined at the site.
|
||||
site cloth main 9efc20 1e200900 f81f0fe9 @page:x9 bd400520 1e200900 f84107e9 # fmul s0, s8, s0
|
||||
site cloth main 9efc1c bd0117e8 d10083ff f90003e9 3d8007ff @page:x9 bd40013f 1e3f091f bd0137ff 3dc007ff f94003e9 910083ff # str s8, [sp, #0x114]
|
||||
site cloth main 9f0bcc 1e200900 f81f0fe9 @page:x9 bd400520 1e200900 f84107e9 # fmul s0, s8, s0
|
||||
@@ -46,11 +45,11 @@ site cloth main a05a04 1e210801 f81f0fe9 @page:x9 bd400521 1e210801 f84107e9 #
|
||||
site cloth main a05a08 bd0137e0 d10083ff f90003e9 3d8007ff @page:x9 bd40013f 1e3f081f bd0157ff 3dc007ff f94003e9 910083ff # str s0, [sp, #0x134]
|
||||
site cloth main 9f044c 97fbf1bd @page:x8 bd400104 1e240842 1e240863 97fbf1bd # bl 0x8ecb40
|
||||
|
||||
# Trampolines (upstream 27c3b43): the slow-motion check compares time object +0x28 (30 / (ratio * time scale)) with
|
||||
# Trampolines: the slow-motion check compares time object +0x28 (30 / (ratio * time scale)) with
|
||||
# 100; compare +0x28 * +0x38 (30 / time scale) instead, the same value at 30 Hz and independent of the frame rate.
|
||||
site bounce main bee7e0 bd402900 bd402900 bd403901 1e210800 # ldr s0, [x8, #0x28]; ldr s1, [x8, #0x38]; fmul s0, s0, s1
|
||||
|
||||
# Output size (upstream games/<game>/runtime/game_patches.c patch_output_res; runtime/resolution.c switches the set on).
|
||||
# Output size (runtime/resolution.c switches the set on).
|
||||
# The swapchain size nnMain writes before NvInitializeGraphics comes from page +48 ({w, h} as one 64-bit value), and
|
||||
# the output size the renderer lays out its canvas, crop and UI in (main+0xcc3f00, read from the graphics parameters
|
||||
# through main+0xcc4160) from page +32; the renderer itself goes to page +40.
|
||||
@@ -60,7 +59,7 @@ site output main cea5c8 aa1403e0 @page:x21 # mov x0, x20 -> adrp x21, page
|
||||
site output main cea5cc 94000081 f90016b3 # bl 0xcc4160 -> str x19, [x21, #40]
|
||||
site output main cea5d0 f9400015 f94012b5 # ldr x21, [x0] -> ldr x21, [x21, #32]
|
||||
|
||||
# Scene render size (upstream patch_render_res): the renderer's +0xcc4 / +0xcc8, which size every scene render target,
|
||||
# Scene render size: the renderer's +0xcc4 / +0xcc8, which size every scene render target,
|
||||
# take two floats from page +16 instead of the graphics parameters' docked 1600x900.
|
||||
site scene main cea5e0 5e21d900 @page:x9 # scvtf s0, s8 -> adrp x9, page
|
||||
site scene main cea5e8 bd0cc660 2d420520 # str s0, [x19, #0xcc4] -> ldp s0, s1, [x9, #16]
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
# the four screen vtables that keep it, +176 the UI's horizontal squeeze (16:9 over the picture's ratio) in four lanes, +192 the
|
||||
# movie's margin on each side as a share of the width.
|
||||
#
|
||||
# The matrix-update, UI and movie sites and what each does there come from oot-mod by Ivan0xFF
|
||||
# (https://github.com/craftycorvid/oot-mod @ c5ccd1cd57e8219aea3be1e758221795fa5b7ec8, build.py hooks; MIT,
|
||||
# Copyright (c) 2026 Ivan0xFF). Its hooks branch to code caves; here each is rewritten without branches or flags, as
|
||||
# the generator's patch sites need. The set names differ from NX2navi's (output, scene, aspect), whose page layout
|
||||
# runtime/resolution.c owns.
|
||||
# The matrix-update, UI and movie sites: Copyright (c) 2026 Ivan0xFF (MIT; see THIRD_PARTY_NOTICES.md). Each is
|
||||
# written without branches or flags, as the generator's patch sites need. The set names differ from the other patch
|
||||
# files' (output, scene, aspect), whose page layout runtime/resolution.c owns.
|
||||
|
||||
set wide_out NX2NAVI_PATCH_WIDE_OUT 0
|
||||
set wide_scene NX2NAVI_PATCH_WIDE_SCENE 0
|
||||
@@ -31,12 +29,12 @@ site wide_out main 31f39f8 f2c0b408 f9403108 # movk x8, #0x5a0, lsl #32 -> ldr
|
||||
site wide_scene main 31f3a00 d280f008 @page:x8 # mov x8, #0x780 -> adrp x8, page
|
||||
site wide_scene main 31f3a04 f2c08708 f9403508 # movk x8, #0x438, lsl #32 -> ldr x8, [x8, #104]
|
||||
|
||||
# Camera aspect ratio: the camera update (main+0x4c48c0, the same code as NX2navi's camera update site in
|
||||
# Camera aspect ratio: the camera update (main+0x4c48c0, the same code as the camera update site in
|
||||
# recomp/patches-v143.txt) copies the camera's near, far, vertical angle and ratio (camera +0x134..+0x140) into the
|
||||
# sead perspective projection the renderer reads (+0x98..+0xb0; the projection's own matrix update, main+0x3485cc0, does
|
||||
# not run in play: the renderer builds its matrices from these fields). The replacement loads the ratio as before and
|
||||
# puts the page's ratio in its place when it is within the page's tolerance of 16:9 (the camera's value is not the bit
|
||||
# pattern of the 16/9 constant, and the tolerance is oot-mod's 0.01); other ratios stay the camera's. fabd + fcmge + bit
|
||||
# pattern of the 16/9 constant, and the tolerance is 0.01); other ratios stay the camera's. fabd + fcmge + bit
|
||||
# write no flags, so the alternatives agree. s1..s4 and x9 are free there: nothing reads them before the call at
|
||||
# main+0x4c534c.
|
||||
site wide_aspect main 4c5334 bd414260 bd414260 @page:x9 2d4e0921 bd407923 7ea1d404 7e24e464 2ea41c40 # ldr s0, [x19, #0x140]; ldp s1, s2, [x9, #112]; ldr s3, [x9, #120]; fabd s4, s0, s1; fcmge s4, s3, s4; bit v0, v2, v4
|
||||
@@ -55,7 +53,7 @@ site wide_aspect main 33b82c 2d558440 2d558440 @page:x9 2d4e1123 bd407922 7ea3d4
|
||||
# ratio, so the UI keeps its shape in the middle 16:9 of the picture, its edge elements at that area's edges, and the
|
||||
# markers that follow the 3D world stay on their targets. Screens whose canvas (+0x1b8 into the screen object) belongs
|
||||
# to the item-wheel background (vtable main+0x4bed098) or the pause and system menu backgrounds (main+0x4be4fb0) keep
|
||||
# it, as in oot-mod: they redraw a capture of the whole picture. So do the event and loading fades (UIEventFadeScreen
|
||||
# it: they redraw a capture of the whole picture. So do the event and loading fades (UIEventFadeScreen
|
||||
# main+0x4be61c8, UILoadingFadeScreen main+0x4be7b30; the vtables that hold those names at +0x378): a fade is one colour,
|
||||
# and in the middle 16:9 alone it would leave the picture showing at the sides. Without branches: the two projection
|
||||
# words are compared in vector lanes, the screen's vtable is read from the canvas' screen only when they match (else from
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# Code patches for NX2navi 1.2.1 main (recomp/patches.py). Ported from MacNativeGames games/<game>/runtime/game_patches.c
|
||||
# (MIT, Copyright (c) 2026 MacNativeGames contributors) at upstream ebe621d; 1.2.1 sites from its game_version.h
|
||||
# (2db612b), each original word checked against the 1.2.1 main. The patch page holds two floats the runtime writes at
|
||||
# Code patches for NX2navi 1.2.1 main (recomp/patches.py). Copyright (c) 2026 MacNativeGames contributors (MIT; see
|
||||
# THIRD_PARTY_NOTICES.md). Each original word is checked against the 1.2.1 main. The patch page holds two floats the runtime writes at
|
||||
# every present (frame_rate.c): +0 the 30 Hz ratio (seconds * 30), +4 the frame step in seconds.
|
||||
|
||||
set fps60 NX2NAVI_FPS60 1
|
||||
@@ -11,7 +10,7 @@ set output NX2NAVI_PATCH_OUTPUT 0
|
||||
set scene NX2NAVI_PATCH_SCENE 0
|
||||
set shadow NX2NAVI_PATCH_SHADOW 0
|
||||
|
||||
# 60 fps: the adaptive present-interval controller (main+0x8f26c8, 1.0.0 0x8f6bec) gets the minimum interval 1.
|
||||
# 60 fps: the adaptive present-interval controller (main+0x8f26c8) gets the minimum interval 1.
|
||||
site fps60 main 8f273c 6b08015f 7100055f # clamp: cmp w10, #1 (was cmp w10, w8 = minimum)
|
||||
site fps60 main 8f2740 1a89b10a 1a9fa52a # clamp: csinc w10, w9, wzr, ge (desired = max(desired, 1))
|
||||
site fps60 main 8f2764 b9401a8a d503201f # lower trigger: nop the stored-candidate load
|
||||
@@ -20,8 +19,8 @@ site fps60 main 8f2804 1a88c1ac 1a9fc5ac # raise path: csinc w12, w13, wzr, gt
|
||||
site fps60 main 8f2858 b9400288 52800028 # lower path: mov w8, #1 (minimum interval 1)
|
||||
site fps60 main 8f2874 2a0a03f5 1a9fa555 # lower path: csinc w21, w10, wzr, ge (result never below 1)
|
||||
|
||||
# Real-time step: the VFR step (main+0x7ede6c, 1.0.0 0x7a83e4) and the global ratio after the controller call
|
||||
# (main+0x8f2394, 1.0.0 0x8f68b8) read ratio and seconds from the patch page instead of interval * 0.5 and interval / 60.
|
||||
# Real-time step: the VFR step (main+0x7ede6c) and the global ratio after the controller call
|
||||
# (main+0x8f2394) read ratio and seconds from the patch page instead of interval * 0.5 and interval / 60.
|
||||
site realtime main 7ede7c 1e220020 @page:x9 # scvtf s0, w1 -> adrp x9, page
|
||||
site realtime main 7ede80 52a84e08 bd400120 # mov w8, #60.0 -> ldr s0, [x9] (ratio)
|
||||
site realtime main 7ede84 1e270101 bd400521 # fmov s1, w8 -> ldr s1, [x9, #4] (seconds)
|
||||
@@ -33,16 +32,16 @@ site realtime main 8f2398 1e2c1001 bd400120 # fmov s1, #0.5 -> ldr s0, [x9] (g
|
||||
site realtime main 8f23a8 5e21d800 d503201f # scvtf s0, s0 -> nop
|
||||
site realtime main 8f23ac 1e210800 d503201f # fmul s0, s0, s1 -> nop
|
||||
|
||||
# Equipment-switch cooldown (issue #18, found by JieML1100 on 1.4.3): the player update (main+0x852d24) steps the
|
||||
# Equipment-switch cooldown (issue #18): the player update (main+0x852d24) steps the
|
||||
# countdown at player state +0x109c through the timer step (main+0xec98cc) only while it is above FLT_EPSILON, but the
|
||||
# equipment gate (main+0xcae6f8) blocks weapon, shield and bow changes while it is above 0. A measured ratio can leave
|
||||
# a remainder in (0, FLT_EPSILON] that is never stepped again; stepping while above 0 takes it below 0.
|
||||
site realtime main 852d28 1e270101 1e2703e1 # fmov s1, w8 (FLT_EPSILON) -> fmov s1, wzr
|
||||
|
||||
# Hair and cloth (upstream 290ec9f, 8f8022f): the actor animation update builds a second clock {seconds = factor / 30,
|
||||
# Hair and cloth: the actor animation update builds a second clock {seconds = factor / 30,
|
||||
# ratio = factor} per rendered frame. Three inlined places: at the fmul, seconds = measured seconds * factor; at the
|
||||
# store of the factor into the ratio slot, measured ratio * factor. The call of the shared update (main+0x89822c)
|
||||
# scales s2 (seconds) and s3 (ratio) by the measured ratio. Upstream's veneer bodies, inlined at the site.
|
||||
# scales s2 (seconds) and s3 (ratio) by the measured ratio. The replacement bodies are inlined at the site.
|
||||
site cloth main 82192c 1e200900 f81f0fe9 @page:x9 bd400520 1e200900 f84107e9 # fmul s0, s8, s0
|
||||
site cloth main 821928 bd0127e8 d10083ff f90003e9 3d8007ff @page:x9 bd40013f 1e3f091f bd0147ff 3dc007ff f94003e9 910083ff # str s8, [sp, #0x124]
|
||||
site cloth main 822a64 1e200900 f81f0fe9 @page:x9 bd400520 1e200900 f84107e9 # fmul s0, s8, s0
|
||||
@@ -51,21 +50,21 @@ site cloth main 83182c 1e210801 f81f0fe9 @page:x9 bd400521 1e210801 f84107e9 #
|
||||
site cloth main 831830 bd0137e0 d10083ff f90003e9 3d8007ff @page:x9 bd40013f 1e3f081f bd0157ff 3dc007ff f94003e9 910083ff # str s0, [sp, #0x134]
|
||||
site cloth main 8222f0 9401d7cf @page:x8 bd400104 1e240842 1e240863 9401d7cf # bl 0x89822c
|
||||
|
||||
# Trampolines (upstream 27c3b43): the slow-motion check compares time object +0x28 (30 / (ratio * time scale)) with
|
||||
# Trampolines: the slow-motion check compares time object +0x28 (30 / (ratio * time scale)) with
|
||||
# 100; compare +0x28 * +0x38 (30 / time scale) instead, the same value at 30 Hz and independent of the frame rate.
|
||||
site bounce main bda798 bd402900 bd402900 bd403901 1e210800 # ldr s0, [x8, #0x28]; ldr s1, [x8, #0x38]; fmul s0, s0, s1
|
||||
|
||||
# Cursor and aim steps (upstream game_patches.c patch_cursor_speed, 363a6eb). These updates read the game's 30 Hz frame
|
||||
# ratio for their smoothing but leave it out of the step itself, so the map cursor and the vertical object aim moved
|
||||
# Cursor and aim steps. These updates read the game's 30 Hz frame
|
||||
# ratio for their smoothing but leave it out of the step itself, so the map cursor and the vertical aim moved
|
||||
# 2x as fast at 60 fps and 4x at 120 as at the shipping 30 fps (issue #44). Each site multiplies the step by that ratio,
|
||||
# so the speed is the shipping one at any frame rate. x9 and s16 are free: the next read of x9 follows a write, the
|
||||
# function does not touch s16, and x20 keeps the update's frame object for the whole function.
|
||||
set cursor NX2NAVI_HIGHFPS_FIX 1
|
||||
site cursor main ec3d9c bd400361 f94002e9 bd400930 1e300800 bd400361 # map pan speed s0 *= [[x23] + 8], then ldr s1, [x27]
|
||||
site cursor main 1d48d64 1e2a198c 1e2a198c bd400a90 1e30098c # fdiv s12, s12, s10, then s12 *= [x20 + 8]: vertical object aim
|
||||
site cursor main 1d484e4 1e200923 1e200923 bd400a90 1e300863 # fmul s3, s9, s0, then s3 *= [x20 + 8]: vertical gyro aim (Recall)
|
||||
site cursor main 1d48d64 1e2a198c 1e2a198c bd400a90 1e30098c # fdiv s12, s12, s10, then s12 *= [x20 + 8]: vertical aim
|
||||
site cursor main 1d484e4 1e200923 1e200923 bd400a90 1e300863 # fmul s3, s9, s0, then s3 *= [x20 + 8]: vertical gyro aim
|
||||
|
||||
# Output size (upstream games/<game>/runtime/game_patches.c patch_output_res; runtime/resolution.c switches the set on).
|
||||
# Output size (runtime/resolution.c switches the set on).
|
||||
# The swapchain size nnMain writes before NvInitializeGraphics comes from page +48 ({w, h} as one 64-bit value), and
|
||||
# the output size the renderer lays out its canvas, crop and UI in (main+0xcc3f00, read from the graphics parameters
|
||||
# through main+0xcc4160) from page +32; the renderer itself goes to page +40.
|
||||
@@ -75,14 +74,14 @@ site output main cc3f50 aa1403e0 @page:x21 # mov x0, x20 -> adrp x21, page
|
||||
site output main cc3f54 94000083 f90016b3 # bl 0xcc4160 -> str x19, [x21, #40]
|
||||
site output main cc3f58 f9400015 f94012b5 # ldr x21, [x0] -> ldr x21, [x21, #32]
|
||||
|
||||
# Scene render size (upstream patch_render_res): the renderer's +0xcc4 / +0xcc8, which size every scene render target,
|
||||
# Scene render size: the renderer's +0xcc4 / +0xcc8, which size every scene render target,
|
||||
# take two floats from page +16 instead of the graphics parameters' docked 1600x900.
|
||||
site scene main cc3f68 5e21d900 @page:x9 # scvtf s0, s8 -> adrp x9, page
|
||||
site scene main cc3f70 bd0cc660 2d420520 # str s0, [x19, #0xcc4] -> ldp s0, s1, [x9, #16]
|
||||
site scene main cc3f74 5e21d921 bd0cc660 # scvtf s1, s9 -> str s0, [x19, #0xcc4]
|
||||
|
||||
# Camera aspect ratio for a game resolution that is not 16:9 (upstream game_patches.c, the 1.2.1 sites of aspect_install;
|
||||
# runtime/resolution.c res_init writes the output's width / height to page +56 and switches the set on). The same four
|
||||
# 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). The same four
|
||||
# sites as patches-v143.txt, with the same original words: 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 (Hor+). x10 is kept on the stack, so no register liveness is assumed.
|
||||
@@ -92,11 +91,11 @@ site aspect main 12521cc bd414260 f81f0fea @page:x10 bd403940 f84107ea # ldr s0
|
||||
site aspect main 19b36f0 1e211800 f81f0fea @page:x10 bd403940 f84107ea # fdiv s0, s0, s1 (viewport)
|
||||
site aspect main 1ecdf68 1e211800 f81f0fea @page:x10 bd403940 f84107ea # fdiv s0, s0, s1 (viewport)
|
||||
|
||||
# Texture pool offsets past 2 GiB (MacNativeGames ca311e2d). The texture loader keeps a texture's place in its pool as a
|
||||
# Texture pool offsets past 2 GiB. The texture loader keeps a texture's place in its pool as a
|
||||
# 32-bit offset (main+0xad4294: sub x25, x9, x10, stored as the word w25) and widens it as a signed number for
|
||||
# nvnTextureBuilderSetStorage's offset and for SetPackagedTextureData's source (the pool's CPU address + offset). The
|
||||
# shipped heap table keeps every pool far below 2 GiB; a texture pack's heap table with NX2NAVI_APP_POOL raised can make
|
||||
# one larger (MacNativeGames saw a 3.58 GiB pool), and every texture past 2 GiB then got storage 4 GiB below its pool.
|
||||
# one larger (a 3.58 GiB pool has been seen), and every texture past 2 GiB then got storage 4 GiB below its pool.
|
||||
# The offset is widened unsigned instead, the same value below 2 GiB, right up to 4 GiB. 1.4.3 needs no patch: its
|
||||
# loaders (main+0x583c34, main+0x27ed214) keep the offset in 64 bits.
|
||||
set pooloff NX2NAVI_POOL_OFFSET_PATCH 1
|
||||
@@ -975,6 +974,5 @@ spin sdk 3d3250 3d3270 # 9 instructions; loads
|
||||
# cover is, rounded up to 8 at main+0xcec22c and stored as the width (+0x3d8 of the cascade set) and, through the packed
|
||||
# store at +0xe4, the height (+0x3f8). Near the ground it falls to about 400, which draws foliage shadows blocky, and
|
||||
# every change of size moves the shadow texels, so leaf shadows jump instead of sliding. The page's fixed size (+92)
|
||||
# goes in just before the rounding, as the community's shadow resolution mods do (1.1.0: mov w11, #1024 over the
|
||||
# computation). Found by a write watch on the size field (the writer was this function, and no other).
|
||||
# goes in just before the rounding. Found by a write watch on the size field (the writer was this function, and no other).
|
||||
site shadow main cec22c 11001d6b @page:x11 b9405d6b 11001d6b # add w11, w11, #7 -> adrp x11, page; ldr w11, [x11, #92]; add w11, w11, #7
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Adapted from LAS Recomp tools/simd_c.py @ da35b83 (MIT, Copyright (c) 2026 Peiikai).
|
||||
# Copyright (c) 2026 Peiikai (MIT; see THIRD_PARTY_NOTICES.md).
|
||||
"""Portable C lowering of AArch64 FP / AdvSIMD / crypto / CRC32 instructions (lifter --simd=c).
|
||||
|
||||
Every encoding is decoded here at lift time and turned into C over the Cpu struct, calling the static
|
||||
|
||||
Reference in New Issue
Block a user