From ff5706c28bd6efb1a258ef5150647b93c6815f99 Mon Sep 17 00:00:00 2001 From: SchulzCode <116190857+SchulzCode@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:03:37 +0100 Subject: [PATCH 1/6] Cache the thread id per thread on Linux plat_thread_id() made a gettid syscall on every call, about 700,000 times a second in the open world (plat_rmutex_lock asks on every acquire). A thread's id never changes and the runtime does not fork, so the first call on each thread keeps it in a thread-local. noinline keeps a caller from reusing the thread-local's address across a fiber switch, since a fiber may resume on another thread. Fixes #236. --- runtime/platform/linux.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/platform/linux.c b/runtime/platform/linux.c index 0b9f572a..c28bff64 100644 --- a/runtime/platform/linux.c +++ b/runtime/platform/linux.c @@ -1172,7 +1172,17 @@ size_t plat_getenv(const char *name, char *out, size_t cap) { return n; } -uint32_t plat_thread_id(void) { return (uint32_t)syscall(SYS_gettid); } +// The kernel's id of the calling thread, kept per thread after the first call. The runtime asks for it about 700,000 +// times a second in the open world (plat_rmutex_lock in common.c, on every acquire), and syscall(SYS_gettid) enters the +// kernel each time. +// A thread's id never changes, and the runtime does not fork. noinline: a fiber may resume on another thread +// (platform.h), and a caller that inlined this could reuse the address of tid it computed before a plat_fiber_switch; +// as a call it reads the slot of the thread it runs on, as the syscall did. +__attribute__((noinline)) uint32_t plat_thread_id(void) { + static __thread uint32_t tid; + if (!tid) tid = (uint32_t)syscall(SYS_gettid); + return tid; +} // The first set variable of names ("ru_RU.UTF-8") as a BCP-47 tag ("ru-RU") into tag; "" for C and POSIX. static void locale_tag(const char *const *names, int n, char *tag, size_t cap) { From 33c2a1ac63085371c3ae7a310d789f4a3bdd2969 Mon Sep 17 00:00:00 2001 From: m3rcury02 <74795556+m3rcury02@users.noreply.github.com> Date: Sun, 1 Nov 2026 16:03:41 +0530 Subject: [PATCH 2/6] Stop the Windows release on a translator older than its sources. make_release.py copied build/xlate as it found it, so a translator change reached no Windows release until someone rebuilt it by hand, and nothing failed when they did not: 0.2.1 and 0.2.8 shipped a translator from before the gather bias while the runtime logged that the bias was on. The Linux release builds its own. Co-Authored-By: Claude Opus 5.5 --- docs/building.md | 3 ++- tools/make_release.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/building.md b/docs/building.md index e63b60d3..9bb704b1 100644 --- a/docs/building.md +++ b/docs/building.md @@ -78,7 +78,8 @@ of them. .venv-py314\Scripts\python tools\extract.py ``` -4. Shader translator (once; no game files). This publishes `build\xlate\totk_xlate.exe`: +4. Shader translator (no game files; again after a change to its sources, and `tools\make_release.py` stops on an older + one). This publishes `build\xlate\totk_xlate.exe`: ```powershell .venv\Scripts\python tools\build_xlate.py diff --git a/tools/make_release.py b/tools/make_release.py index 4b9bf12f..8dd9f600 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -25,6 +25,8 @@ Both need one game version extracted and lifted first (tools/extract.py, recomp/ it, generated/v143, and for --prove its build/extracted/ (they are read, nothing is written to them). The runtime library reads only what both versions' layout.h share (MOD_COUNT, MOD_MAIN_BASE), so either serves. +A release also needs build/xlate built from the current sources (tools/build_xlate.py); the script stops first if not. + The folder contains nothing derived from the game: check_content runs over it before the script finishes. Then the folder's own python runs a check-only installer pass (no game files: it must get through the release, toolchain and host checks and stop at the missing game files) and the window's --selftest. @@ -45,6 +47,7 @@ import zipfile from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) +import build_xlate # noqa: E402 import check_content # noqa: E402 import shader_list # noqa: E402 @@ -293,6 +296,17 @@ def build_llvm(out): # ---- bin/ and deps --------------------------------------------------------------------------------------------------- +def check_translator(): + """Stop on a translator older than the sources. build/xlate is built by hand and only copied here (the Linux release + builds its own), so without a rebuild a translator change reaches no Windows release, and nothing fails: the runtime + sends job fields the old exe ignores, as happened to gather_bias.""" + idf = MAIN_ROOT / 'build' / 'xlate' / 'totk_xlate.id' + have = idf.read_text(encoding='ascii').strip() if idf.is_file() else 'none' + want = build_xlate.identity() + if have != want: + sys.exit(f'build/xlate has translator {have[:16]}, the sources are {want[:16]}: run tools/build_xlate.py') + + def build_bin(out): b = out / 'bin' b.mkdir(parents=True, exist_ok=True) @@ -545,6 +559,7 @@ def main(): if args.prove: prove(out, args.cpu) return + check_translator() if out.exists(): shutil.rmtree(out) out.mkdir(parents=True) From da9460457e7fd5f318d11e0b2d349f584d6ff99b Mon Sep 17 00:00:00 2001 From: itaskaev2 <165683571+itaskaev2@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:08:52 +0100 Subject: [PATCH 3/6] Stage large CPU texture uploads in parts of at most 32 MiB With astc = cpu a large ASTC array decodes to RGBA8 in one staging buffer: the 1024x1024 array of 121 layers with 11 levels takes 645 MiB. On an Intel UHD with 8 GB of shared memory that allocation failed (-2) and the game closed before the title screen (#347). upload now fills one staging buffer per part of at most 32 MiB (a single region larger than that gets its own) and records one copy per part, all in the same upload batch, which is submitted as before. The parts fit the staging pool's 64 MiB blocks. The GPU ASTC decoder still reads every region from one buffer. Fixes #347. Co-Authored-By: Claude Opus 5.5 --- runtime/vk_texture.c | 66 +++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c index c43b13dc..90b8873c 100644 --- a/runtime/vk_texture.c +++ b/runtime/vk_texture.c @@ -622,9 +622,14 @@ static void astc_check(const Tex *e, const uint8_t *raw, const VkAstcRegion *ar, (unsigned long long)n_texels, (unsigned long long)n_diff_tex); } +// Staging bytes of one part of a texture upload decoded or copied on the CPU (see upload). With TOTK_ASTC=cpu a +// large ASTC array decodes to RGBA8 in one go: a staging buffer of 676682336 bytes failed (-2) on an Intel UHD with +// 8 GB of shared memory and the game closed before the title screen. +#define UPLOAD_PART (32ull << 20) // fits the staging pool (vk_staging takes up to half of its 64 MiB block) + // Copies the whole storage into the image (every level and layer the image has). static void upload(Tex *e) { - static volatile int32_t n_bad, n_undecoded; + static volatile int32_t n_bad, n_undecoded, n_split; const tex_t *t = &e->t; const nvn_texdesc *d = &t->d; int bw, bh, bpb = nvn_fmt_bpb(d->format, &bw, &bh); @@ -648,16 +653,27 @@ static void upload(Tex *e) { total += (out + 15) & ~15ull; decoded += texels * 4; } - VkCommandBuffer cb = vk_upload_begin(); VkBuffer sb, rbuf = VK_NULL_HANDLE; VmaAllocation ralloc = NULL; - uint8_t *stg = vk_staging(total, &sb, NULL), *rmap = acheck ? vk_staging(decoded, &rbuf, &ralloc) : NULL; - k = 0; - for (uint32_t lv = 0; lv < levels; lv++) - for (uint32_t ly = 0; ly < layers; ly++, k++) { + uint8_t *rmap = NULL, *raw_copy = NULL; + int checked = 0, parts = 1; + // A CPU decode or copy stages at most UPLOAD_PART bytes per staging buffer (a region larger than that alone) and + // records one copy per buffer; every part stays in the same upload batch, submitted as before. The GPU decoder + // takes the raw blocks of every region from one buffer. + for (uint32_t k0 = 0, k1; k0 < n; k0 = k1) { + VkDeviceSize base = rg[k0].bufferOffset, size; + for (k1 = k0 + 1; k1 < n && (agpu || (k1 + 1 < n ? rg[k1 + 1].bufferOffset : total) - base <= UPLOAD_PART);) k1++; + size = (k1 < n ? rg[k1].bufferOffset : total) - base; + if (k0) parts++; + VkCommandBuffer cb = vk_upload_begin(); + uint8_t *stg = vk_staging(size, &sb, NULL); + if (acheck) rmap = vk_staging(decoded, &rbuf, &ralloc); + for (k = k0; k < k1; k++) { + uint32_t lv = rg[k].imageSubresource.mipLevel, ly = rg[k].imageSubresource.baseArrayLayer; uint32_t w = rg[k].imageExtent.width, h = rg[k].imageExtent.height, sl = rg[k].imageExtent.depth; uint32_t rb = (w + bw - 1) / bw * (uint32_t)bpb, rows = (h + bh - 1) / bh; size_t raw = (size_t)rb * rows * sl; + rg[k].bufferOffset -= base; uint8_t *dst = stg + rg[k].bufferOffset, *tmp = (astc && !agpu) || rgb ? malloc(raw) : NULL; if (nvn_deswizzle(d, lv, ly, t->mem, tmp ? tmp : dst, rb)) { log_limited(&n_bad, "texture %#llx fmt %#x target %d: level %u layer %u has no CPU layout; uploaded as zeros", @@ -681,23 +697,29 @@ static void upload(Tex *e) { } free(tmp); } - uint8_t *raw_copy = acheck ? malloc(total) : NULL; - if (raw_copy) memcpy(raw_copy, stg, total); - barrier(cb, ALL_RW, VK_PIPELINE_STAGE_2_COPY_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT); - int checked = 0; - if (agpu) { - uint64_t a0 = perf_begin(); - checked = vk_astc_record(cb, sb, total, ar, (int)n, e->f.astc_bw, e->f.astc_bh, e->f.astc_srgb, e->f.astc_bc, e->pub.image, - e->pub.aspect, rbuf); - perf_end(PERF_ASTC, a0); - if (!checked) - log_limited(&n_undecoded, "ASTC texture %#llx (fmt %#x %ux%u) not decoded on the GPU: left as it was", - (unsigned long long)e->pub.addr, d->format, d->width, d->height); - } else { - vkCmdCopyBufferToImage(cb, sb, e->pub.image, VK_IMAGE_LAYOUT_GENERAL, n, rg); + if (acheck) { + raw_copy = malloc(size); + memcpy(raw_copy, stg, size); + } + barrier(cb, ALL_RW, VK_PIPELINE_STAGE_2_COPY_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT); + if (agpu) { + uint64_t a0 = perf_begin(); + checked = vk_astc_record(cb, sb, size, ar, (int)n, e->f.astc_bw, e->f.astc_bh, e->f.astc_srgb, e->f.astc_bc, + e->pub.image, e->pub.aspect, rbuf); + perf_end(PERF_ASTC, a0); + if (!checked) + log_limited(&n_undecoded, "ASTC texture %#llx (fmt %#x %ux%u) not decoded on the GPU: left as it was", + (unsigned long long)e->pub.addr, d->format, d->width, d->height); + } else { + vkCmdCopyBufferToImage(cb, sb, e->pub.image, VK_IMAGE_LAYOUT_GENERAL, k1 - k0, rg + k0); + } + barrier(cb, VK_PIPELINE_STAGE_2_COPY_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT, ALL_RW); + vk_upload_end(); } - barrier(cb, VK_PIPELINE_STAGE_2_COPY_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT, ALL_RW); - vk_upload_end(); + if (parts > 1) + log_limited(&n_split, "texture %#llx fmt %#x %ux%u, %u levels, %u layers: %.1f MiB staged in %d parts", + (unsigned long long)e->pub.addr, d->format, d->width, d->height, levels, layers, total / 1048576.0, + parts); if (acheck) { // waits for the GPU vk_upload_flush(1); if (checked) { From cc4572b244b3615ff49aab0b1c4dcf5f9b3ca9eb Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 31 Oct 2026 09:57:49 +0800 Subject: [PATCH 4/6] Build the runtime library without the generated chunk lists --make-runtime-lib compiles runtime/ alone, so it must not insist on a chunk manifest that only a lift writes: the library is rebuilt by itself when the runtime sources change. --- tools/build_game.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build_game.py b/tools/build_game.py index ef55110c..608c01db 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -821,7 +821,8 @@ def main(): if unknown: sys.exit(f'unknown modules {unknown}; the layout has {names}') linked = [m for m in names if m in wanted] - mods = {m: chunk_files(gen, m) for m in linked} + # --make-runtime-lib builds runtime/ only, so it never reads the generated chunks + mods = {} if args.make_runtime_lib else {m: chunk_files(gen, m) for m in linked} cpus = os.cpu_count() or 1 budget = min(MEM_BUDGET, int(total_ram() * 0.8)) From a7b988b417e89757850c3750e3624d46c08751f3 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 1 Nov 2026 21:08:13 +0800 Subject: [PATCH 5/6] Name the 1.1.0 update 1.1.0 instead of 1.1.1 The update this port builds for has version value 0x20000, which is Tears of the Kingdom 1.1.0, not 1.1.1: the upstream expected-v1.1.2.json carries 0x40000 and the other expected files step 0x10000 per release, so 0x20000 is 1.1.0 and 0x30000 is 1.1.1. Pull request #220 introduced the wrong label in expected-v1.1.1.json. Expected hashes, patch sites, boot constants and the RomFS layout are unchanged; only names change: - tools/data/expected-v1.1.1.json -> expected-v1.1.0.json, display_version 1.1.0 - recomp/patches-v111.txt -> patches-v110.txt - installer/layout.py SUPPORTED and tools/build_game.py DISPLAY_VERSIONS - make_romfs_patches.py --version choices and its COMMON table key (the RomFS archive name stays Common.Product.110) - runtime RT_V111 -> RT_V110, the inits_111 and expect_111 tables, the probe's census folder v110 - README, docs and the installer texts Co-authored-by: deepseek-v4.1-flash-1017 --- README.md | 4 ++-- docs/building.md | 2 +- docs/installer.md | 6 +++--- docs/tester-guide.md | 2 +- installer/cli.py | 2 +- installer/layout.py | 2 +- installer/text/en.json | 10 +++++----- installer/text/ru.json | 10 +++++----- recomp/{patches-v111.txt => patches-v110.txt} | 8 ++++---- runtime/boot.c | 14 +++++++------- runtime/frame_rate.c | 6 +++--- runtime/gfx_shader_probe.c | 6 +++--- runtime/host.h | 4 ++-- runtime/loader.c | 8 ++++---- tools/build_game.py | 2 +- .../{expected-v1.1.1.json => expected-v1.1.0.json} | 4 ++-- tools/make_romfs_patches.py | 8 ++++---- tools/prepare_shaders.py | 2 +- tools/shader_census.py | 2 +- 19 files changed, 51 insertions(+), 51 deletions(-) rename recomp/{patches-v111.txt => patches-v110.txt} (99%) rename tools/data/{expected-v1.1.1.json => expected-v1.1.0.json} (75%) diff --git a/README.md b/README.md index 21ee2fcb..118bc428 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **TotK Recomp** is a static recompilation of *The Legend of Zelda: Tears of the Kingdom* (Nintendo Switch, 2023) into a native x86-64 application for Windows and Linux ([docs/architecture.md](docs/architecture.md)). > [!IMPORTANT] -> **No game files are included.** You need your own legally obtained copy of *Tears of the Kingdom*, dumped from your own console: the base game and the 1.1.1, 1.2.1 or 1.4.3 update. Instructions for obtaining those files will not be provided. +> **No game files are included.** You need your own legally obtained copy of *Tears of the Kingdom*, dumped from your own console: the base game and the 1.1.0, 1.2.1 or 1.4.3 update. Instructions for obtaining those files will not be provided. > > The game is built from your files on your machine, so the result contains the game. It is for your own use. Do not share it. @@ -16,7 +16,7 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md). ## Features - Native code, not emulation -- Game updates 1.1.1, 1.2.1 and 1.4.3; 1.2.1 and 1.4.3 saves carry over between them +- Game updates 1.1.0, 1.2.1 and 1.4.3; 1.2.1 and 1.4.3 saves carry over between them - 60 fps by default; up to 144 fps or the monitor's refresh rate (experimental) - Custom resolutions (1080p, 2k...), supersampling and AMD FSR 1 upscaling - HDR10 output with peak, game and HUD brightness settings diff --git a/docs/building.md b/docs/building.md index e63b60d3..ad207bd7 100644 --- a/docs/building.md +++ b/docs/building.md @@ -54,7 +54,7 @@ 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, `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 +1.4.3, `v121` for 1.2.1 or `v110` for 1.1.0. 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 diff --git a/docs/installer.md b/docs/installer.md index 102f0c6a..45e6a059 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -9,7 +9,7 @@ holds only the game; the installer and its tools stay outside it. 1. Downloads `TotK-Setup--windows.zip` from GitHub Releases (none is published yet), unpacks it anywhere and starts `TotK-Setup.exe`. 2. Picks: - - the base game (XCI or NSP) and the 1.1.1, 1.2.1 or 1.4.3 update (NSP); + - the base game (XCI or NSP) and the 1.1.0, 1.2.1 or 1.4.3 update (NSP); - their `prod.keys`; - optionally the firmware folder (`system/Contents/registered` of an unpacked firmware or an emulator's install), needed for Chinese, Korean and Traditional Chinese text; @@ -37,13 +37,13 @@ The player runs a newer installer on the same folder. It reads `totk-install.jso `shared-fonts/`, `profile/` and `totk.ini` after checking their hashes, rebuilds `totk.exe` and re-prepares the shaders. A newer release that changes nothing game-derived skips the rebuild. -Given an update file other than the recorded one (1.1.1, then 1.2.1, then 1.4.3), the installer extracts and builds again from it +Given an update file other than the recorded one (1.1.0, then 1.2.1, then 1.4.3), the installer extracts and builds again from it and keeps `profile/`. Saves carry over both ways between 1.2.1 and 1.4.3: 1.4.3 converts a 1.2.1 save on load, and 1.2.1 loads the saves 1.4.3 wrote. ## Setup steps -1. **Check** before writing anything: the files open with the keys, the update is 1.1.1, 1.2.1 or 1.4.3 (by hash, as +1. **Check** before writing anything: the files open with the keys, the update is 1.1.0, 1.2.1 or 1.4.3 (by hash, as `tools/extract.py`), the keys are new enough for the update, enough space is free on the target disk (about 36 GiB at the peak of a first install, 20 GiB after it), the CPU is at least x86-64-v2 (SSE4.2; with AVX2/FMA the faster `v3` build is used, otherwise the `v2` one), a Vulkan 1.3 GPU exists. Each failure is one clear message. diff --git a/docs/tester-guide.md b/docs/tester-guide.md index 08607ae6..ea04a45d 100644 --- a/docs/tester-guide.md +++ b/docs/tester-guide.md @@ -9,7 +9,7 @@ from it may be shared. - Windows 10 or later, an x86-64 CPU with SSE4.2 (AVX2/FMA recommended: they build the default, faster version), about 60 GB free. - A GPU with Vulkan 1.3 and `VK_EXT_external_memory_host`, with a current driver. -- *Tears of the Kingdom* base game (1.0.0) and the 1.1.1, 1.2.1 or 1.4.3 update, dumped from your own Switch as NSP or XCI. +- *Tears of the Kingdom* base game (1.0.0) and the 1.1.0, 1.2.1 or 1.4.3 update, dumped from your own Switch as NSP or XCI. - `prod.keys` dumped from your own Switch. Never send it to anyone, and never paste it into a log or an issue. ## Build diff --git a/installer/cli.py b/installer/cli.py index 17e6da64..f95a0084 100644 --- a/installer/cli.py +++ b/installer/cli.py @@ -48,7 +48,7 @@ def cancel(signum, frame): def main(argv=None): ap = Parser(prog='python -m installer', description=__doc__.splitlines()[0]) ap.add_argument('--base', type=Path, help='base game, XCI or NSP') - ap.add_argument('--update', type=Path, help='the update NSP: 1.1.1, 1.2.1 or 1.4.3') + ap.add_argument('--update', type=Path, help='the update NSP: 1.1.0, 1.2.1 or 1.4.3') ap.add_argument('--keys', type=Path, help='prod.keys') ap.add_argument('--firmware', type=Path, help='Switch firmware folder (Contents/registered) for the shared fonts ' 'of Chinese, Korean and Traditional Chinese text') diff --git a/installer/layout.py b/installer/layout.py index 930c8e8d..5b5c498a 100644 --- a/installer/layout.py +++ b/installer/layout.py @@ -37,7 +37,7 @@ from pathlib import Path WIN = os.name == 'nt' EXE = '.exe' if WIN else '' UCRT = Path(r'C:\msys64\ucrt64\bin') -SUPPORTED = ('1.2.1', '1.4.3', '1.1.1') # updates the installer builds; the check identifies the player's by hash +SUPPORTED = ('1.2.1', '1.4.3', '1.1.0') # updates the installer builds; the check identifies the player's by hash def version_tag(version): diff --git a/installer/text/en.json b/installer/text/en.json index 6f06ab4e..dfc6198b 100644 --- a/installer/text/en.json +++ b/installer/text/en.json @@ -51,7 +51,7 @@ "check.vulkan_missing": "No Vulkan driver is installed. Install the latest driver for your graphics card.", "check.vulkan_no_device": "Vulkan finds no graphics card. Install the latest driver for your graphics card.", "check.vulkan_too_old": "The game needs a graphics card with Vulkan 1.3; found: {devices}. Update the graphics driver.", - "check.inputs_needed": "The game files are needed: choose the base game, the 1.1.1 or 1.2.1 or 1.4.3 update and prod.keys.", + "check.inputs_needed": "The game files are needed: choose the base game, the 1.1.0 or 1.2.1 or 1.4.3 update and prod.keys.", "check.input_missing": "File not found ({input}): {path}", "check.keys_unreadable": "The keys file cannot be read. Choose a prod.keys file.", "check.keys_no_header_key": "The keys file has no header_key. Dump prod.keys from your console again.", @@ -65,7 +65,7 @@ "check.base_is_update": "The base game file is an update. Choose the base game NSP or XCI (version 1.0.0) here and this file as the update.", "check.base_combined": "The base game file holds several packages (base game, update or DLC in one file). Choose a base game dump that contains only the game.", "check.update_not_nsp": "The update must be an NSP file.", - "check.update_is_base": "The update file holds a base game. Choose the 1.1.1 or 1.2.1 or 1.4.3 update NSP.", + "check.update_is_base": "The update file holds a base game. Choose the 1.1.0 or 1.2.1 or 1.4.3 update NSP.", "check.update_not_totk": "The update file is not a Tears of the Kingdom update ({detail}).", "check.exefs_failed": "The game code of the {input} file failed its checks; see {log}.", "check.input_damaged": "The {input} file is damaged or incomplete: {path} ({detail}). Copy that file again from its source, or dump it again, then run the setup again.", @@ -104,14 +104,14 @@ "ui.notice": "The folder this setup builds contains the game. It is for your own use only; do not share or upload it.", "ui.keys_private": "The keys file is read in place. Its contents are never shown, copied or stored.", "ui.base": "Base game (NSP or XCI)", - "ui.update": "Update 1.1.1 or 1.2.1 or 1.4.3 (NSP)", + "ui.update": "Update 1.1.0 or 1.2.1 or 1.4.3 (NSP)", "ui.keys": "prod.keys", "ui.firmware": "Firmware folder (optional)", "ui.game_language": "Game language", "ui.dest": "Install folder", "ui.browse": "Browse...", "ui.pick_game": "Choose the base game file", - "ui.pick_update": "Choose the 1.1.1 or 1.2.1 or 1.4.3 update file", + "ui.pick_update": "Choose the 1.1.0 or 1.2.1 or 1.4.3 update file", "ui.pick_keys": "Choose prod.keys", "ui.pick_firmware": "Choose the Switch firmware folder (Contents/registered)", "ui.pick_dest": "Choose the install folder", @@ -131,7 +131,7 @@ "ui.update_mode": "This folder holds an earlier installation. The setup continues or updates it; the game files are asked for only if they are needed again.", "ui.need_dest": "Choose the install folder.", "ui.need_base": "Choose the base game file.", - "ui.need_update": "Choose the 1.1.1 or 1.2.1 or 1.4.3 update file.", + "ui.need_update": "Choose the 1.1.0 or 1.2.1 or 1.4.3 update file.", "ui.need_keys": "Choose the prod.keys file.", "ui.need_lang": "Choose the game language.", "ui.missing_base": "The base game file does not exist.", diff --git a/installer/text/ru.json b/installer/text/ru.json index 72db03d2..ad4e71c2 100644 --- a/installer/text/ru.json +++ b/installer/text/ru.json @@ -51,7 +51,7 @@ "check.vulkan_missing": "Драйвер Vulkan не установлен. Установите свежий драйвер видеокарты.", "check.vulkan_no_device": "Vulkan не находит видеокарту. Установите свежий драйвер видеокарты.", "check.vulkan_too_old": "Игре нужна видеокарта с Vulkan 1.3; найдено: {devices}. Обновите драйвер видеокарты.", - "check.inputs_needed": "Нужны игровые файлы: выберите базовую игру, обновление 1.1.1 или 1.2.1 или 1.4.3 и prod.keys.", + "check.inputs_needed": "Нужны игровые файлы: выберите базовую игру, обновление 1.1.0 или 1.2.1 или 1.4.3 и prod.keys.", "check.input_missing": "Файл не найден ({input}): {path}", "check.keys_unreadable": "Не удаётся прочитать файл ключей. Выберите файл prod.keys.", "check.keys_no_header_key": "В файле ключей нет header_key. Снова получите prod.keys со своей консоли.", @@ -65,7 +65,7 @@ "check.base_is_update": "Файл базовой игры — это обновление. Выберите здесь NSP или XCI базовой игры (версия 1.0.0), а этот файл укажите как обновление.", "check.base_combined": "Файл базовой игры содержит несколько пакетов (игра, обновление или DLC в одном файле). Выберите дамп, в котором только базовая игра.", "check.update_not_nsp": "Обновление должно быть файлом NSP.", - "check.update_is_base": "Файл обновления содержит базовую игру. Выберите NSP с обновлением 1.1.1 или 1.2.1 или 1.4.3.", + "check.update_is_base": "Файл обновления содержит базовую игру. Выберите NSP с обновлением 1.1.0 или 1.2.1 или 1.4.3.", "check.update_not_totk": "Файл обновления — не обновление Tears of the Kingdom ({detail}).", "check.exefs_failed": "Код игры из файла «{input}» не прошёл проверку; подробности в {log}.", "check.input_damaged": "Файл «{input}» повреждён или скопирован не полностью: {path} ({detail}). Скопируйте этот файл заново из источника или сделайте дамп ещё раз, затем снова запустите установку.", @@ -104,14 +104,14 @@ "ui.notice": "Папка, которую создаёт установка, содержит игру. Она предназначена только для личного использования: не передавайте и не выкладывайте её.", "ui.keys_private": "Файл ключей читается на месте. Его содержимое не показывается, не копируется и не сохраняется.", "ui.base": "Базовая игра (NSP или XCI)", - "ui.update": "Обновление 1.1.1 или 1.2.1 или 1.4.3 (NSP)", + "ui.update": "Обновление 1.1.0 или 1.2.1 или 1.4.3 (NSP)", "ui.keys": "prod.keys", "ui.firmware": "Папка прошивки (необязательно)", "ui.game_language": "Язык игры", "ui.dest": "Папка установки", "ui.browse": "Обзор...", "ui.pick_game": "Выберите файл базовой игры", - "ui.pick_update": "Выберите файл обновления 1.1.1 или 1.2.1 или 1.4.3", + "ui.pick_update": "Выберите файл обновления 1.1.0 или 1.2.1 или 1.4.3", "ui.pick_keys": "Выберите prod.keys", "ui.pick_firmware": "Выберите папку прошивки Switch (Contents/registered)", "ui.pick_dest": "Выберите папку установки", @@ -131,7 +131,7 @@ "ui.update_mode": "В этой папке уже есть установка. Программа продолжит или обновит её; файлы игры понадобятся, только если их снова придётся читать.", "ui.need_dest": "Выберите папку установки.", "ui.need_base": "Выберите файл базовой игры.", - "ui.need_update": "Выберите файл обновления 1.1.1 или 1.2.1 или 1.4.3.", + "ui.need_update": "Выберите файл обновления 1.1.0 или 1.2.1 или 1.4.3.", "ui.need_keys": "Выберите файл prod.keys.", "ui.need_lang": "Выберите язык игры.", "ui.missing_base": "Файл базовой игры не найден.", diff --git a/recomp/patches-v111.txt b/recomp/patches-v110.txt similarity index 99% rename from recomp/patches-v111.txt rename to recomp/patches-v110.txt index 905a11b6..c79e4cc8 100644 --- a/recomp/patches-v111.txt +++ b/recomp/patches-v110.txt @@ -1,6 +1,6 @@ -# Code patches for TotK 1.1.1 main (recomp/patches.py). The sites come from MacNativeGames +# Code patches for TotK 1.1.0 main (recomp/patches.py). The sites come from MacNativeGames # games/totk/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.1 by instruction-window matching +# 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 # present (frame_rate.c): +0 the 30 Hz ratio (seconds * 30), +4 the frame step in seconds. @@ -35,7 +35,7 @@ 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, # 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.1 +# 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. site cloth main 9efc20 1e200900 f81f0fe9 @page:x9 bd400520 1e200900 f84107e9 # fmul s0, s8, s0 @@ -66,7 +66,7 @@ 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] site scene main cea5ec 5e21d921 bd0cc660 # scvtf s1, s9 -> str s0, [x19, #0xcc4] -# Spin waits, from tools/spin_waits.py --exefs build/extracted/v111/exefs --patches recomp/patches-v111.txt: loops that only +# Spin waits, from tools/spin_waits.py --exefs build/extracted/v110/exefs --patches recomp/patches-v110.txt: loops that only # another thread can end; their back-edges pass rt_spin_gate (runtime/kernel.c), TOTK_SPIN=0 keeps the core. # spin waits found by tools/spin_waits.py on the 1.1.x modules diff --git a/runtime/boot.c b/runtime/boot.c index a92830db..30999a95 100644 --- a/runtime/boot.c +++ b/runtime/boot.c @@ -4,7 +4,7 @@ // 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, at the return address of -// each in main (1.1.1, 1.2.1, 1.4.3): +// each in main (1.1.0, 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 @@ -23,19 +23,19 @@ #include "platform/platform.h" #define SYM_INIT_START "_ZN2nn4init5StartEmmPFvvES2_S2_" -// main: return addresses of nnMain's SetFocusHandlingMode call (1.1.1 and 1.2.1 from this port's analysis of main; +// main: return addresses of nnMain's SetFocusHandlingMode call (1.1.0 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 CHECKPOINT_RET (RT_V143 ? 0xbdb48cull : RT_V111 ? 0xeb8c14ull : 0xe7a954ull) -#define NVN_RET (RT_V143 ? 0xbe0360ull : RT_V111 ? 0xebcdecull : 0xe7eb2cull) +#define CHECKPOINT_RET (RT_V143 ? 0xbdb48cull : RT_V110 ? 0xeb8c14ull : 0xe7a954ull) +#define NVN_RET (RT_V143 ? 0xbe0360ull : RT_V110 ? 0xebcdecull : 0xe7eb2cull) #define CTOR_DONE 2 // a module's constructor flag after its DT_INIT ran the init_array -// The init_array sizes (1.1.1 and 1.2.1: counted in the modules; 1.4.3: DT_INIT_ARRAYSZ); MacNativeGames' boot check +// The init_array sizes (1.1.0 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_110[] = {{"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 : RT_V111 ? inits_111 : inits_121) +#define expected_inits (RT_V143 ? inits_143 : RT_V110 ? inits_110 : inits_121) static volatile int32_t inits_done, checkpoint_seen; uint64_t rt_guest_start_ns; diff --git a/runtime/frame_rate.c b/runtime/frame_rate.c index 08b5343c..84ddca10 100644 --- a/runtime/frame_rate.c +++ b/runtime/frame_rate.c @@ -180,13 +180,13 @@ static uint64_t read_ptr(uint64_t a) { uint64_t p = 0; return read_guest(a, &p, 8) ? p : 0; } -// 1.2.1: [main+0x4728538] (1.1.1: [main+0x4630a68], 1.4.3: [main+0x3add238]) +0x1e8 scene, its component 13 lists the +// 1.2.1: [main+0x4728538] (1.1.0: [main+0x4630a68], 1.4.3: [main+0x3add238]) +0x1e8 scene, its component 13 lists the // resident actors; the one named "Player" has its position at +0x2b4 (MacNativeGames world_survey.c, game_version.h -// TOTK_GAME_V121/V143). The 1.1.1 slot was measured from its own dereference chain: 181 scene accesses in that build +// TOTK_GAME_V121/V143). The 1.1.0 slot was measured from its own dereference chain: 181 scene accesses in that build // read it, and one of them reproduces this walk (the 14-component check, component 13, the 0x70 stride and the name // compare) instruction for instruction. static int player_pos(float xyz[3]) { - uint64_t module = read_ptr(MOD_MAIN_BASE + (RT_V143 ? 0x3add238 : RT_V111 ? 0x4630a68 : 0x4728538)), + uint64_t module = read_ptr(MOD_MAIN_BASE + (RT_V143 ? 0x3add238 : RT_V110 ? 0x4630a68 : 0x4728538)), scene = module ? read_ptr(module + 0x1e8) : 0; int32_t count = 0; if (!scene || !read_guest(scene + 0x50, &count, 4) || count < 14 || count > 256) return 0; diff --git a/runtime/gfx_shader_probe.c b/runtime/gfx_shader_probe.c index 753353ed..2023b0d4 100644 --- a/runtime/gfx_shader_probe.c +++ b/runtime/gfx_shader_probe.c @@ -53,9 +53,9 @@ static int hexval(char c) { return c <= '9' ? c - '0' : (c | 32) - 'a' + 10; } // parent of totk.exe that has one with a jobs.json, the running game version's first, then the others' (any census // serves a probe). 1 with that folder in dir. int probe_census_dir(char *dir, size_t n) { - const char *const versions[3] = {RT_V111 ? "v111" : RT_V143 ? "v143" : "v121", - RT_V111 ? "v121" : RT_V143 ? "v121" : "v143", - RT_V111 ? "v143" : RT_V143 ? "v111" : "v111"}; + const char *const versions[3] = {RT_V110 ? "v110" : RT_V143 ? "v143" : "v121", + RT_V110 ? "v121" : RT_V143 ? "v121" : "v143", + RT_V110 ? "v143" : RT_V143 ? "v110" : "v110"}; for (int v = 0; v < 3; v++) { char exe[PLAT_PATH_MAX * 2]; int len = plat_exe_path(exe, sizeof exe); diff --git a/runtime/host.h b/runtime/host.h index e071f182..e856810e 100644 --- a/runtime/host.h +++ b/runtime/host.h @@ -187,9 +187,9 @@ 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: 111 (1.1.1), 121 (1.2.1) or 143 (1.4.3) +extern const int rt_game_version; // the game build: 110 (1.1.0), 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_V111 (rt_game_version == 111) // 1.1.1: its own boot constants and data slots +#define RT_V110 (rt_game_version == 110) // 1.1.0: its own boot constants and data slots #define RT_V143 (rt_game_version >= 143) // ---- kernel (kernel.c) diff --git a/runtime/loader.c b/runtime/loader.c index 8bd482fe..4aa030f5 100644 --- a/runtime/loader.c +++ b/runtime/loader.c @@ -552,8 +552,8 @@ uint64_t ldr_plt_stub(const char *module, const char *name) { } // ---- --probe-loader -// Expected values, measured on the 1.1.1, 1.2.1 and 1.4.3 modules; the 1.4.3 relocation totals match the ones -// MacNativeGames' port notes give for that version. 1.1.1 shares subsdk0 and sdk with 1.2.1 down to every count. +// Expected values, measured on the 1.1.0, 1.2.1 and 1.4.3 modules; the 1.4.3 relocation totals match the ones +// MacNativeGames' port notes give for that version. 1.1.0 shares subsdk0 and sdk with 1.2.1 down to every count. typedef struct { const char *name; uint64_t kinds[K_COUNT], total, sym_import, sym_own; @@ -564,7 +564,7 @@ static const Expect expect_121[] = { {"subsdk0", {1623, 12820, 1030, 3924}, 19397, 6576, 11198, 667, {9, 0, 654}, 4, 0x30, 45}, {"sdk", {10917, 13976, 1207, 8932}, 35032, 16, 24099, 13, {8, 0, 0}, 5, 0x30, 116}, }; -static const Expect expect_111[] = { +static const Expect expect_110[] = { {"main", {508604, 1412, 32, 639}, 510687, 2083, 0, 673, {0, 16, 645}, 12, 0x30, 10668}, {"subsdk0", {1623, 12820, 1030, 3924}, 19397, 6576, 11198, 667, {9, 0, 654}, 4, 0x30, 45}, {"sdk", {10917, 13976, 1207, 8932}, 35032, 16, 24099, 13, {8, 0, 0}, 5, 0x30, 116}, @@ -574,7 +574,7 @@ static const Expect expect_143[] = { {"subsdk0", {3424, 10927, 905, 3817}, 19073, 6557, 9092, 663, {9, 0, 654}, 0, 0x20, 45}, {"sdk", {15013, 10135, 1079, 7832}, 34059, 10, 19036, 8, {8, 0, 0}, 0, 0x400, 83}, }; -#define expect (RT_V143 ? expect_143 : RT_V111 ? expect_111 : expect_121) +#define expect (RT_V143 ? expect_143 : RT_V110 ? expect_110 : expect_121) static int failures; #define CHECK(cond, ...) do { if (!(cond)) { failures++; printf(" FAIL: " __VA_ARGS__); putchar('\n'); } } while (0) diff --git a/tools/build_game.py b/tools/build_game.py index ef55110c..5fb11414 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -163,7 +163,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', 'v111': '1.1.1', 'v112': '1.1.2', 'v121': '1.2.1', 'v143': '1.4.3'} +DISPLAY_VERSIONS = {'v0': '1.0.0', 'v110': '1.1.0', '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 diff --git a/tools/data/expected-v1.1.1.json b/tools/data/expected-v1.1.0.json similarity index 75% rename from tools/data/expected-v1.1.1.json rename to tools/data/expected-v1.1.0.json index 5f706acf..a14f90f8 100644 --- a/tools/data/expected-v1.1.1.json +++ b/tools/data/expected-v1.1.0.json @@ -1,8 +1,8 @@ { - "_comment": "Written locally for the player's own 1.1.x update (version value 0x20000, seen as 1.1.1). RomFS hashes filled in after the first merge; no game data here. No rewritten_sha256: this dump was not run through MacNativeGames' NSO rewriter, so the three digests of the other versions have no reference here and none of the tools read them.", + "_comment": "Written locally for the player's own 1.1.0 update (version value 0x20000). RomFS hashes filled in after the first merge; no game data here. No rewritten_sha256: this dump was not run through MacNativeGames' NSO rewriter, so the three digests of the other versions have no reference here and none of the tools read them.", "title_id": "0100F2C0115B6000", "version": 131072, - "display_version": "1.1.1", + "display_version": "1.1.0", "exefs_sha256": { "main": "1664b8cf664524d90ca64deb3ce41709266457df966dcb499485267554eb8cec", "main.npdm": "fa3f60922406ab9e2488c2b8d77b12e9869b435033fd8c27c543c347bc185587", diff --git a/tools/make_romfs_patches.py b/tools/make_romfs_patches.py index a5236556..acf151d4 100644 --- a/tools/make_romfs_patches.py +++ b/tools/make_romfs_patches.py @@ -1,6 +1,6 @@ # Adapted from MacNativeGames games/totk/scripts/make_romfs_patches.py @ ebe621d (MIT, Copyright (c) 2026 # MacNativeGames contributors). -"""Build the 60 fps RomFS overlay for TotK 1.1.1, 1.2.1 or 1.4.3 (runtime/romfs.c, TOTK_ROMFS_PATCHES). +"""Build the 60 fps RomFS overlay for TotK 1.1.0, 1.2.1 or 1.4.3 (runtime/romfs.c, TOTK_ROMFS_PATCHES). UI/LayoutArchive/Common.Product.<110 or 140>.Nin_NX_NVN.blarc.zs: the weapon / shield / material quick menus capture the game picture for their background when the panes C_CaptureBG_00, C_CaptureClearBG_00 and P_CaptureClearBG_00 become @@ -8,7 +8,7 @@ visible at animation frame 1.0 (anim/ShortCutBG_00_In.bflan), AutoBuilder the sa (anim/AutoBuilder_00_In.bflan). UI animations advance 0.5 frames per game frame at 60 fps, so the capture lands after the world stopped drawing and the background can be black. The visibility keys move to frame 0.0: the live world is captured at once (upstream checked weapon, shield, material and ability wheel at 60 fps, and 30 fps). -The game-over flow fix of the same upstream script is 1.0.0 only (1.1.1, 1.2.1 and 1.4.3 run DmF_SY_GameOver.110) and is +The game-over flow fix of the same upstream script is 1.0.0 only (1.1.0, 1.2.1 and 1.4.3 run DmF_SY_GameOver.110) and is left out. --aspect x (a game resolution of another shape than 16:9, such as 3440x1440 or 1280x800) also lays the UI out @@ -53,7 +53,7 @@ from pathlib import Path root = Path(__file__).resolve().parents[1] ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) -ap.add_argument('--version', choices=('v111', 'v121', 'v143'), default='v121') +ap.add_argument('--version', choices=('v110', 'v121', 'v143'), default='v121') ap.add_argument('--romfs', type=Path, help='default build/extracted//romfs') ap.add_argument('--out', type=Path, help='default build//romfs-patches (romfs-patches-