# 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.2.1 (runtime/romfs.c, TOTK_ROMFS_PATCHES). UI/LayoutArchive/Common.Product.110.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 visible at animation frame 1.0 (anim/ShortCutBG_00_In.bflan), AutoBuilder the same with C_CaptureBG_00 (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.2.1 runs DmF_SY_GameOver.110) and is left out. Input: build/extracted/v121/romfs (romfs.bin and index.json, verified by tools/extract.py). Output: / and /manifest.tsv (path, size, SHA-256 of the overlay, SHA-256 of the original). Run with .venv-py314. """ import argparse import compression.zstd as zstd import hashlib import json import struct from pathlib import Path root = Path(__file__).resolve().parents[1] ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) ap.add_argument('--romfs', type=Path, default=root / 'build/extracted/v121/romfs') ap.add_argument('--out', type=Path, default=root / 'build/v121/romfs-patches') args = ap.parse_args() index = json.loads((args.romfs / 'index.json').read_text()) assert index['status'] == 'pass' files = {f['path']: f for f in index['files']} def sarc_members(data): """name -> (absolute start, end) of every SARC member.""" assert data[:4] == b'SARC' and data[6:8] == b'\xff\xfe' header, size, start = struct.unpack_from('