Move the aspect words of the patch page to +80..+91 and list the words in use, so other patch sets can take +56..+79.

The shadow cascade range of a pending change loads its four distances from +64..+79 on 1.4.3, where the aspect and the
canvas factors were; with both on, the camera would have read a cascade distance as its aspect. recomp/patches.py now
lists the words each set uses.
This commit is contained in:
Wellington Dias committed 2026-10-30 14:35:23 -03:00
1 parent 89b5126da0
commit 08df794360
4 files changed
+21 -18

No files matched your search

+10 -10
View File
@@ -933,25 +933,25 @@ spin sdk 23a7fc 23a918 # 19 instructions; loads
spin sdk 3d3250 3d3270 # 9 instructions; loads
# Aspect ratio (runtime/resolution.c aspect_init switches the set on when the game resolution is not 16:9; the sites are those of
# Fruithapje21's TOTK-Ultrawide 1.2.1 patch, GPL-3.0, read for behaviour, the code here our own). The page holds +64 the
# aspect (output width / height), +68 and +72 the factors the 2D canvas size is multiplied by in x and y: wider than
# Fruithapje21's TOTK-Ultrawide 1.2.1 patch, GPL-3.0, read for behaviour, the code here our own). The page holds +80 the
# aspect (output width / height), +84 and +88 the factors the 2D canvas size is multiplied by in x and y: wider than
# 16:9, x by aspect / (16/9); narrower (the Steam Deck's 16:10), y by (16/9) / aspect; the other is 1.
# - The world camera reads its aspect from the camera parameter DefaultAspect (main+0x1164a7c reads DefaultFovy,
# DefaultAspect, DefaultOffsetX...), whose default is the float at main+0x3816ab4: the reader takes the page's instead.
site aspect main 1164aa8 d0013588 @page:x8 # adrp x8, 0x3816000 -> adrp x8, page
site aspect main 1164aac 912ad108 91010108 # add x8, x8, #0xab4 -> add x8, x8, #64
site aspect main 1164aac 912ad108 91014108 # add x8, x8, #0xab4 -> add x8, x8, #80
# - Two copies of a camera-viewport update compute aspect = (right - left) / (bottom - top) of a 16:9 rectangle;
# x9 is set to 1 again after the load, so it holds the page meanwhile.
site aspect main 19b36e0 1e223800 @page:x9 # fsub s0, s0, s2 -> adrp x9, page
site aspect main 19b36e8 52800029 bd404120 # mov w9, #1 -> ldr s0, [x9, #64]
site aspect main 19b36e8 52800029 bd405120 # mov w9, #1 -> ldr s0, [x9, #80]
site aspect main 19b36f0 1e211800 52800029 # fdiv s0, s0, s1 -> mov w9, #1
site aspect main 1ecdf58 1e223800 @page:x9
site aspect main 1ecdf60 52800029 bd404120
site aspect main 1ecdf60 52800029 bd405120
site aspect main 1ecdf68 1e211800 52800029
# - The size of the 2D canvas the layouts are drawn in, loaded as {width, height} at five places: each load is kept
# and followed by the multiplication, with x9 and s2 saved on the stack around it.
site aspect main 1add300 2d4307a0 2d4307a0 f81f0fe9 bd000be2 @page:x9 bd404522 1e220800 bd404922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x29, #0x18]
site aspect main 1ae1ae4 2d440680 2d440680 f81f0fe9 bd000be2 @page:x9 bd404522 1e220800 bd404922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x20, #0x20]
site aspect main 1adc6f8 2d4103e1 2d4103e1 f81f0fe9 bd000be2 @page:x9 bd404522 1e220821 bd404922 1e220800 bd400be2 f84107e9 # ldp s1, s0, [sp, #8] (width in s1)
site aspect main 12c7bd4 2d400500 2d400500 f81f0fe9 bd000be2 @page:x9 bd404522 1e220800 bd404922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x8]
site aspect main 12c7fbc 2d400500 2d400500 f81f0fe9 bd000be2 @page:x9 bd404522 1e220800 bd404922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x8]
site aspect main 1add300 2d4307a0 2d4307a0 f81f0fe9 bd000be2 @page:x9 bd405522 1e220800 bd405922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x29, #0x18]
site aspect main 1ae1ae4 2d440680 2d440680 f81f0fe9 bd000be2 @page:x9 bd405522 1e220800 bd405922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x20, #0x20]
site aspect main 1adc6f8 2d4103e1 2d4103e1 f81f0fe9 bd000be2 @page:x9 bd405522 1e220821 bd405922 1e220800 bd400be2 f84107e9 # ldp s1, s0, [sp, #8] (width in s1)
site aspect main 12c7bd4 2d400500 2d400500 f81f0fe9 bd000be2 @page:x9 bd405522 1e220800 bd405922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x8]
site aspect main 12c7fbc 2d400500 2d400500 f81f0fe9 bd000be2 @page:x9 bd405522 1e220800 bd405922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x8]
+5 -5
View File
@@ -943,10 +943,10 @@ spin sdk 541e54 541f98 # 32 instructions; loads
# switched off 1.2.1 draws the gameplay HUD and the system menu the same at 21:9, so what they adjust is not known yet.
# - DefaultAspect's default (main+0x2d06910, 16/9): the camera parameter reader takes the page's.
site aspect main 1aa0ac4 d0009328 @page:x8 # adrp x8, 0x2d06000 -> adrp x8, page
site aspect main 1aa0ac8 91244108 91010108 # add x8, x8, #0x910 -> add x8, x8, #64
site aspect main 1aa0ac8 91244108 91014108 # add x8, x8, #0x910 -> add x8, x8, #80
# - The two camera-viewport updates: the division becomes a load of the page's aspect (x9 is set again just after).
site aspect main 1ff04f4 1e211800 @page:x9 bd404120 # fdiv s0, s0, s1 -> adrp x9, page; ldr s0, [x9, #64]
site aspect main 253fbb0 1e211800 @page:x9 bd404120 # fdiv s0, s0, s1
site aspect main 1ff04f4 1e211800 @page:x9 bd405120 # fdiv s0, s0, s1 -> adrp x9, page; ldr s0, [x9, #80]
site aspect main 253fbb0 1e211800 @page:x9 bd405120 # fdiv s0, s0, s1
# - Loads of the 2D canvas size {width, height}, each followed by the multiplication (x9 and s2 saved around it).
site aspect main 2136fa8 2d4307a0 2d4307a0 f81f0fe9 bd000be2 @page:x9 bd404522 1e220800 bd404922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x29, #0x18]
site aspect main 213641c 2d4103e1 2d4103e1 f81f0fe9 bd000be2 @page:x9 bd404522 1e220821 bd404922 1e220800 bd400be2 f84107e9 # ldp s1, s0, [sp, #8] (width in s1)
site aspect main 2136fa8 2d4307a0 2d4307a0 f81f0fe9 bd000be2 @page:x9 bd405522 1e220800 bd405922 1e220821 bd400be2 f84107e9 # ldp s0, s1, [x29, #0x18]
site aspect main 213641c 2d4103e1 2d4103e1 f81f0fe9 bd000be2 @page:x9 bd405522 1e220821 bd405922 1e220800 bd400be2 f84107e9 # ldp s1, s0, [sp, #8] (width in s1)
+4 -1
View File
@@ -11,7 +11,10 @@ Lifted code cannot be byte-patched when the game runs, so a patch is applied whe
<address> is a module offset (hex), <original> the instruction word the module has there (checked; a mismatch stops
the generator), each <replacement> an instruction word (hex) or `@page:x<n>`, which is `adrp x<n>, <patch page>`
encoded for the site's address. The patch page is the first 4 KiB page after main's image (layout.py leaves the rest
of the 2 MiB-aligned module slot free); the runtime commits it and owns its contents.
of the 2 MiB-aligned module slot free); the runtime commits it and owns its contents. Words in use, by byte offset:
+0..15 the frame-rate step (runtime/frame_rate.c), +16..55 the output, swapchain and scene sizes
(runtime/resolution.c res_init), +80..91 the aspect and the canvas factors (runtime/resolution.c aspect_init). A new
set takes words outside these.
The replacement words are lifted at the site's address in place of the original instruction, and the generated C reads
`if (rt_patch_on[<set>]) { replacement } else { original }`: one byte load and a branch per executed site. Replacement
+2 -2
View File
@@ -201,14 +201,14 @@ int res_heapdef_build(const void *in, size_t n, void **out, size_t *out_n) {
void res_heapdef_served(void) { R.heapdef_ok = 1; }
// ---- aspect ratio: an output of another shape than 16:9 gets a camera and a 2D canvas of its shape (the aspect set,
// recomp/patches-v121.txt). Page +64 the aspect, +68 and +72 the factors of the canvas width and height: wider than 16:9
// recomp/patches-v121.txt). Page +80 the aspect, +84 and +88 the factors of the canvas width and height: wider than 16:9
// the canvas grows in x, narrower in y, so the 16:9 layouts keep their proportions and sit in the middle of it.
static void aspect_init(uint8_t *page) {
int set = rt_patch_set("aspect"); // decide() kept a version without it at 16:9
double a = (double)R.ow / R.oh, base = (double)BASE_W / BASE_H;
if (fabs(a - base) < ASPECT_EPS || set < 0) return;
float v[3] = {(float)a, (float)(a > base ? a / base : 1.0), (float)(a < base ? base / a : 1.0)};
memcpy(page + 64, v, sizeof v);
memcpy(page + 80, v, sizeof v);
rt_patch_switch(set, 1);
rt_log("resolution: aspect %.4f (%ux%u): camera and interface canvas follow it (x %.4f, y %.4f)", a, R.ow, R.oh, v[1],
v[2]);