From 2b16578f697982418524d60e2e0c6747fa726436 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 31 Oct 2026 09:57:38 +0800 Subject: [PATCH] Boot the 1.1 game: its init_array count, checkpoint addresses and version name The build knows the player's update as v111: DISPLAY_VERSIONS maps it for the version line of the settings menu, and boot.c carries its two checkpoint return addresses (0xeb8c14 for SetFocusHandlingMode, 0xebcdec for the first nvnBootstrapLoader call) beside the 1.2.1 and 1.4.3 ones, with init_array counts of 10668, 45 and 116 for main, subsdk0 and sdk. The build guide lists v111 among the versions every step takes. Co-authored-by: deepseek-v4.1-flash-1017 --- docs/building.md | 3 ++- runtime/boot.c | 27 +++++++++++++++------------ runtime/host.h | 2 +- tools/build_game.py | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/building.md b/docs/building.md index e7d48480..f457b81a 100644 --- a/docs/building.md +++ b/docs/building.md @@ -52,7 +52,8 @@ hactool reads `-k `; MSYS2 shells set `HOME`, which hides its default ## Build From the repository root, in PowerShell. Every step that depends on the game version takes it as ``: `v143` for -1.4.3 or `v121` for 1.2.1. The tools default to `v121` when `--version` is left out. Saves load on either version. +1.4.3, `v121` for 1.2.1 or `v111` for 1.1.1. The tools default to `v121` when `--version` is left out. Saves load on any +of them. 1. Python environments (once). `.venv` runs the lifter and the build; `.venv-py314` runs the extraction scripts, which need the stdlib `compression.zstd` of Python 3.14: diff --git a/runtime/boot.c b/runtime/boot.c index 6a754e9f..e27ddb17 100644 --- a/runtime/boot.c +++ b/runtime/boot.c @@ -3,11 +3,12 @@ // da35b83 (MIT, Copyright (c) 2026 Peiikai). // The boot driver: the guest main thread runs the game's own nn::init::Start // with three host callbacks, the second of which runs DT_INIT of main, subsdk0 and sdk; Start then calls nnMain. -// --boot checks two checkpoints on the way and ends at the first nvnBootstrapLoader call: -// SetFocusHandlingMode called from main+0xe7a954 (1.4.3: +0xbdb48c) in nnMain, every module's constructor flag -// reads 2 -// nvnBootstrapLoader called from main+0xe7eb2c (1.4.3: +0xbe0360) in the graphics bring-up; logs the run -// statistics, exits 0 +// --boot checks two checkpoints on the way and ends at the first nvnBootstrapLoader call, at the return address of +// each in main (1.1.1, 1.2.1, 1.4.3): +// SetFocusHandlingMode main+0xeb8c14 (1.2.1: +0xe7a954, 1.4.3: +0xbdb48c) in nnMain, every module's constructor +// flag reads 2 +// nvnBootstrapLoader main+0xebcdec (1.2.1: +0xe7eb2c, 1.4.3: +0xbe0360) in the graphics bring-up; logs the +// run statistics, exits 0 // With --seconds S the run continues past that call; rt_frame_presented ends it once the world clock passed S. #include #include @@ -22,18 +23,20 @@ #include "platform/platform.h" #define SYM_INIT_START "_ZN2nn4init5StartEmmPFvvES2_S2_" -// main: return addresses of nnMain's SetFocusHandlingMode call (1.2.1 from this port's analysis of main; 1.4.3 from -// MacNativeGames' scripts/verify_boot.py) and of the first nvnBootstrapLoader call, per game version. -#define CHECKPOINT_RET (RT_V143 ? 0xbdb48cull : 0xe7a954ull) -#define NVN_RET (RT_V143 ? 0xbe0360ull : 0xe7eb2cull) +// main: return addresses of nnMain's SetFocusHandlingMode call (1.1.1 and 1.2.1 from this port's analysis of main; +// 1.4.3 from MacNativeGames' scripts/verify_boot.py) and of the first nvnBootstrapLoader call, per game version. +#define RT_V111 (rt_game_version == 111) +#define CHECKPOINT_RET (RT_V143 ? 0xbdb48cull : RT_V111 ? 0xeb8c14ull : 0xe7a954ull) +#define NVN_RET (RT_V143 ? 0xbe0360ull : RT_V111 ? 0xebcdecull : 0xe7eb2cull) #define CTOR_DONE 2 // a module's constructor flag after its DT_INIT ran the init_array -// The init_array sizes (1.2.1: counted in the modules; 1.4.3: DT_INIT_ARRAYSZ); MacNativeGames' boot check expects -// the same. +// The init_array sizes (1.1.1 and 1.2.1: counted in the modules; 1.4.3: DT_INIT_ARRAYSZ); MacNativeGames' boot check +// expects the same. The three tables carry the same rows, so cb_module_inits walks them by the size of one. typedef struct { const char *name; uint64_t entries; } InitCount; +static const InitCount inits_111[] = {{"main", 10668}, {"subsdk0", 45}, {"sdk", 116}}; static const InitCount inits_121[] = {{"main", 10673}, {"subsdk0", 45}, {"sdk", 116}}; static const InitCount inits_143[] = {{"main", 10717}, {"subsdk0", 45}, {"sdk", 83}}; -#define expected_inits (RT_V143 ? inits_143 : inits_121) +#define expected_inits (RT_V143 ? inits_143 : RT_V111 ? inits_111 : inits_121) static volatile int32_t inits_done, checkpoint_seen; uint64_t rt_guest_start_ns; diff --git a/runtime/host.h b/runtime/host.h index 452ac8e4..e0bf5f5d 100644 --- a/runtime/host.h +++ b/runtime/host.h @@ -184,7 +184,7 @@ typedef struct { const char *file, *sha256; } RtFileHash; extern const RtFileHash rt_exefs_sha256[]; // tools/data/expected-.json "exefs_sha256" extern const int rt_exefs_sha256_count; extern const char rt_default_exefs[], rt_default_romfs[], rt_default_profile[]; -extern const int rt_game_version; // the game build: 121 (1.2.1) or 143 (1.4.3) +extern const int rt_game_version; // the game build: 111 (1.1.1), 121 (1.2.1) or 143 (1.4.3) extern const char rt_port_version[]; // VERSION at the build's root: 0.1.0, 0.1.0+973c626 in a release #define RT_V143 (rt_game_version >= 143) diff --git a/tools/build_game.py b/tools/build_game.py index 8d88d01c..65a2062f 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -150,7 +150,7 @@ WINDRES = UCRT / 'windres.exe' # runtime/totk.rc: the manifest of totk.exe TOOLCHAIN_BIN = None # llvm-mingw bin directory, set by main() for --toolchain DEPS = None # the deps directory of an llvm-mingw build # tools/data/expected-.json for each build version name. -DISPLAY_VERSIONS = {'v0': '1.0.0', 'v112': '1.1.2', 'v121': '1.2.1', 'v143': '1.4.3'} +DISPLAY_VERSIONS = {'v0': '1.0.0', 'v111': '1.1.1', 'v112': '1.1.2', 'v121': '1.2.1', 'v143': '1.4.3'} GiB = 1 << 30 # Peak commit of one compile, 1.2.1 at -O1 (2026-10-20): 120-180 MiB per ~3 MiB chunk, 568 MiB for main_table.c