From 01e35e4850ca29251379e4491391314f3f949391 Mon Sep 17 00:00:00 2001 From: Walking Sim Game <176498006+Remorc-e@users.noreply.github.com> Date: Fri, 27 Nov 2026 19:32:37 -0500 Subject: [PATCH 1/2] 1440p output: scale the UI like Series S does (menus and HUD 1.5x too large) With the 1440p output, menus and the HUD were drawn 1.5 times too large and overlapped (Settings > Control Scheme, the tab row, footer prompts; issues #98, #301). The title lays its UI out on the 3840x2160 size its menus are authored for and scales it onto a smaller surface only when its legacy UI flag (0xA9438F4) is set. Its console preset sets the flag on Series S, whose menus are right at 1080p, and leaves it 0 on Series X, whose output is always 3840x2160. With the 1440p patch the Series X UI was laid out on a 2560x1440 stage while its content stayed 4K-sized. native_1440p.rs, each field checked against the stock bytes first: - 0x1E0FB69: the preset's legacy UI byte loads as 1 (mov al, 1). - 0x26192F9: the settings update stores 1 in the flag. - 0x247AD4A, the UI memory pool (named the scanout reservation before; it is the Series X value beside the Series S one, 0x5200000): 0x5E00000, two 3840x2160 legacy UI surfaces and two 2560x1440 targets rounded to 2 MiB, within the title's leftover check at 0x247AF25. The previous size had no room for the legacy surfaces (the title's allocator asserted). - The stock bytes of the two new places are kept as BLAKE3 hashes and checked with same(), as the others are since 64d4931. - 0x58048D4, the Settings viewport load, is left stock: with the flag set the legacy size it loads is the right one. Tested on an RTX 4070 Ti, 1440p output with DLSS and frame generation: Settings > Control Scheme laid out as at 4K, no crash over three minutes, about 32 fps in the menus as before. The retail-image tests pass (VICTORY_DISPLAY_PROFILE_TEST_IMAGE set). Co-Authored-By: Gemini Co-Authored-By: Claude Opus 5.5 --- apps/victory/src/native_1440p.rs | 111 ++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 38 deletions(-) diff --git a/apps/victory/src/native_1440p.rs b/apps/victory/src/native_1440p.rs index 1fa28e292..710ae27a2 100644 --- a/apps/victory/src/native_1440p.rs +++ b/apps/victory/src/native_1440p.rs @@ -2,10 +2,17 @@ //! 1.0.2.1): the title presents at 3840x2160 on Series X, its scene drawn at //! 2560x1440 and scaled up by its own temporal pass. With 1440p asked for //! (`VICTORY_NATIVE_1440P=1`, or `VICTORY_RENDER_1080P=1` for a 1920x1080 -//! scene scaled to 1440p), the image's SDR display mode, the scanout -//! reservation, the temporal scene scale and the Settings viewport load are -//! patched before it is mapped: the title then makes a 1440p output, and no -//! 4K pass runs. +//! scene scaled to 1440p), the image's SDR display mode, the UI memory pool, +//! the legacy UI flag and the temporal scene scale are patched before it is +//! mapped: the title then makes a 1440p output, lays its UI out on the +//! 3840x2160 size its menus are authored for and scales it onto the 2560x1440 +//! targets (as Series S does at 1080p), and no 4K pass runs. +//! +//! The legacy UI flag (`0xA9438F4`, byte) is what scales the UI: the title +//! sets it from its console preset, 1 on Series S, 0 on Series X, where the +//! output is always 3840x2160 and nothing needs scaling. Left at 0 with the +//! 1440p output, menus and the HUD were laid out on a 2560x1440 stage with +//! their 4K-sized content, 1.5 times too large and overlapping. //! //! Ported from DexNom's fork (DexNom/VIctory, `apps/victory/src/native_1440p.rs`, //! GPL-3.0-or-later), its native 1440p part only. Every field is checked @@ -28,9 +35,36 @@ pub(super) const WIDTH: u32 = 2560; pub(super) const HEIGHT: u32 = 1440; const SDR_MODE: u32 = 0x0615_c100; const STOCK_SDR_MODE: &str = "abfb5438d8153b6a0b8d08f33f4f0066e5383925b55aacc5f669131f3f51d4cf"; -const SCANOUT_RESERVATION: u32 = 0x0247_ad4a; +const LEGACY_UI_WIDTH: u32 = 3840; +const LEGACY_UI_HEIGHT: u32 = 2160; +/// The UI memory pool's size in the UI setup at `0x247AD10`: `mov ecx, +/// 0x4000000`, the Series X value (Series S: `0x5200000`, picked by +/// `cmovne` on the title's Series S check). +const UI_POOL: u32 = 0x0247_ad4a; const TEMPORAL_SCALE: u32 = 0x028f_1e7e; -const UI_VIEWPORT_LOAD: u32 = 0x0580_48d4; +/// The legacy UI flag from the console preset: `mov al, [rdi+0x1e8]`, then +/// stored to the flag (`mov [rsi+0x13c], al`). +const LEGACY_UI_PRESET: u32 = 0x01e0_fb69; +const STOCK_LEGACY_UI_PRESET: &str = "79b808935d64ed64f88414b9bb8f696c996005b2ce05e5a81ac93b3c6218f739"; +/// The settings update storing the flag again: `mov [rsi+0x13c], r8b`. +const LEGACY_UI_FLAG_STORE: u32 = 0x0261_92f9; +const STOCK_LEGACY_UI_FLAG_STORE: &str = "edaab24aa453924381dd65cfc5724a1e254c071d1894f738ddb20dd6f7d8e809"; + +/// Bytes of one 64 KiB-aligned, 64 KiB-tiled RGBA8 UI surface. +fn ui_surface_bytes(width: u32, height: u32) -> Result { + let texture = Texture::new(&TextureDesc { + dimension: Dimension::Tex2d, + width, + height, + depth_or_array: 1, + mips: 1, + format: 28, + samples: 1, + swizzle: Swizzle::SW_64KB_D_X, + }) + .map_err(|error| anyhow::anyhow!("UI surface layout ({width}x{height}): {error:?}"))?; + Ok(texture.size.next_multiple_of(64 * 1024)) +} /// Patches `image` for a 2560x1440 output; the scene is drawn at 2560x1440, /// or at 1920x1080 with `render_1080p`. Returns the scene's size. @@ -45,40 +79,36 @@ pub(super) fn prepare(image: &mut PreparedImage, render_1080p: bool) -> Result<( mode[..4].copy_from_slice(&WIDTH.to_le_bytes()); mode[4..8].copy_from_slice(&HEIGHT.to_le_bytes()); - // Two 64 KiB-aligned, tiled RGBA8 scanout buffers. The reservation is - // rounded to 2 MiB, matching the title's allocation check. - let texture = Texture::new(&TextureDesc { - dimension: Dimension::Tex2d, - width: WIDTH, - height: HEIGHT, - depth_or_array: 1, - mips: 1, - format: 28, - samples: 1, - swizzle: Swizzle::SW_64KB_D_X, - }) - .map_err(|error| anyhow::anyhow!("1440p scanout layout: {error:?}"))?; - let pool_size = - u32::try_from((texture.size.next_multiple_of(64 * 1024) * 2).next_multiple_of(2 << 20))?; - let reservation = field::<5>(image, SCANOUT_RESERVATION)?; - ensure!(*reservation == [0xb9, 0, 0, 0, 4], "unexpected Series X scanout reservation"); - reservation[1..].copy_from_slice(&pool_size.to_le_bytes()); + // With the legacy UI flag set, the UI setup makes two 3840x2160 legacy + // UI surfaces and two 2560x1440 UI targets in one pool, and asserts that + // no more than 0x1FFFFF of it is left over (`0x247AF25`). Rounded to + // 2 MiB: 0x5E00000 (94 MiB). The stock Series X 64 MiB had no room for + // the legacy surfaces (the title's allocator asserted, `int3` at + // `0x56A2AFD`). + let pool_size = u32::try_from( + (ui_surface_bytes(LEGACY_UI_WIDTH, LEGACY_UI_HEIGHT)? * 2 + ui_surface_bytes(WIDTH, HEIGHT)? * 2) + .next_multiple_of(2 << 20), + )?; + let pool = field::<5>(image, UI_POOL)?; + ensure!(*pool == [0xb9, 0, 0, 0, 4], "unexpected Series X UI pool size"); + pool[1..].copy_from_slice(&pool_size.to_le_bytes()); + + // The legacy UI flag set on Series X too: the preset's byte loads as 1 + // (`mov al, 1`), and the settings update stores 1 (`mov byte [rsi+0x13c], + // 1`). The rest of the preset stays Series X. + let preset = field::<6>(image, LEGACY_UI_PRESET)?; + ensure!(same(&preset[..], STOCK_LEGACY_UI_PRESET), "unexpected legacy UI preset load"); + *preset = [0xb0, 0x01, 0x90, 0x90, 0x90, 0x90]; + let store = field::<7>(image, LEGACY_UI_FLAG_STORE)?; + ensure!(same(&store[..], STOCK_LEGACY_UI_FLAG_STORE), "unexpected legacy UI flag store"); + *store = [0xc6, 0x86, 0x3c, 0x01, 0x00, 0x00, 0x01]; let scale = field::<4>(image, TEMPORAL_SCALE)?; ensure!(*scale == (2.0f32 / 3.0).to_le_bytes(), "unexpected Series X temporal scene scale"); let (render_width, render_height) = if render_1080p { (1920, 1080) } else { (WIDTH, HEIGHT) }; *scale = (render_width as f32 / WIDTH as f32).to_le_bytes(); - - // Settings lays out its preview panels with a viewport setter of its - // own that loads the legacy UI size (3840x2160) even when a 1440p UI - // surface was made: it reads the selected SDR mode instead. - let viewport = field::<8>(image, UI_VIEWPORT_LOAD)?; - ensure!( - *viewport == [0xc5, 0xfb, 0x10, 0x0d, 0x10, 0xf0, 0x13, 0x05], - "unexpected Settings viewport size load" - ); - let displacement = (SDR_MODE as i32) - (UI_VIEWPORT_LOAD as i32 + 8); - viewport[4..].copy_from_slice(&displacement.to_le_bytes()); + // The Settings preview panels' viewport (`0x58048D4`) loads the legacy + // UI size, which is right with the legacy flag set: left stock. Ok((render_width, render_height)) } @@ -176,9 +206,14 @@ mod tests { assert_eq!(mode[4..8], HEIGHT.to_le_bytes()); let scale = f32::from_le_bytes(*field::<4>(&mut image, TEMPORAL_SCALE).unwrap()); assert_eq!((WIDTH as f32 * scale) as u32, scene.0); - let load = *field::<8>(&mut image, UI_VIEWPORT_LOAD).unwrap(); - let disp = i32::from_le_bytes(load[4..].try_into().unwrap()); - assert_eq!(UI_VIEWPORT_LOAD.wrapping_add(8).wrapping_add_signed(disp), SDR_MODE); + // The UI pool holds two legacy surfaces and two 1440p targets. + assert_eq!(*field::<5>(&mut image, UI_POOL).unwrap(), [0xb9, 0x00, 0x00, 0xe0, 0x05]); + // The legacy UI flag is set from the preset and by the update. + assert_eq!(*field::<6>(&mut image, LEGACY_UI_PRESET).unwrap(), [0xb0, 0x01, 0x90, 0x90, 0x90, 0x90]); + assert_eq!( + *field::<7>(&mut image, LEGACY_UI_FLAG_STORE).unwrap(), + [0xc6, 0x86, 0x3c, 0x01, 0x00, 0x00, 0x01] + ); // Patched once, the image is no longer the stock one: refused. assert!(prepare(&mut image, render_1080p).is_err()); } From 0c0d466238f5187537fa5743e8c91464eb1d0b9f Mon Sep 17 00:00:00 2001 From: Walking Sim Game <176498006+Remorc-e@users.noreply.github.com> Date: Sat, 28 Nov 2026 01:16:27 -0500 Subject: [PATCH 2/2] 1440p output: Series S's output settings in the title's own settings (map icons 1.5x out) The pause map's icons sat 1.5 times too far from the map's top left corner. Its targets are sized from the title's UI layout size, which the settings give through 0x7B4E10: the legacy UI size when the settings' legacy UI flag is on, the output size when it is off. The flag was set only where it is read (0x1E0FB69, 0x26192F9), so the settings still had it off. The map was then drawn at 2560x1440 while its icons were placed for 3840x2160. Series S's preset sets three video settings: legacy UI flag 1, legacy UI size 3840x2160, output 1920x1080. Series X's has the flag at 0 and no legacy size. Those three are now written into the title's settings, with a 2560x1440 output. The place is the settings collection's copy (0x1D70750), which every settings store goes through: its last store of the video block (0x1D70B98, 11 bytes, checked by BLAKE3) jumps to our code in int3 padding (0x55FF285). That code does the same store, writes the three settings and jumps back. The SDR mode stays at stock 3840x2160 and the reported display at the 3840x2160 default, as on Series S. The SDR mode patch, the VICTORY_DISPLAY_MODE override and the two flag patches are gone. The UI pool and the temporal scene scale stay. Tested on an RTX 4070 Ti at 1440p with DLSS Performance: - the map's icons, menus and HUD line up; - 0xA9438CC/D0 = 2560x1440, 0xA9438EC/F0 = 3840x2160, flag 1, screen size 3840x2160, no assertions. cargo test -p victory with the retail image: 23 + 2 passed. xtask policy ok. No clippy warnings in the changed files. Co-Authored-By: Claude Opus 5.5 --- apps/victory/src/native_1440p.rs | 121 +++++++++++++++++++++---------- apps/victory/src/run.rs | 7 +- 2 files changed, 86 insertions(+), 42 deletions(-) diff --git a/apps/victory/src/native_1440p.rs b/apps/victory/src/native_1440p.rs index 710ae27a2..91f5537fa 100644 --- a/apps/victory/src/native_1440p.rs +++ b/apps/victory/src/native_1440p.rs @@ -2,17 +2,20 @@ //! 1.0.2.1): the title presents at 3840x2160 on Series X, its scene drawn at //! 2560x1440 and scaled up by its own temporal pass. With 1440p asked for //! (`VICTORY_NATIVE_1440P=1`, or `VICTORY_RENDER_1080P=1` for a 1920x1080 -//! scene scaled to 1440p), the image's SDR display mode, the UI memory pool, -//! the legacy UI flag and the temporal scene scale are patched before it is -//! mapped: the title then makes a 1440p output, lays its UI out on the -//! 3840x2160 size its menus are authored for and scales it onto the 2560x1440 -//! targets (as Series S does at 1080p), and no 4K pass runs. +//! scene scaled to 1440p), the title's own settings get what Series S's +//! preset gives them, with a 2560x1440 output, and the UI memory pool and the +//! temporal scene scale are patched before the image is mapped. The SDR +//! display mode stays at stock 3840x2160, as Series S keeps it. The title then +//! makes a 1440p output, lays its UI and pause map out on the 3840x2160 size +//! they are authored for, scales them onto the 2560x1440 targets, and runs no +//! 4K pass. //! -//! The legacy UI flag (`0xA9438F4`, byte) is what scales the UI: the title -//! sets it from its console preset, 1 on Series S, 0 on Series X, where the -//! output is always 3840x2160 and nothing needs scaling. Left at 0 with the -//! 1440p output, menus and the HUD were laid out on a 2560x1440 stage with -//! their 4K-sized content, 1.5 times too large and overlapping. +//! Series S's preset sets three video settings: the legacy UI flag (1), the +//! legacy UI size (3840x2160) and the output size (1920x1080). Every reader +//! (the UI layout, the title's screen size `0x92D7924`, the pause map's +//! target size) takes what it needs from them. Series X's preset has the flag +//! at 0 and no legacy size, so with a 1440p output its menus and HUD were laid +//! out on a 2560x1440 stage with their 4K-sized content, 1.5 times too large. //! //! Ported from DexNom's fork (DexNom/VIctory, `apps/victory/src/native_1440p.rs`, //! GPL-3.0-or-later), its native 1440p part only. Every field is checked @@ -42,13 +45,51 @@ const LEGACY_UI_HEIGHT: u32 = 2160; /// `cmovne` on the title's Series S check). const UI_POOL: u32 = 0x0247_ad4a; const TEMPORAL_SCALE: u32 = 0x028f_1e7e; -/// The legacy UI flag from the console preset: `mov al, [rdi+0x1e8]`, then -/// stored to the flag (`mov [rsi+0x13c], al`). -const LEGACY_UI_PRESET: u32 = 0x01e0_fb69; -const STOCK_LEGACY_UI_PRESET: &str = "79b808935d64ed64f88414b9bb8f696c996005b2ce05e5a81ac93b3c6218f739"; -/// The settings update storing the flag again: `mov [rsi+0x13c], r8b`. -const LEGACY_UI_FLAG_STORE: u32 = 0x0261_92f9; -const STOCK_LEGACY_UI_FLAG_STORE: &str = "edaab24aa453924381dd65cfc5724a1e254c071d1894f738ddb20dd6f7d8e809"; +/// The settings collection's copy (`0x1D70750`), which every settings store +/// goes through (the init's apply, the runtime updates, the backups): its +/// last store of the video block and the `vzeroupper` after it (11 bytes). +/// The video settings start at collection `+0x450`, so the legacy UI flag is +/// at `+0x638` (settings `+0x1E8`, byte), the legacy UI size at +/// `+0x63C/+0x640` (`+0x1EC/+0x1F0`) and the output size at `+0x654/+0x658` +/// (`+0x204/+0x208`). +const SETTINGS_COPY: u32 = 0x01d7_0b98; +const STOCK_SETTINGS_COPY: &str = "9d8829e6720f7624fd7004b8905ccfd6e1d9c6610ec186100f8350e091344038"; +const SETTINGS_COPY_LEN: usize = 11; +/// Padding (`int3`, 60 bytes from `0x55FF284`) between two functions, inside +/// the mapped code. +const SETTINGS_CAVE: u32 = 0x055f_f285; +const SETTINGS_CAVE_LEN: usize = 59; + +/// Our code for the cave: the copy's store (as `vmovdqu`, the same store), +/// then the three settings as Series S has them, with a 2560x1440 output, and +/// the jump back after the patched site. +fn settings_cave_bytes() -> Result> { + let pair = |w: u32, h: u32| (u64::from(h) << 32 | u64::from(w)).to_le_bytes(); + let mut cave = Vec::with_capacity(SETTINGS_CAVE_LEN); + cave.extend_from_slice(&[0xc5, 0xfe, 0x7f, 0x86, 0x38, 0x06, 0, 0]); // vmovdqu [rsi+0x638], ymm0 + cave.extend_from_slice(&[0xc6, 0x86, 0x38, 0x06, 0, 0, 0x01]); // mov byte [rsi+0x638], 1 + cave.extend_from_slice(&[0x48, 0xb8]); // mov rax, legacy size + cave.extend_from_slice(&pair(LEGACY_UI_WIDTH, LEGACY_UI_HEIGHT)); + cave.extend_from_slice(&[0x48, 0x89, 0x86, 0x3c, 0x06, 0, 0]); // mov [rsi+0x63c], rax + cave.extend_from_slice(&[0x48, 0xb8]); // mov rax, output size + cave.extend_from_slice(&pair(WIDTH, HEIGHT)); + cave.extend_from_slice(&[0x48, 0x89, 0x86, 0x54, 0x06, 0, 0]); // mov [rsi+0x654], rax + cave.extend_from_slice(&[0xc5, 0xf8, 0x77]); // vzeroupper + let back = i64::from(SETTINGS_COPY) + SETTINGS_COPY_LEN as i64 - (i64::from(SETTINGS_CAVE) + cave.len() as i64 + 5); + cave.push(0xe9); // jmp back + cave.extend_from_slice(&i32::try_from(back)?.to_le_bytes()); + ensure!(cave.len() <= SETTINGS_CAVE_LEN, "settings cave code too long"); + Ok(cave) +} + +/// `jmp cave` and NOPs over the copy's last store. +fn settings_copy_bytes() -> Result<[u8; SETTINGS_COPY_LEN]> { + let mut site = [0x90; SETTINGS_COPY_LEN]; + site[0] = 0xe9; + let to = i64::from(SETTINGS_CAVE) - (i64::from(SETTINGS_COPY) + 5); + site[1..5].copy_from_slice(&i32::try_from(to)?.to_le_bytes()); + Ok(site) +} /// Bytes of one 64 KiB-aligned, 64 KiB-tiled RGBA8 UI surface. fn ui_surface_bytes(width: u32, height: u32) -> Result { @@ -74,10 +115,10 @@ pub(super) fn prepare(image: &mut PreparedImage, render_1080p: bool) -> Result<( "1440p output is only known for the retail build {RETAIL_BUILD}" ); - let mode = field::<16>(image, SDR_MODE)?; - ensure!(same(&mode[..], STOCK_SDR_MODE), "unexpected Series X SDR mode"); - mode[..4].copy_from_slice(&WIDTH.to_le_bytes()); - mode[4..8].copy_from_slice(&HEIGHT.to_le_bytes()); + // The SDR mode stays at stock 3840x2160: the pause map's targets and the + // title's screen size follow the layout size, which stays 4K as on + // Series S. Only checked here. + ensure!(same(&field::<16>(image, SDR_MODE)?[..], STOCK_SDR_MODE), "unexpected Series X SDR mode"); // With the legacy UI flag set, the UI setup makes two 3840x2160 legacy // UI surfaces and two 2560x1440 UI targets in one pool, and asserts that @@ -93,15 +134,17 @@ pub(super) fn prepare(image: &mut PreparedImage, render_1080p: bool) -> Result<( ensure!(*pool == [0xb9, 0, 0, 0, 4], "unexpected Series X UI pool size"); pool[1..].copy_from_slice(&pool_size.to_le_bytes()); - // The legacy UI flag set on Series X too: the preset's byte loads as 1 - // (`mov al, 1`), and the settings update stores 1 (`mov byte [rsi+0x13c], - // 1`). The rest of the preset stays Series X. - let preset = field::<6>(image, LEGACY_UI_PRESET)?; - ensure!(same(&preset[..], STOCK_LEGACY_UI_PRESET), "unexpected legacy UI preset load"); - *preset = [0xb0, 0x01, 0x90, 0x90, 0x90, 0x90]; - let store = field::<7>(image, LEGACY_UI_FLAG_STORE)?; - ensure!(same(&store[..], STOCK_LEGACY_UI_FLAG_STORE), "unexpected legacy UI flag store"); - *store = [0xc6, 0x86, 0x3c, 0x01, 0x00, 0x00, 0x01]; + // The output settings as Series S's preset has them (legacy UI flag 1, + // legacy UI size 3840x2160), with a 2560x1440 output, written into the + // title's settings each time they are stored. The rest of the preset + // stays Series X. + let site = field::(image, SETTINGS_COPY)?; + ensure!(same(&site[..], STOCK_SETTINGS_COPY), "unexpected settings copy"); + let cave = field::(image, SETTINGS_CAVE)?; + ensure!(cave.iter().all(|b| *b == 0xcc), "settings cave is not free padding"); + let code = settings_cave_bytes()?; + cave[..code.len()].copy_from_slice(&code); + *field::(image, SETTINGS_COPY)? = settings_copy_bytes()?; let scale = field::<4>(image, TEMPORAL_SCALE)?; ensure!(*scale == (2.0f32 / 3.0).to_le_bytes(), "unexpected Series X temporal scene scale"); @@ -201,19 +244,19 @@ mod tests { for (render_1080p, scene) in [(false, (2560, 1440)), (true, (1920, 1080))] { let mut image = victory_loader::prepare(&bytes).unwrap(); assert_eq!(prepare(&mut image, render_1080p).unwrap(), scene); - let mode = *field::<16>(&mut image, SDR_MODE).unwrap(); - assert_eq!(mode[..4], WIDTH.to_le_bytes()); - assert_eq!(mode[4..8], HEIGHT.to_le_bytes()); + assert!(same(&field::<16>(&mut image, SDR_MODE).unwrap()[..], STOCK_SDR_MODE)); let scale = f32::from_le_bytes(*field::<4>(&mut image, TEMPORAL_SCALE).unwrap()); assert_eq!((WIDTH as f32 * scale) as u32, scene.0); // The UI pool holds two legacy surfaces and two 1440p targets. assert_eq!(*field::<5>(&mut image, UI_POOL).unwrap(), [0xb9, 0x00, 0x00, 0xe0, 0x05]); - // The legacy UI flag is set from the preset and by the update. - assert_eq!(*field::<6>(&mut image, LEGACY_UI_PRESET).unwrap(), [0xb0, 0x01, 0x90, 0x90, 0x90, 0x90]); - assert_eq!( - *field::<7>(&mut image, LEGACY_UI_FLAG_STORE).unwrap(), - [0xc6, 0x86, 0x3c, 0x01, 0x00, 0x00, 0x01] - ); + // The settings copy jumps to the cave, whose jump comes back + // right after the patched site. + assert_eq!(*field::(&mut image, SETTINGS_COPY).unwrap(), settings_copy_bytes().unwrap()); + let code = settings_cave_bytes().unwrap(); + let cave = *field::(&mut image, SETTINGS_CAVE).unwrap(); + assert_eq!(cave[..code.len()], code[..]); + let back = i32::from_le_bytes(code[code.len() - 4..].try_into().unwrap()); + assert_eq!((SETTINGS_CAVE + code.len() as u32).wrapping_add_signed(back), SETTINGS_COPY + SETTINGS_COPY_LEN as u32); // Patched once, the image is no longer the stock one: refused. assert!(prepare(&mut image, render_1080p).is_err()); } diff --git a/apps/victory/src/run.rs b/apps/victory/src/run.rs index ad6ac5908..be0ef871c 100644 --- a/apps/victory/src/run.rs +++ b/apps/victory/src/run.rs @@ -172,10 +172,11 @@ pub fn run( } let (w, h) = native_1440p::prepare(&mut prepared, render_1080p && upscaler.is_none()) .map_err(|e| if victory_game::identify(&hash).is_some() { e } else { e.context(changed_copy(exe)) })?; - // SAFETY: nothing else runs yet; the title and the display mode list - // read these later. + // The display mode reported to the title stays the 3840x2160 default + // (`dxgi::display_size`), as on Series S: the output is 1440p from the + // title's own settings (`native_1440p::prepare`). + // SAFETY: nothing else runs yet; the title reads this later. unsafe { - std::env::set_var("VICTORY_DISPLAY_MODE", format!("{}x{}", native_1440p::WIDTH, native_1440p::HEIGHT)); std::env::set_var("VICTORY_NATIVE_1440P", "1"); } match upscaler.map(|mode| (mode, native_1440p::prepare_upscaler(&mut prepared, mode))) {