diff --git a/.github/release-games.json b/.github/release-games.json index ee94682..0f8e13c 100644 --- a/.github/release-games.json +++ b/.github/release-games.json @@ -10,6 +10,16 @@ "game_version": "1.2.1", "build_id": "FF773E90972D544EB79406EAA65396D53C43EFB9", "layout_count": 129 + }, + "botw": { + "folder": "the-legend-of-zelda-breath-of-the-wild", + "name": "The Legend of Zelda: Breath of the Wild", + "mod_folder": "Native 4x3 Aspect Ratio", + "zip_stem": "BOTW-4x3-Native", + "title_id": "01007EF00011E000", + "game_version": "1.6.0", + "build_id": "8E9978D50BDD20B4C8395A106C27FFDE", + "layout_count": 4 } } } diff --git a/AGENTS.md b/AGENTS.md index ca17908..6209097 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,7 +25,7 @@ scripts/check_repo.py Blocks game data, keys and decompiler dumps (pre- docs/DEVELOPMENT.md Dated log of how the mod got here ``` -Games: [`super-mario-bros-wonder/`](super-mario-bros-wonder/) (1.2.1). +Games: [`super-mario-bros-wonder/`](super-mario-bros-wonder/) (1.2.1), [`the-legend-of-zelda-breath-of-the-wild/`](the-legend-of-zelda-breath-of-the-wild/) (1.6.0). ## Rules @@ -48,7 +48,7 @@ Run before committing a mod change and before every release: ``` python scripts/check_repo.py # game data / keys / dumps (also the pre-commit hook) python scripts/release.py check # release rules: changelog, build ID, allowlist, archive count -# plus the game's own verifiers, listed in its AGENTS.md (SMBW: tools/verify.py and tools/verify_pchtxt.py) +# plus the game's own verifiers, listed in its AGENTS.md (SMBW: tools/verify.py and tools/verify_pchtxt.py; BotW: tools/verify.py) ``` No package manager, build system, linter or type checker: Python scripts run directly. `scripts/` needs only Python 3.8+ (CI uses the runner's 3.12). Game tools may need more (SMBW: Python 3.14 plus `capstone` and `lz4`). diff --git a/README.md b/README.md index dd379f0..e4f286f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Native 4:3 aspect-ratio mods for Nintendo Switch games. "Native" means the game | Game | Needs game version | Download | Install steps | | --- | --- | --- | --- | | Super Mario Bros. Wonder | 1.2.1 | [Download v1.2.0](https://github.com/PyroDonkey/switch-4x3-mods/releases/download/smbw-v1.2.0/SMBW-4x3-Native-v1.2.0-for-game-1.2.1.zip) | [Install](super-mario-bros-wonder/README.md#install) | +| The Legend of Zelda: Breath of the Wild | 1.6.0 | Coming soon | [Install](the-legend-of-zelda-breath-of-the-wild/README.md#install) | Tested on Switch emulators on Windows and Android (Retroid Pocket Nova). Each mod only works with the game version listed, so update your game first. To install, follow the install guide linked for your game in the table above; it also covers updating and troubleshooting. diff --git a/docs/aspect-ratio-guide.md b/docs/aspect-ratio-guide.md index 9bdfcc8..db63f6b 100644 --- a/docs/aspect-ratio-guide.md +++ b/docs/aspect-ratio-guide.md @@ -420,7 +420,11 @@ BOTW 1.6.0 (title ID 01007EF00011E000) on an Eden-family emulator at 4:3, built **An aspect patch alone is not a 4:3 mod.** With only the code patch, the 3D view is correct but the HUD is laid out for 1280×720 and stretched: the minimap measured about 152 px wide by 202 px tall at the same window height where 16:9 gives a 204 px circle. The layout work is what restores round gauges, undistorted icons and the menu fixes above. -**Game code reads scale on list containers.** In the pause menu, the Adventure Log → Memories list drew row 6 on top of row 5 at 4:3 only. The cause was the 0.75 root-child scale on one container (and the part it holds) whose scale the list code reads. Moving the 0.75 onto its child, or into the part's own layout, did not help; leaving that subtree at stock scale, position and size did. Page containers that the code rewrites still take the factor on their children, but a pane the list code reads has to stay stock, at the cost of that page not being squeezed. A check that the pane stays at stock guards it. +**Game code reads scale on list containers.** In the pause menu, the Adventure Log → Memories list drew row 6 on top of row 5 at 4:3 only. The cause was the 0.75 root-child scale on one container (and the part it holds) whose scale the list code reads. Moving the 0.75 onto its child, or into the part's own layout, did not help; leaving that subtree at stock scale, position and size did. Page containers that the code rewrites still take the factor on their children, but a pane the list code reads has to stay stock. A check that the pane stays at stock guards it. Leaving the page unsqueezed made its text 75% wide and cut long descriptions off, so the factor then went one level lower again: onto the direct root children of the page's part layouts (the detail panel and tabs, and the list's five row slots, whose spacing becomes 52.5 instead of 70). The list containers themselves stay stock, and the list scrolls correctly past row 5. When a container must stay stock, try the panes inside its parts before giving up on the squeeze. + +**Keep each capture source the same size as its use.** On the Sheikah map, the earlier fix grew the capture use panes (and the scissor) to the 4:3 height but left their sources at stock. The terrain then drew 1.33× too tall (grid cells 77.5 × 103 px instead of square) and drifted against the correctly placed names and icons whenever the map scrolled. Stock keeps every source and its use at the same size in every pose (720 for the full map, 192 for the mini-map); giving the sources the same 960 fixed it. This pair doesn't follow from the capture note above alone, so when a source/use pair is resized, resize both and check a square reference (a grid) in game. + +**Bounds boxes the code reads by name.** The map's "Link is off screen" bubble is clamped to, and only shown outside, a pane named `N_PosSize_00` sized to the 16:9 view minus a margin (1200 × 590). At 4:3 the view is 960 units tall, so the bubble appeared while Link was visible and sat on the wrong edge. Growing the box by the same 240 (margins kept) fixed it. Look for such size-only panes (often named `*Size*` or `*Area*`) whenever an element appears or disappears at the wrong distance from the screen edge. **Find in-game bugs by reverting layouts in halves.** When the cause is unknown, ship test mods that contain only the changed archive, with every layout in a group left at stock, and let the player test one at a time: all pause layouts stock, then half, then single layouts, then single panes. Each answer halves the search; this one took eight rounds. Keep the code patch fixed while testing, and give each test its own throwaway folder in the emulator's load directory, deleted afterwards. diff --git a/the-legend-of-zelda-breath-of-the-wild/AGENTS.md b/the-legend-of-zelda-breath-of-the-wild/AGENTS.md new file mode 100644 index 0000000..fa8d21e --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/AGENTS.md @@ -0,0 +1,70 @@ +# Agent instructions: The Legend of Zelda: Breath of the Wild 4:3 + +Read the root [`../AGENTS.md`](../AGENTS.md) first. This file is the **source of truth for the current state** of the BotW mod; [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md) is the dated log of how it got here (its values may be superseded). The general method is in [`../docs/aspect-ratio-guide.md`](../docs/aspect-ratio-guide.md); its "Second reference" section describes this mod. + +## Game and target + +- Title ID `01007EF00011E000`, **version 1.6.0 only**, build ID `8E9978D50BDD20B4C8395A106C27FFDE`. Tested with both DLC packs installed; without DLC is untested. +- Tested on Eden (yuzu family) on Windows with Graphics > Aspect Ratio > **Force 4:3**. Android and console are untested. +- Mod folder: `mod/Native 4x3 Aspect Ratio/` = `exefs/1.6.0.pchtxt` (exact 4/3, copied from `tools/hand-edited/exefs/1.6.0.pchtxt`) + `romfs/Layout/BootUp.sblarc`, `romfs/Layout/Horse.sblarc`, `romfs/Pack/Bootup.pack` (holds `Layout/Common.sblarc`, almost every UI layout), `romfs/Pack/Title.pack` + `README.txt` (no install steps, only the link to `README.md#install`). Named "Nova Aspect Ratio 4x3 Native" in the maintainer's earlier test builds and "Aspect Ratio 4x3 Native" briefly before v1.0.0; don't rename it again. +- Installed for testing at `%APPDATA%\eden\load\01007EF00011E000\`. Sync with the game closed: `robocopy "mod\Native 4x3 Aspect Ratio" "%APPDATA%\eden\load\01007EF00011E000\Native 4x3 Aspect Ratio" /MIR`. Make sure only one 4:3 folder is ticked in Eden's add-ons (older test folders contain the same archives). +- Releases: tag prefix `botw` (`.github/release-games.json`); procedure in the root AGENTS.md "Releasing". `layout_count` there is the number of files under `romfs/` (4). + +## Local inputs (outside the repo) + +| Input | Where it comes from | Used by | +| --- | --- | --- | +| romfs 1.6.0 (base + update merged) | `\dump\01007EF00011E000\romfs`, extracted from the maintainer's own base and v1.6.0 update NSPs. It contains the DLC-era layouts, so it is not the 1.0.0 base alone | `build.py`, `verify.py` | +| `exefs/main` 1.6.0 | `\work\exefs\main` (build ID above) | patch research; `mkpatch.py` (capstone) | + +## Build and verify + +Python 3.14; stdlib only for build and verify (`-I` is fine). `mkpatch.py` needs `capstone` (run without `-I`). + +``` +# : a new empty folder outside the repo, with Layout\ and Pack\ subfolders (the build does not create them) +python -I tools/build.py "/dump/01007EF00011E000/romfs" +# verify check 20 compares the HUD enlargement against a build with it off: +BOTW_HUD_SCALE=1.0 python -I tools/build.py "/dump/01007EF00011E000/romfs" +BOTW_HUD_BASE= python -I tools/verify.py "/dump/01007EF00011E000/romfs" # must print FAILS: 0 +# then copy the 4 archives from into mod/Native 4x3 Aspect Ratio/romfs/ (not build_report.json), and +# tools/hand-edited/exefs/1.6.0.pchtxt into its exefs/ +python scripts/check_repo.py +python scripts/release.py check botw +``` + +Environment switches (defaults are the shipped build): `BOTW_ROOT_MODE=children|root`, `BOTW_HUD_SCALE` (1.3333333; 1.0 = off), `BOTW_CURSOR_KEEP` (`Cursor_00`), `BOTW_GANBARI_FIX` (1; 0 = stamina wheel fix off). verify.py reads `build_report.json` from ``, so verify the build folder, not the mod folder. + +## Current state (2026-11-10, v1.0.0 prepared, not released) + +Code patch: `exefs/1.6.0.pchtxt` replaces the three aspect instructions used by the community 1.6.0 patch (`0x00E0AD68`, `0x015C2148`, `0x01271870`) with `LDR S0` of a literal `3FAAAAAB` (4/3) planted in zero padding after a nearby `ret`. Played and checked. + +Layouts (children mode: RootPane untouched because the game overwrites its scale; each direct child of RootPane gets ScaleY and TransY x0.75; panes the code rescales by name, `CODE_SCALE_PANES`, take the factor on their children): + +| Area | Rule (curated.py) | Status | +| --- | --- | --- | +| Edge shifts, fills, Title art and glow, loading screens, PauseMenuBG bands | rounds 1-3 | played and checked | +| D-pad icon list edge masks | `CAPTURE_APPLY_INVARIANT`, `SRC_H_SCALE` | played and checked | +| Menu cursor corners | `CURSOR_ROOT_KEEP` (Cursor_00 stock) | played and checked | +| System message pill end caps | `FORCE_SHIFT` MessageSp_00, `SHIFT_FOLLOW` | played and checked | +| HUD at 16:9 size | `HUD_SCALE`, `HUD_PANES` | played and checked | +| Adventure Log page | `NO_SCALE_SUBTREES` N_InOutQuest_02 stock; `PART_SQUASH_Y` (PaPauseQuest_00 panel and tabs, PaPageChallenge5_00 row slots) | played and checked (quest list, description, Memories past row 5); long-list scroll, CLEAR stamp, Memories pictures not yet | +| Sheikah map terrain | `SIZEH_RETARGET` AppMap_00 incl. capture sources N_Capture_00-04 (`MAP_CAPTURE_PAIRS`) | played and checked (grid square, names on terrain) | +| Map player locator | `PART_GROW_H` PaMapPlayer_00 N_PosSize_00 590 -> 830 | played and checked | +| Stamina wheel | `PART_SY` (squash inside the part), `HOST_SY_FACTOR` | played and checked (combined build) | +| Speaker name plate | `FORCE_SHIFT` Message_00 N_NameS_00 + N_Capture_00 | played and checked (combined build) | + +The combined build (all rows above, the v1.0.0 mod folder) was played and checked on 2026-11-10: stamina wheel, name plate, Adventure Log and map. + +Not yet played: shrine/Divine Beast maps (`AppMapDungeon_00` has the same capture-source/use pattern as the world map and may show the same terrain stretch), tool screen, end credits, a missing menu arrow noted in an early round (cause unknown). + +verify.py checks: 0 (no unchanged or stray archive in the output), 1-2 (structure, every changed byte logged), 4-10 (rules re-derived from the originals), 11 (capture use sizes), 12 (Cursor_00 byte-identical), 13-17 (rounds 2-5), 18-19 (pause page containers, Adventure Log subtree stock), 20 (HUD enlargement vs `BOTW_HUD_BASE`), 21 (stamina wheel), 22 (Adventure Log squash). + +## Gotchas + +- **The game overwrites RootPane scale** (and the scale of panes named in `CODE_SCALE_PANES`), so a root-scale mod is lost at run time. That is why children mode exists. +- **Code reads some pane sizes and scales by name.** The Adventure Log list breaks if its containers (`N_InOutQuest_02`, `Pa_Quest_00`, `N_Cut_00`) are scaled; the map locator clamps to `N_PosSize_00`'s size; the stamina wheel hosts get their ScaleX/ScaleY overwritten by code. Squash below such panes, or grow the box, instead of scaling them. +- **Map captures: keep each source the same size as its use.** Stock keeps them equal in every pose (720 full map, 192 mini-map). With only the uses at 960 the terrain was 1.33x too tall and drifted against names and icons; matching the sources fixed it in game. The guide's capture model (a plain source copies its local size) does not by itself explain this pair; the equal-size rule is what was tested. +- **Bootup.pack is the whole pack** (fonts and other data with it); LayeredFS replaces whole files, which the game-files policy allows for changed archives. Never ship an archive the build did not change (verify check 0). +- **Eden locks layout files while a game runs**, and code patches load only at boot: close the game before syncing. Eden tracks add-ons by folder name, so after a rename tick the new folder and untick old ones. +- The optional map-view exefs patch (`map_view_960`, 720 -> 960 view height at `0x1AFE4`) from round 3 was never enabled or needed; it is not shipped. diff --git a/the-legend-of-zelda-breath-of-the-wild/CHANGELOG.md b/the-legend-of-zelda-breath-of-the-wild/CHANGELOG.md new file mode 100644 index 0000000..f3da587 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/CHANGELOG.md @@ -0,0 +1,16 @@ +# Changelog: The Legend of Zelda: Breath of the Wild 4:3 + +Newest first. Each release's section becomes its GitHub release notes. + +## v1.0.0 + +For game v1.6.0. + +First release. + +- The 3D view renders at exactly 4:3. +- HUD, menus, loading screens, title screen, dialog boxes and the Sheikah Slate map are re-laid out for the 4:3 screen: elements sit at the real screen edges, full-screen layers cover the whole screen, and nothing is stretched. +- The gameplay HUD (hearts, Divine Beast gauges, weapon and shield icons, sensor, noise meter, temperature and clock) is shown at the same size as on 16:9, and the stamina wheel keeps its round shape. +- Adventure Log: quest text, the quest list and Memories have the correct shape, and long quest descriptions are no longer cut off. +- Map: terrain, place names and icons stay lined up while you move and zoom, and the marker pointing to Link only appears when he is off screen. +- The speaker's name plate sits on its dialog box. diff --git a/the-legend-of-zelda-breath-of-the-wild/CLAUDE.md b/the-legend-of-zelda-breath-of-the-wild/CLAUDE.md new file mode 100644 index 0000000..43c994c --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/the-legend-of-zelda-breath-of-the-wild/README.md b/the-legend-of-zelda-breath-of-the-wild/README.md new file mode 100644 index 0000000..8365cf3 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/README.md @@ -0,0 +1,87 @@ +# The Legend of Zelda: Breath of the Wild: Native 4:3 + +[![Support me on Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/pyrodonkey) + +Plays Breath of the Wild natively at 4:3 instead of stretching or letterboxing it. The 3D view renders at 4:3, and the HUD, menus and Sheikah Slate map are re-laid out for the taller screen so nothing is squashed. + + + +Requires **game version 1.6.0**. Tested on Switch emulators on Windows, with both DLC packs installed. Other versions of the game are not supported. + +## Install + +This is the install guide for this mod; the release page, the `README.txt` in the zip and the main page all link here. The menu names below are the ones used by the emulators this was tested on; other emulators may label them differently. + +### Before you start + +1. **Check your game version.** The game must be updated to **v1.6.0**. Your emulator shows the installed update in the game list (often an Add-ons or Version column) or in the game's properties. Other versions get a squashed 3D picture. +2. **Turn off other aspect-ratio mods** for this game (for example an ultrawide or 21:9 mod, or another 4:3 patch). Two of them at once conflict. +3. **Remove older versions of this mod**, including test builds named "Nova Aspect Ratio 4x3 Native" or "Aspect Ratio 4x3 Native". A different folder name counts as a separate mod, and old files left behind can override new ones. +4. **Close the game** before installing; mod files are only read when the game starts. +5. On the release page, download the `.zip` under **Assets**, not "Source code" (that's the whole repo). + +### Windows + +1. Right-click The Legend of Zelda: Breath of the Wild > **Configure Game** > **Add-Ons** > **Import Mod from ZIP**, pick the downloaded zip and confirm. +2. Make sure **Native 4x3 Aspect Ratio** is ticked in the Add-Ons list. +3. In the same Configure Game window, go to **Graphics** > Aspect Ratio and choose **Force 4:3**. This changes only this game. +4. Start the game. + +- **No "Import Mod from ZIP" button?** Right-click the game > **Open Mod Data Location**, open the zip, and drag the **Native 4x3 Aspect Ratio** folder into that window. +- **Updating:** remove the old version from Add-Ons first, then import the new zip. + +### Android + +1. Extract the zip with your file manager. +2. Long-press The Legend of Zelda: Breath of the Wild > **Add-ons** > **Install**. Open the extracted files and select the **Native 4x3 Aspect Ratio** folder itself (the one with `exefs` and `romfs` inside), then tap **Use this folder** and **Allow**. +3. Make sure the add-on is ticked. +4. In this game's own settings, set the aspect ratio to **4:3**. +5. Start the game. + +- **Updating:** uninstall the old version in Add-ons first, then install the new folder. + +### Troubleshooting + +| What you see | Fix | +| --- | --- | +| 3D looks tall and thin, UI looks fine | Wrong game version: update the game to v1.6.0 | +| Nothing changed | The add-on is unticked, the wrong folder was picked (Android: pick the folder that contains `exefs` and `romfs`), or the game was running during install | +| Everything is still stretched, or black bars at the sides | The game's aspect ratio isn't set to 4:3 | +| Parts of the screen look wrong in a way that changes with another mod on | Another aspect-ratio mod is still enabled: turn it off | + +Still stuck? [Open an issue](https://github.com/PyroDonkey/switch-4x3-mods/issues/new/choose) with your game version, device and a screenshot. + +## What it changes + +**`exefs/1.6.0.pchtxt`**: the 3D aspect ratio, 16:9 to exactly 4:3. + +**`romfs/Pack/Bootup.pack`, `romfs/Pack/Title.pack`, `romfs/Layout/BootUp.sblarc`, `romfs/Layout/Horse.sblarc`**: the game's UI layouts, re-laid out for 4:3. These archives hold many screens each, so the whole archive is replaced; everything else comes from the game. + +- HUD and menu elements sit at the real 4:3 screen edges, and full-screen layers (backgrounds, fades, the Sheikah Slate frame) cover the taller screen. +- Gameplay HUD pieces are shown at their 16:9 size: hearts, Divine Beast gauges, weapon and shield icons, sensor, noise meter, temperature and clock. The stamina wheel stays round. +- Adventure Log: quest text, the quest list and Memories have the correct shape. +- Sheikah Slate map: the terrain, place names and icons line up, and the marker pointing to Link appears only when he is off screen. +- Dialog boxes: the speaker's name plate sits on the box. + +## Known limits + +- Played and checked: D-pad weapon windows, menu cursors, Link in the inventory, pause-menu bars, loading screens, title screen art, the HUD at 16:9 size, the stamina wheel, the speaker's name plate on dialog boxes, Adventure Log (quest list, full quest descriptions, Memories list past the fifth row), and the Sheikah Slate map (terrain, place names, icons and the marker pointing to Link). +- Not yet played: scrolling far down a long quest list, a completed quest's CLEAR stamp, Memories preview pictures, shrine and Divine Beast maps, and the end credits. +- Some HUD pieces are drawn by the game's code rather than its layouts and keep their stock 4:3 size, for example the minimap circle. +- Please open an issue if something looks stretched, squashed or cut off. + +## Credits + +- Aspect-ratio instruction addresses from the community 1.6.0 aspect-ratio patch. +- Exact 4:3 code patch and UI layouts by PyroDonkey, from analysis of the 1.6.0 executable and layouts. + +## For developers + +| | | +| --- | --- | +| Title ID | `01007EF00011E000` | +| Build ID (1.6.0) | `8E9978D50BDD20B4C8395A106C27FFDE` | +| Mod folder | [`mod/Native 4x3 Aspect Ratio/`](mod/Native%204x3%20Aspect%20Ratio/) | +| Changelog | [`CHANGELOG.md`](CHANGELOG.md) | + +The mod folder is generated by the scripts in [`tools/`](tools/) from the original layouts, which you must dump from your own copy of the game. See [`AGENTS.md`](AGENTS.md) for build and verify commands, the current state and the gotchas, and [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md) for how each fix was found. diff --git a/the-legend-of-zelda-breath-of-the-wild/docs/DEVELOPMENT.md b/the-legend-of-zelda-breath-of-the-wild/docs/DEVELOPMENT.md new file mode 100644 index 0000000..67dfd2a --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/docs/DEVELOPMENT.md @@ -0,0 +1,41 @@ +# Development log: The Legend of Zelda: Breath of the Wild 4:3 + +Dated log of how the mod got to its current state, kept for the reasoning behind each fix. **The current state is in [`../AGENTS.md`](../AGENTS.md)**; values here may be superseded by later sections. "Played and checked" means the tester confirmed it in game. Build snapshots named here (`previous_romfs_vN`, `installed_eden_backup_*`) are in the maintainer's workspace `extras` folder, not in the repo. + +## Rounds 1-8 (2026-10, before the repo folder existed) + +Built in the maintainer's workspace from the 1.6.0 originals, over several rounds of in-game feedback. The mod started as the maintainer's own "Nova Aspect Ratio 4x3 Native" (original copy kept in the workspace as `ORIGINAL_Nova Aspect Ratio 4x3 Native`). + +- **Children mode.** The game overwrites RootPane's scale at run time, so a root scale of 0.75 in the BFLYT is lost. The build leaves RootPane alone and gives each direct child ScaleY and TransY x0.75 (static and animation keys). Panes the code rescales by name (`CODE_SCALE_PANES`) keep their own scale; the factor goes on their children and their SizeH. `BOTW_ROOT_MODE=root` still builds the old variant. +- **Capture policy `fullframe`.** Framebuffer-copy sources keep their stock size; every FBLayout use pane keeps its stock projected size (local h = stock h / 0.75^n, n = 0.75-scaled panes in its chain). verify check 11. +- **Cursor_00** stays byte-identical to stock: the game builds the corner frame from the target's already-compressed rect, so a 0.75 on the cursor compressed it twice. verify check 12. +- **Round 2:** `UNIFORM_GROW` (Title wallpaper, DLC art), `EDGE_GROW` (PauseMenuBG band rings +240), PaFadeBar_00/Fade_00 corner shifts, tip-text font height x0.75 (`TXT_FONT_Y_LAYOUTS`). Checks 13/14. +- **Round 3:** `LEAF_TY`/`UNIFORM_TY_GROW` (Title art), `CAPTURE_BG_FULLFRAME` (Title glow), `SIZEH_RETARGET` for the Sheikah map scissor and capture uses (the 0.75 chain would clip the map to the middle 540 of 720). An optional exefs patch raising the map code's view height 720 -> 960 was written and left disabled; it was never needed. Check 15. +- **Round 4:** `CAPTURE_APPLY_INVARIANT` (D-pad icon list edge masks, MainShortCut_00 N_Capture_00/01: h x0.75, ScaleY / 0.75^n, correct whether the engine's CaptureApplyScale flag is on or off), `SRC_H_SCALE` (N_DmcCapture_00). Check 16. +- **Round 5:** `FORCE_SHIFT` MessageSp_00 N_SunLight_00 (arc end caps of the system message pill), `SHIFT_FOLLOW`. Check 17. +- **Round 6:** N_Slide_00/01/02 added to `CODE_SCALE_PANES` (pause-menu page containers). Kept, but it was not the Memories fix. Check 18. +- **Round 7:** Adventure Log > Memories drew rows #6 and later on top of #5. Found by an in-game bisect with pack-only test builds (layouts reverted to stock one group at a time): only `PauseMenu_00/N_InOutQuest_02` at stock was clean; pushing its 0.75 to `Pa_Quest_00` or to all root children of `PaPauseQuest_00` stayed broken. `NO_SCALE_SUBTREES` leaves that subtree at stock. Resolution scale, post-processing and the shader cache were ruled out. Check 19. The code patch became the exact-4/3 variant in the same round. +- **Round 8:** HUD enlargement (`HUD_SCALE` 4/3, `HUD_PANES`): hearts, Divine Beast gauges and weapon/shield icons about the top-left corner; sensor, noise meter, temperature and clock about the bottom-right; static values and TransX/TransY/Scale keys. Restores the 16:9 pixel size (the UI was 75% of it). Check 20 compares against a build with `BOTW_HUD_SCALE=1.0`. Not enlarged: D-pad window (captures), stamina wheel, message and banner text, minimap circle (code-drawn), MainScreenMS/HeartIchigekiDLC hearts, Time_00. + +## Stamina wheel and speaker name plate (2026-11-10, earlier session) + +Developed in the workspace copy of the tools after the repo copy was taken, and found in the maintainer's Eden install; merged into the repo tools later the same day (the six affected layouts are byte-identical to that install). + +- **Stamina wheel:** the code (writes at `0x117c8e8` / `0x117cf24`) overwrites both ScaleX and ScaleY of the hosts `Pa_Ganbari_00` / `Pa_GanbariEx_00` with one distance-based value, so a 0.75 on the host's ScaleY was lost and the wheel was drawn stretched. The squash moved into the parts (`PART_SY`: PaGanbariGauge_01 N_All_00, PaGanbariGaugeEx_00 N_AllL/R_00/01), and the hosts' ScaleY is compensated so every chain nets 0.75 (`HOST_SY_FACTOR`, MainScreen3D_00 and PauseMenuInfo_00). Check 21. +- **Speaker name plate:** Message_00 `N_NameS_00` (y -174, under the edge threshold) stayed about 75 units above the edge-shifted dialog box; it and its capture source `N_Capture_00` are now force-shifted with the box. + +## Round 9: Adventure Log aspect (2026-11-10) + +Tester report: quest menu text looked squished. Round 7 left the page at stock height while the game squeezes width to 0.75, so its text and art were 75% wide. Measured in a screenshot: quest text about 0.42 glyph height per character against 0.59 for evenly scaled text ("Back"), ratio 0.71. Long quest descriptions were also cut off mid-word. + +The 0.75 now goes one level below the panes round 7 ruled out, on direct RootPane children of the page's parts (`PART_SQUASH_Y`). Three variants were built for an in-game test: A (detail panel only), B (A + category tabs + the five list row slots of PaPageChallenge5_00, row pitch 70 -> 52.5), C (A + each row's contents, pitch kept). B was tested first and was clean: quest list and full description correct, Memories rows #6 and #7 below #5. `N_InOutQuest_02`, `Pa_Quest_00`, `N_Cut_00` (list container), `Null_00` (full-height art) and `Null_01` (full-frame mask) stay stock. Check 22. + +## Round 10: Sheikah map (2026-11-10) + +**Terrain stretch.** Tester report: place names didn't move correctly with the map. In a screenshot the map grid cells measured 77.5 x 103 px, but they are square in stock: the terrain and grid were 1.33x too tall while names and icons were correct, so they drifted apart when panning. Stock keeps each map capture source and its use the same size in every pose (`AppMap_00_MiniMap`: 720 full map, 192 mini-map). Round 3 retargeted the uses (and the scissor) to 960 but kept the sources N_Capture_00-04 at 720; giving the sources the same 960 fixed it. Played and checked against a stock 16:9 screenshot: grid cells square (311 x 310 px), names on their terrain. The guide's capture note (a plain source copies a rectangle of its local size) does not by itself predict this; the tested rule is "source = use". + +**Player locator.** Tester report: the bubble pointing to Link sat on the map edge and appeared at the wrong times. The bubble is `PaMapPlayer_00` (`Pa_PlayerNavi_00`): shown when Link is off screen, clamped to the box `N_PosSize_00` (1200 x 590, the 720 view minus 65 per edge), pointing at him. In stock and modded screenshots with the map scrolled differently, the bubble stayed at the same screen spot (about 237 units above centre), i.e. pinned to the stock box's top edge, while in 4:3 Link's own icon was visible above it. The code reads `N_PosSize_00` by name; growing it by 240 to 830 (`PART_GROW_H`, margins kept) fixed it. Played and checked. + +## Repo setup (2026-11-10) + +Mod folder renamed to "Native 4x3 Aspect Ratio" (same as SMBW); the unused optional map-view patch dropped; the shipped code patch moved to `tools/hand-edited/exefs/1.6.0.pchtxt` (`mkpatch.py` emits a different cave-based variant that never shipped). verify check 0 added: no archive identical to the original and nothing else in the output folder. The combined build (earlier-session fixes plus rounds 9 and 10) was installed as "Native 4x3 Aspect Ratio" and played and checked: stamina wheel, speaker name plate, Adventure Log and map. diff --git a/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/README.txt b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/README.txt new file mode 100644 index 0000000..0339b58 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/README.txt @@ -0,0 +1,16 @@ +Native 4x3 Aspect Ratio +The Legend of Zelda: Breath of the Wild, game version 1.6.0 only + +Plays the game natively at 4:3 instead of stretching or letterboxing it. The +3D view renders at 4:3 and the HUD, menus and map are re-laid out for the +taller screen so nothing is squashed. + +How to install, update and troubleshoot (please follow this guide): +https://github.com/PyroDonkey/switch-4x3-mods/blob/main/the-legend-of-zelda-breath-of-the-wild/README.md#install + +Contents of this folder: +- exefs/1.6.0.pchtxt aspect ratio 16:9 -> exactly 4:3 +- romfs/Layout/*, romfs/Pack/* + the UI archives the mod changes; the rest come from the game + +By PyroDonkey. diff --git a/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/exefs/1.6.0.pchtxt b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/exefs/1.6.0.pchtxt new file mode 100644 index 0000000..ec505be --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/exefs/1.6.0.pchtxt @@ -0,0 +1,21 @@ +@nsobid-8E9978D50BDD20B4C8395A106C27FFDE + +@flag print_values +@flag offset_shift 0x100 + +// Native 4x3 Aspect Ratio: 3D aspect ratio 16:9 -> exactly 4:3 (BOTW 1.6.0 only). +// Replaces the three aspect instructions used by the community 1.6.0 aspect patch (which writes fmov s0,#1.3125, 1.56% +// under 4/3) with LDR S0 of the exact float 4/3 = 3FAAAAAB, planted in zero padding after nearby RET instructions. +// Do NOT enable together with another BOTW aspect patch: they patch the same three addresses. + +@enabled +// 0x00E0AD68 was fdiv s0,s0,s1 -> ldr s0,#+0x104C (literal at 0xE0BDB4) +00E0AD68 6082001C +00E0BDB4 ABAAAA3F +// 0x015C2148 was fdiv s0,s0,s1 -> ldr s0,#+0xF0 (literal at 0x15C2238) +015C2148 8007001C +015C2238 ABAAAA3F +// 0x01271870 was ldr s0,[x0,#0xb0] -> ldr s0,#+8 (literal at 0x1271878, right after the ret) +01271870 4000001C +01271878 ABAAAA3F +@stop diff --git a/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Layout/BootUp.sblarc b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Layout/BootUp.sblarc new file mode 100644 index 0000000..da0235e Binary files /dev/null and b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Layout/BootUp.sblarc differ diff --git a/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Layout/Horse.sblarc b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Layout/Horse.sblarc new file mode 100644 index 0000000..7b90b9b Binary files /dev/null and b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Layout/Horse.sblarc differ diff --git a/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Pack/Bootup.pack b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Pack/Bootup.pack new file mode 100644 index 0000000..ac97cb5 Binary files /dev/null and b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Pack/Bootup.pack differ diff --git a/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Pack/Title.pack b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Pack/Title.pack new file mode 100644 index 0000000..3668870 Binary files /dev/null and b/the-legend-of-zelda-breath-of-the-wild/mod/Native 4x3 Aspect Ratio/romfs/Pack/Title.pack differ diff --git a/the-legend-of-zelda-breath-of-the-wild/tools/README.txt b/the-legend-of-zelda-breath-of-the-wild/tools/README.txt new file mode 100644 index 0000000..d5780dc --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/tools/README.txt @@ -0,0 +1,16 @@ +BOTW 4:3 native UI build tools + +Build : python -I tools/build.py "/01007EF00011E000/romfs" +Verify: python -I tools/verify.py "/01007EF00011E000/romfs" (must print FAILS: 0) + + must be an empty folder outside the repo with Layout/ and Pack/ subfolders; the build writes only the archives it +changes plus build_report.json (verify reads it). Full command list, environment variables and the copy step into +mod/: see ../AGENTS.md. History of each rule: ../docs/DEVELOPMENT.md. + +build.py applies the rules to the original layouts (float overwrites in place; SARC/Yaz0 rebuilt) +curated.py every per-layout decision (the only file most fixes touch) +rules.py shared geometry (1280x720 layouts, 4:3: factor 0.75, visible half-height 480, edge shift 120) +lyt.py SARC / Yaz0 / BFLYT / BFLAN reader that records byte offsets +verify.py re-derives every rule from the originals and checks the output (checks 0-22) +mkpatch.py emits a cave-based exact-4:3 patch; NOT what ships (the shipped patch is hand-edited/exefs/1.6.0.pchtxt) +hand-edited/exefs/1.6.0.pchtxt the shipped code patch, copied into the mod folder as is diff --git a/the-legend-of-zelda-breath-of-the-wild/tools/build.py b/the-legend-of-zelda-breath-of-the-wild/tools/build.py new file mode 100644 index 0000000..d360b24 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/tools/build.py @@ -0,0 +1,921 @@ +"""Build a native-looking 4:3 layout set for BOTW 1.6.0 from the ORIGINAL layouts. + +usage: python -I build.py [--no-compress] + +Writes /Layout/*.sblarc, /Pack/Bootup.pack, Title.pack (only the archives that changed) +and /build_report.json. Every change is a float overwrite in place (no pane/size is added), so only +the Yaz0 stream sizes change; SARC containers are rebuilt with the original order and alignment. +""" +import sys, os, struct, re, json, collections +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from rules import * +import curated as C + +SRC, OUT = sys.argv[1], sys.argv[2] +COMPRESS = '--no-compress' not in sys.argv + +CONTAINERS = {'pan1', 'scr1', 'ali1'} + + +class Writer: + def __init__(self, buf): + self.buf = buf + self.log = [] + + def f32(self, off, val, what): + old = struct.unpack_from(' skip.""" + if p.name in ty_keys: + notes.append(f'WARN {why} {p.name}: TransY animation present, skipped') + return False + vo = vert_origin(p) + W.f32(p.off + Pane.H, p.h * factor, f'{why}-h {lname}/{p.name}') + if vo: + grow = (p.h * factor - p.h) / 2 * p.sy + W.f32(p.off + Pane.TY, p.ty + (grow if vo == 1 else -grow), f'{why}-recentre {lname}/{p.name}') + if uniform: + W.f32(p.off + Pane.W, p.w * factor, f'{why}-w {lname}/{p.name}') + for an, keys in szh_keys.get(p.name, []): + for k in keys: + W.f32(k.off + 4, k.value * factor, f'{why}-hanim {lname}/{p.name} {an}') + W.f32(k.off + 8, k.slope * factor, f'{why}-hanim-slope {lname}/{p.name} {an}') + return True + + +def find_capture_source(root, use): + """The pan1 'Capture' source whose rect equals a FBLayout use pane's rect (same centre and size), growable + in height: no TransY animation is checked by the caller; children must not hang off its top/bottom edge.""" + for s in root.walk(): + if s.kind != 'pan1' or 'Capture' not in s.name or s is use: + continue + if (abs(s.ax - use.ax) <= 2 and abs(s.ay - use.ay) <= 2 and abs(s.aw - use.aw) <= 2 and abs(s.ah - use.ah) <= 2 + and abs(s.h - use.h) <= 2 and not any(parent_vert_origin(c) for c in s.children)): + return s + return None +def last_key_shift(W, lname, name, dy, ty_keys, notes, why='lastkey'): + """Shift the FINAL pose of every TransY curve of `name` (>= 2 keys) by dy and keep the hermite + start slope linear (slope += dy / frame span). Single-key curves (constant overrides) and the + static pane position are untouched.""" + n = 0 + for an, keys in ty_keys.get(name, []): + if len(keys) < 2: + continue + kl, kp = keys[-1], keys[-2] + W.f32(kl.off + 4, kl.value + dy, f'{why} {lname}/{name} {an}') + df = kl.frame - kp.frame + if df > 0 and kp.slope is not None: + W.f32(kp.off + 8, kp.slope + dy / df, f'{why}-slope {lname}/{name} {an}') + n += 1 + if n: + notes.append(f'{why} {name:<26} final TransY pose {dy:+.0f} ({n} curve(s))') + return n + + +def scale_ty(W, lname, p, factor, ty_keys, notes): + """Scale a pane's TransY (static value and every key + slope) by factor (centre-origin panes).""" + W.f32(p.off + Pane.TY, p.ty * factor, f'ty-scale {lname}/{p.name}') + for an, keys in ty_keys.get(p.name, []): + for k in keys: + W.f32(k.off + 4, k.value * factor, f'ty-scale-anim {lname}/{p.name} {an}') + if k.slope is not None: + W.f32(k.off + 8, k.slope * factor, f'ty-scale-slope {lname}/{p.name} {an}') + notes.append(f'ty-scale {p.name:<26} x{factor:.4f}') + + +# --------------------------------------------------------------------------------------------------------- +# fullframe capture policy (children mode). See curated.CAPTURE_POLICY. +def _visited(p): + """children_pass visits this pane (same rule as verify.tl).""" + if p.parent is None or p.name in C.NO_SCALE_NAMES: + return False + if p.parent.parent is None: + return True + q = p.parent + return q.name in C.CODE_SCALE_PANES and q.rot == (0.0, 0.0, 0.0) and _visited(q) + + +def _scaled(p): + """the pane receives the 0.75 factor on its own ScaleY in children mode""" + return _visited(p) and p.name not in C.CODE_SCALE_PANES and p.rot == (0.0, 0.0, 0.0) + + +def n_scaled_chain(p): + n = 0 + while p is not None and p.parent is not None: + n += _scaled(p) + p = p.parent + return n + + +def fb_pairs(lname, raw, s, root): + """(use, [sources]) pairs of framebuffer-copy captures in a top-level layout, on the STOCK tree (annotate(root) + must have run): use = pic1 with an FBLayout texture, source = pan1 'Capture' pane on the same rect. Text-glow + captures (CaptureBGColor), CaptureApplyScale sources, map windows and code-sized slide seams are not framebuffer + copies of the plain kind and are left alone.""" + if C.CAPTURE_POLICY != 'fullframe' or C.ROOT_MODE != 'children' or lname in C.CAPTURE_SKIP_LAYOUTS: + return [] + mats = materials(raw, s) + out = [] + for u in root.walk(): + if u.kind != 'pic1' or u.name.startswith(C.CAPTURE_SKIP_PREFIX): + continue + mi = struct.unpack_from(' {target:.0f}') + return True + + +def capture_pass(lname, raw, ents, buf, W): + s, e = ents['blyt/' + lname + '.bflyt'] + lw, lh, root = parse_flyt(raw, s) + annotate(root) + notes = [] + pairs = fb_pairs(lname, raw, s, root) + if not pairs: + return notes + szh = collections.defaultdict(list) + for an in layout_anims(ents, lname): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(raw, ents[an][0]): + if not is_mat and target == 9: + szh[pane].append((an, ks)) + for u, cs in pairs: + n = n_scaled_chain(u) + retarget_h(W, lname, u, u.h / (ROOT_SY ** n), szh, notes, f'capture-use(n={n}, src {cs[0].name})') + return notes + + +def host_scale_counts(raw, ents, part): + """{n} over every use site of `part` in this archive's top-level layouts: n = 0.75-scaled panes in the prt1's chain.""" + counts = set() + for nm in ents: + if not nm.endswith('.bflyt'): + continue + ln = nm[5:-6] + if ln == part or ln in C.ROOT_SKIP: + continue + s = ents[nm][0] + lw, lh, root = parse_flyt(raw, s) + if (lw, lh) != (1280.0, 720.0): + continue + panes = [q for q in root.walk() if q.kind == 'prt1'] + secs = [p for m, p, z in flyt_tags(raw, s, {b'prt1'})] + if len(panes) != len(secs): + continue + for q, p in zip(panes, secs): + if prt1_name(raw, p) == part: + counts.add(n_scaled_chain(q)) + return counts + + +def build_part(lname, raw, ents, buf, W, root): + """Curated fills/shifts for a referenced part layout. Root stays (1, 1); safety for the fill + geometry (all prt1 uses at scale (1, 1), part content centred on screen) is enforced in verify.py.""" + fills = C.PART_FILL.get(lname, {}) + shifts = C.PART_SHIFT.get(lname, set()) + exact = C.PART_EXACT_H.get(lname, {}) + shift_y = C.PART_SHIFT_Y.get(lname, {}) + ty_scale = C.PART_TY_SCALE.get(lname, {}) + cap_use = C.PART_CAPTURE_USE.get(lname, []) if (C.CAPTURE_POLICY == 'fullframe' and C.ROOT_MODE == 'children') else [] + squash = C.PART_SQUASH_Y.get(lname, set()) + grow_h = C.PART_GROW_H.get(lname, {}) + part_sy = C.PART_SY.get(lname, set()) if C.ROOT_MODE == 'children' else set() + if not (fills or shifts or exact or shift_y or ty_scale or cap_use or squash or grow_h or part_sy): + return [] + notes = [] + annotate(root) + ty_keys = collections.defaultdict(list) + szh_keys = collections.defaultdict(list) + sy_keys = collections.defaultdict(list) + for an in layout_anims(ents, lname): + for pane, is_mat, tmag, target, ctype, keys in parse_flan(raw, ents[an][0]): + if is_mat: + continue + if target == 1: + ty_keys[pane].append((an, keys)) + elif target == 7: + sy_keys[pane].append((an, keys)) + elif target == 9: + szh_keys[pane].append((an, keys)) + # round 9: squash direct RootPane children of the part by ROOT_SY about the part centre (ScaleY and TransY, + # static + keys). Only centre-attached, unrotated panes; anything else is reported and left alone. + for p in root.children: + if p.name not in squash: + continue + if parent_vert_origin(p) or p.rot != (0.0, 0.0, 0.0): + notes.append(f'WARN part-squash {p.name}: edge-attached or rotated, left alone') + continue + W.f32(p.off + Pane.SY, p.sy * ROOT_SY, f'part-squash-sy {lname}/{p.name}') + W.f32(p.off + Pane.TY, p.ty * ROOT_SY, f'part-squash-ty {lname}/{p.name}') + for kd, what in ((ty_keys, 'ty'), (sy_keys, 'sy')): + for an, keys in kd.get(p.name, []): + for k in keys: + if k.slope is None: + notes.append(f'WARN part-squash {p.name}: step curve in {an}, left alone') + continue + W.f32(k.off + 4, k.value * ROOT_SY, f'part-squash-{what}-anim {lname}/{p.name} {an}') + W.f32(k.off + 8, k.slope * ROOT_SY, f'part-squash-{what}-slope {lname}/{p.name} {an}') + notes.append(f'part-squash {p.name:<26} ScaleY {p.sy:.3f} -> {p.sy * ROOT_SY:.3f}, TransY {p.ty:.1f} -> {p.ty * ROOT_SY:.1f}') + missing = squash - {p.name for p in root.children} + if missing: + notes.append(f'WARN part-squash panes not direct RootPane children: {sorted(missing)}') + done = set() + if cap_use: + ns = host_scale_counts(raw, ents, lname) + if len(ns) != 1: + notes.append(f'WARN part capture {lname}: use sites disagree / not found (n={sorted(ns)}), panes left alone') + else: + n = ns.pop() + for p in root.walk(): + if p.name in cap_use: + retarget_h(W, lname, p, p.h / (ROOT_SY ** n), szh_keys, notes, f'part-capture-use(n={n})') + done.update(cap_use) + for p in root.walk(): + if p.name in fills: + mode = fills[p.name] + factor = (C.PART_FILL_H.get(lname, 2 * HALF_VIS) / p.h) if mode in 'HU' else K + if grow_fill(W, lname, p, factor, mode in 'uU', szh_keys, ty_keys, notes, 'part-fill'): + done.add(p.name) + notes.append(f'part-fill {p.name:<26} h {p.h:.0f} -> {p.h * factor:.0f} ({mode})') + elif p.name in shifts: + sign = 1 if p.ay > 0 else -1 + d_local = sign * DELTA / p.parent_sy + W.f32(p.off + Pane.TY, p.ty + d_local, f'part-shift {lname}/{p.name}') + for an, keys in ty_keys.get(p.name, []): + for k in keys: + W.f32(k.off + 4, k.value + d_local, f'part-shift-anim {lname}/{p.name} {an}') + done.add(p.name) + notes.append(f'part-shift {p.name:<26} y {p.ay:7.1f} -> {p.ay + sign * DELTA:7.1f}') + # exact-height windows (grown around their own centre to a fixed height) + for p in root.walk(): + if p.name in exact: + if grow_fill(W, lname, p, exact[p.name] / p.h, False, szh_keys, ty_keys, notes, 'part-exact'): + done.add(p.name) + notes.append(f'part-exact {p.name:<26} h {p.h:.0f} -> {exact[p.name]:.0f}') + # explicit signed TransY shifts (parts whose use sites sit off the layout origin); the final pose of any + # multi-key TransY curve moves with the pane, constant single-key overrides are left alone + for p in root.walk(): + if p.name in shift_y: + dy = shift_y[p.name] + W.f32(p.off + Pane.TY, p.ty + dy / p.parent_sy, f'part-shift-y {lname}/{p.name}') + last_key_shift(W, lname, p.name, dy / p.parent_sy, ty_keys, notes, 'part-shift-y-key') + done.add(p.name) + notes.append(f'part-shift-y {p.name:<26} y {p.ay:7.1f} -> {p.ay + dy:7.1f}') + for p in root.walk(): + if p.name in ty_scale: + scale_ty(W, lname, p, ty_scale[p.name], ty_keys, notes) + done.add(p.name) + # round 10: fixed height growth around the pane's own centre (no SizeH / TransY animation allowed) + for p in root.walk(): + if p.name in grow_h: + if p.name in szh_keys or p.name in ty_keys: + notes.append(f'WARN part-grow-h {p.name}: SizeH/TransY animated, left alone') + continue + if grow_fill(W, lname, p, (p.h + grow_h[p.name]) / p.h, False, szh_keys, ty_keys, notes, 'part-grow-h'): + done.add(p.name) + notes.append(f'part-grow-h {p.name:<26} h {p.h:.0f} -> {p.h + grow_h[p.name]:.0f}') + for p in root.walk(): # stamina wheel: the 0.75 squash lives inside the part (see curated.PART_SY) + if p.name in part_sy: + W.f32(p.off + Pane.SY, p.sy * ROOT_SY, f'part-sy {lname}/{p.name}') + W.f32(p.off + Pane.TY, p.ty * ROOT_SY, f'part-sy-ty {lname}/{p.name}') + done.add(p.name) + notes.append(f'part-sy {p.name:<26} ScaleY {p.sy:.2f} -> {p.sy * ROOT_SY:.3f}') + for n in (list(fills) + sorted(shifts) + list(exact) + list(shift_y) + list(ty_scale) + list(grow_h) + + sorted(part_sy)): # cap_use warns itself + if n not in done: + notes.append(f'WARN curated part pane {n} not found/handled') + return notes + + +def _build_layout(lname, raw, ents, buf, W, top, referenced): + """Apply the rules to one bflyt. Returns notes.""" + s, e = ents['blyt/' + lname + '.bflyt'] + lw, lh, root = parse_flyt(raw, s) + notes = [] + if lname in referenced: + return build_part(lname, raw, ents, buf, W, root) # part: root stays (1, 1), prt1 stands in for it + if (lw, lh) != (1280.0, 720.0): + notes.append(f'skip layout size {lw}x{lh}') + return notes + if lname not in C.ROOT_SKIP and lname not in C.CURSOR_ROOT_KEEP and C.ROOT_MODE == 'root': + W.f32(root.off + Pane.SY, root.sy * ROOT_SY, 'root.sy') + if lname in C.NO_SHIFT_LAYOUT_ALL: + return notes + annotate(root) + mats = materials(raw, s) + + # TransY / size curves by pane name (this layout's own animations) + ty_keys = collections.defaultdict(list) + szh_keys = collections.defaultdict(list) + for an in layout_anims(ents, lname): + for pane, is_mat, tmag, target, ctype, keys in parse_flan(raw, ents[an][0]): + if is_mat: + continue + if target == 1: + assert ctype == 2, (lname, an, pane, ctype) + ty_keys[pane].append((an, keys)) + elif target == 9: + szh_keys[pane].append((an, keys)) + + handled = set() + sign_of = lambda p: 1 if p.ay > 0 else -1 + + # ---- capture panes that keep the fill ---- + # (none by default: source panes keep their 1280x720 size, only the use panes fill) + + def shift_pane(p, sign, why): + d_local = sign * DELTA / p.parent_sy + W.f32(p.off + Pane.TY, p.ty + d_local, f'shift {lname}/{p.name} ({why})') + for an, keys in ty_keys.get(p.name, []): + for k in keys: + W.f32(k.off + 4, k.value + d_local, f'shift-anim {lname}/{p.name} {an}') + notes.append(f'shift {p.name:<26} y {p.ay:7.1f} -> {p.ay + sign * DELTA:7.1f} ({why})') + handled.add(p.name) + + no_fill = C.NO_FILL.get(lname, set()) + # ---- fill pass ---- + fill = set() + grown_src = set() + for p in root.walk(): + if p is root or p.name in no_fill: + continue + edge_parent = p.kind == 'pan1' and any(parent_vert_origin(c) for c in p.children) + if not (p.kind in ('pic1', 'wnd1', 'scr1') or edge_parent): + continue + if not (H0 * 0.95 <= p.ah < H0 * K - 1): + continue + animated_ty = p.name in ty_keys + if abs(p.ay) > 10 and not (animated_ty and p.aw >= lw * 0.95): + continue + if parent_vert_origin(p) != 0: + notes.append(f'WARN fill {p.name}: attached to parent edge, skipped') + continue + vo = vert_origin(p) + uniform = False + tex = None + capture = False + if p.kind == 'pic1': + mi = struct.unpack_from('= lw * 0.95 and p.name not in C.NO_UNIFORM.get(lname, ()) + and p.name not in szh_keys) + if capture: + # FBLayout use pane: it must keep the size of its capture source (see curated.CAPTURE_POLICY). + src = find_capture_source(root, p) if C.CAPTURE_POLICY == 'grow_source' else None + if src is None or src.name in ty_keys: + notes.append(f'capture-keep {p.name:<22} {p.w:.0f}x{p.h:.0f} unchanged (source {src.name if src else "none/policy"} kept)') + continue + if src.path() not in grown_src: + if grow_fill(W, lname, src, K, False, szh_keys, ty_keys, notes, 'capture-src'): + grown_src.add(src.path()) + fill.add(src.name) + notes.append(f'capture-src {src.name:<22} h {src.h:.0f} -> {src.h * K:.0f}') + else: + continue + W.f32(p.off + Pane.H, p.h * K, f'fill-h {lname}/{p.name}') + if vo: + grow = (p.h * K - p.h) / 2 * p.sy + W.f32(p.off + Pane.TY, p.ty + (grow if vo == 1 else -grow), f'fill-recentre {lname}/{p.name}') + if uniform: + W.f32(p.off + Pane.W, p.w * K, f'fill-w {lname}/{p.name}') + for an, keys in szh_keys.get(p.name, []): + for k in keys: + W.f32(k.off + 4, k.value * K, f'fill-hanim {lname}/{p.name} {an}') + W.f32(k.off + 8, k.slope * K, f'fill-hanim-slope {lname}/{p.name} {an}') + if animated_ty: + W.f32(p.off + Pane.TY, p.ty * K, f'fill-ty {lname}/{p.name}') + for an, keys in ty_keys[p.name]: + for k in keys: + W.f32(k.off + 4, k.value * K, f'fill-anim {lname}/{p.name} {an}') + W.f32(k.off + 8, k.slope * K, f'fill-anim-slope {lname}/{p.name} {an}') + fill.add(p.name) + notes.append(f"fill {p.name:<26} {'uniform' if uniform else 'height '} tex={tex}") + + # ---- curated force fills: off-centre full-screen backdrops the generic rule skips ---- + ff_done = set() + for p in root.walk(): + mode = C.FORCE_FILL.get(lname, {}).get(p.name) + if mode and grow_fill(W, lname, p, K, mode == 'u', szh_keys, ty_keys, notes, 'force-fill'): + ff_done.add(p.name) + fill.add(p.name) + notes.append(f'force-fill {p.name:<26} h {p.h:.0f} -> {p.h * K:.0f}') + for n in C.FORCE_FILL.get(lname, {}): + if n not in ff_done: + notes.append(f'WARN curated force-fill pane {n} not handled') + + # ---- curated proportional growth: screen-proportional decoration (frames/vignettes) that is NOT a full-screen + # backdrop. Height x K keeps its stock distance from the screen edges in framebuffer pixels. Not required to + # cover the 4:3 height (verify.py check P4 enforces exactness, centre and the 480 limit). + pg_done = set() + for p in root.walk(): + if C.PROP_GROW.get(lname, {}).get(p.name) and grow_fill(W, lname, p, K, False, szh_keys, ty_keys, notes, 'prop-grow'): + pg_done.add(p.name) + fill.add(p.name) + notes.append(f'prop-grow {p.name:<26} h {p.h:.0f} -> {p.h * K:.0f}') + for n in C.PROP_GROW.get(lname, {}): + if n not in pg_done: + notes.append(f'WARN curated prop-grow pane {n} not handled') + # ---- uniform growth of textured art (aspect kept) and edge-anchored decoration (height += 2*DELTA) ---- + for p in root.walk(): + if p.name in C.UNIFORM_GROW.get(lname, ()): + if grow_fill(W, lname, p, K, True, szh_keys, ty_keys, notes, 'uniform-grow'): + fill.add(p.name) + notes.append(f'uniform-grow {p.name:<24} {p.w:.0f}x{p.h:.0f} -> {p.w * K:.0f}x{p.h * K:.0f}') + amt = C.EDGE_GROW.get(lname, {}).get(p.name) + if amt: + if grow_fill(W, lname, p, (p.h + amt / p.asy) / p.h, False, szh_keys, ty_keys, notes, 'edge-grow'): + fill.add(p.name) + notes.append(f'edge-grow {p.name:<24} h {p.h:.0f} -> {p.h + amt / p.asy:.0f}') + # ---- round 3: wallpaper cut-outs grown uniformly with their TransY scaled (own writer: TransY keys allowed) ---- + for p in root.walk(): + if p.name in C.UNIFORM_TY_GROW.get(lname, ()): + if vert_origin(p) or p.name in szh_keys: + notes.append(f'WARN uniform-ty-grow {p.name}: edge origin / SizeH keys, skipped') + continue + W.f32(p.off + Pane.H, p.h * K, f'uniform-ty-grow-h {lname}/{p.name}') + W.f32(p.off + Pane.W, p.w * K, f'uniform-ty-grow-w {lname}/{p.name}') + notes.append(f'uniform-ty-grow {p.name:<22} {p.w:.0f}x{p.h:.0f} -> {p.w * K:.0f}x{p.h * K:.0f}') + if p.name in C.LEAF_TY.get(lname, ()): + scale_ty(W, lname, p, K, ty_keys, notes) + fill.add(p.name) + # ---- exact-height windows (match the Sheikah scanning window, 608 + 2*DELTA) ---- + ex = C.EXACT_H.get(lname, {}) + for p in root.walk(): + if p.name in ex and grow_fill(W, lname, p, ex[p.name] / p.h, False, szh_keys, ty_keys, notes, 'exact-h'): + fill.add(p.name) + handled.add(p.name) + notes.append(f'exact-h {p.name:<26} h {p.h:.0f} -> {ex[p.name]:.0f}') + for n in ex: + if n not in handled: + notes.append(f'WARN curated exact-h pane {n} not handled') + + # ---- final-pose shifts of corner-anchored animation targets (mini-map poses) ---- + for p in root.walk(): + dy = C.LAST_KEY_SHIFT.get(lname, {}).get(p.name) + if dy is not None: + if not last_key_shift(W, lname, p.name, dy / p.parent_sy, ty_keys, notes): + notes.append(f'WARN curated last-key pane {p.name}: no multi-key TransY curve') + + # ---- extend edge strips ---- + for p in root.walk(): + if p.name in C.EXTEND_TO_EDGE.get(lname, ()): + sign = sign_of(p) + W.f32(p.off + Pane.H, p.h + DELTA / p.asy, f'extend-h {lname}/{p.name}') + W.f32(p.off + Pane.TY, p.ty + sign * DELTA / 2 / p.parent_sy, f'extend-ty {lname}/{p.name}') + notes.append(f'extend {p.name}') + + # ---- edge shift pass ---- + if lname in C.NO_SHIFT_LAYOUT or lname.startswith('Pa') and not lname.startswith('Pause') and lname not in C.PA_SHIFT: + return notes + force = C.FORCE_SHIFT.get(lname, set()) + skip = C.NO_SHIFT_SUBTREE.get(lname, set()) + + def is_edge(c): + h_eff = 0 if is_nominal_null(c) else c.ah + return h_eff < EDGE_MAXH and (abs(c.ay) >= THRESH or abs(c.ay_origin) >= THRESH + or (h_eff <= SMALL_H and abs(c.ay) + h_eff / 2 >= THRESH)) + + def consider(c, why): + sign = C.FORCE_SIGN.get(lname, {}).get(c.name) or sign_of(c) + pivot = c.kind == 'pan1' and why != 'forced' and (c.name in C.PIVOT_SPLIT.get(lname, ()) or any( + not is_edge(k) and k.name not in fill and k.ty * sign * c.asy <= -0.28 * H0 for k in c.children)) + if pivot: + notes.append(f'split {c.name:<26} (pivot: child counter-translates to central content)') + for k in c.children: + if k.name in skip or k.name in fill: + continue + if is_edge(k): + consider(k, 'edge') + return + shift_pane(c, sign, why) + + def visit(p): + kids = [c for c in p.children if c.name not in skip] + # stacked-column clusters: siblings in the same column touching an edge member move with it + edge_members = [c for c in kids if c.name not in fill and c.ty != 0 and is_edge(c)] + cluster = set() + for em in edge_members: + for c in kids: + if c is em or c.name in fill or c.ty == 0 or c in edge_members: + continue + if (abs(em.ax) >= 300 and abs(c.tx - em.tx) <= 1 and c.kind == em.kind and (c.ay > 0) == (em.ay > 0) + and abs(c.ay - em.ay) <= 4 * max(c.ah, 40) and c.ah < EDGE_MAXH): + cluster.add(c.name) + for c in kids: + if c.name in fill: + if c.kind in CONTAINERS and c.children and c.ty == 0 and c.rot == (0, 0, 0): + visit(c) + continue + if c.ty != 0 or c.name in force: + if c.name in force: + consider(c, 'forced') + elif is_edge(c): + consider(c, 'edge') + elif c.name in cluster: + consider(c, 'cluster') + continue + if c.kind in CONTAINERS and c.children and c.sy == 1 and c.rot == (0, 0, 0): + visit(c) + + visit(root) + # forced panes the container walk could not reach (e.g. parented under a pic1): shift directly unless an + # ancestor was already shifted (that would move them twice) + anc = {} + def mark(p, chain): + anc[p.path()] = chain + for c in p.children: + mark(c, chain + [p]) + mark(root, []) + for p in root.walk(): + if p.name in force and p.name not in handled and p is not root: + if any(a.name in handled for a in anc[p.path()]): + continue + if any(a.ty != 0 or a.sy != 1 or a.rot != (0, 0, 0) for a in anc[p.path()] if a is not root): + continue + consider(p, 'forced') + for n in force: + if n not in handled: + notes.append(f'WARN curated pane {n} not handled') + return notes + + +STATS = collections.Counter() + + +def children_pass(lname, raw, ents, buf, W): + """ROOT_MODE 'children': give every DIRECT child of RootPane the factor ROOT_SY on TransY and ScaleY + (static values read from the buffer, i.e. AFTER the fill/shift rules ran, plus every TransY / ScaleY + key and slope of this layout's own animations). Panes the game code rescales (C.CODE_SCALE_PANES) + keep their own ScaleY; the factor goes to their children and to their SizeH instead. + Direct children attached to the root's top/bottom edge (origin bits 6-7) need + ty' = F*ty + (F-1)*base because the attach base is the (unscaled) root edge.""" + s, e = ents['blyt/' + lname + '.bflyt'] + lw, lh, root = parse_flyt(raw, s) + notes = [] + F = ROOT_SY + keys = collections.defaultdict(lambda: collections.defaultdict(list)) # pane -> target -> [(anim, keys)] + for an in layout_anims(ents, lname): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(raw, ents[an][0]): + if is_mat or target not in (1, 7, 9): + continue + keys[pane][target].append((an, ctype, ks)) + + def rd(off): + return struct.unpack_from(' {len(p.children)} children') + for c in p.children: + apply(c, depth + 1, p) + else: + cur_sy = rd(p.off + Pane.SY) + W.f32(p.off + Pane.SY, cur_sy * F, f'children-sy {lname}/{p.name}') + STATS['sy'] += 1 + STATS['sy_keys'] += scale_keys(p, 7, F, 'sy') + + for c in root.children: + c.parent_h = root.h + apply(c, 0, root) + # a pane that was pushed down contributes its children as depth>0: they never use the root base + return notes + + +def hud_scale_pass(lname, raw, ents, buf, W): + """Round 8 prototype: enlarge selected HUD groups by C.HUD_SCALE about a fixed anchor (see curated.HUD_PANES).""" + spec = C.HUD_PANES.get(lname) + if not spec or abs(C.HUD_SCALE - 1.0) < 1e-6: + return [] + S = C.HUD_SCALE + s, e = ents['blyt/' + lname + '.bflyt'] + lw, lh, root = parse_flyt(raw, s) + byname = {} + for p in root.walk(): + byname.setdefault(p.name, p) + notes = [] + for name, (ax, ay) in spec.items(): + p = byname.get(name) + if p is None: + notes.append(f'WARN hud-scale pane {name} not found') + continue + rd = lambda off: struct.unpack_from(' {p.h * ROOT_SY:.1f}, ScaleY {p.sy:g} -> {p.sy / ROOT_SY ** n:.4f} (n={n})') + if p.name in hs: + W.f32(p.off + Pane.H, p.h * ROOT_SY, f'src-h-scale {lname}/{p.name}') + for an, ks in keys.get((p.name, 9), ()): + for k in ks: + W.f32(k.off + 4, rd(k.off + 4) * ROOT_SY, f'src-h-scale-key {lname}/{p.name} {an}') + if k.slope is not None: + W.f32(k.off + 8, rd(k.off + 8) * ROOT_SY, f'src-h-scale-slope {lname}/{p.name} {an}') + notes.append(f'src-h-scale {p.name}: SizeH and SizeH keys x{ROOT_SY}') + return notes + + +def sizeh_retarget_pass(lname, raw, ents, buf, W): + spec = C.SIZEH_RETARGET.get(lname) + if not spec: + return [] + s, e = ents['blyt/' + lname + '.bflyt'] + root = parse_flyt(raw, s)[2] + notes = [] + rd = lambda off: struct.unpack_from(' {spec[p.name]:.0f}') + for an in layout_anims(ents, lname): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(raw, ents[an][0]): + if is_mat or target != 9 or pane not in spec: + continue + for k in ks: + v = rd(k.off + 4) + if abs(v - H0) < 0.5: + W.f32(k.off + 4, spec[pane], f'sizeh-retarget-key {lname}/{pane} {an}') + if k.slope is not None: + W.f32(k.off + 8, rd(k.off + 8) * spec[pane] / v, f'sizeh-retarget-slope {lname}/{pane} {an}') + notes.append(f'sizeh-retarget key {pane} {an} {v:.0f} -> {spec[pane]:.0f}') + return notes + + +def host_sy_pass(lname, raw, ents, buf, W): + """Stamina-wheel hosts: ScaleY x factor (see curated.HOST_SY_FACTOR). Static value read from the buffer.""" + want = C.HOST_SY_FACTOR.get(lname) + if not want: + return [] + s, e = ents['blyt/' + lname + '.bflyt'] + lw, lh, root = parse_flyt(raw, s) + notes = [] + for p in root.walk(): + if p.name in want: + cur = struct.unpack_from(' {cur * want[p.name]:.3f}') + return notes + + +def build_layout(lname, raw, ents, buf, W, top, referenced): + if lname in C.CURSOR_ROOT_KEEP and lname not in referenced: + return ['kept byte-identical to stock (CURSOR_ROOT_KEEP)'] + notes = _build_layout(lname, raw, ents, buf, W, top, referenced) + if C.ROOT_MODE != 'children' or lname in referenced or lname in C.ROOT_SKIP: + if lname not in referenced: + notes = notes + sizeh_retarget_pass(lname, raw, ents, buf, W) # root scale 0.75 clips the map scissor too + return notes + s, e = ents['blyt/' + lname + '.bflyt'] + lw, lh, root = parse_flyt(raw, s) + if (lw, lh) != (1280.0, 720.0): + return notes + notes = notes + children_pass(lname, raw, ents, buf, W) + notes = notes + host_sy_pass(lname, raw, ents, buf, W) + notes = notes + capture_pass(lname, raw, ents, buf, W) + notes = notes + capture_apply_pass(lname, raw, ents, buf, W) + notes = notes + hud_scale_pass(lname, raw, ents, buf, W) + return notes + sizeh_retarget_pass(lname, raw, ents, buf, W) + + + +def pack_sarc(orig, new_files): + """Rebuild a SARC with the same entry order/hashes; new_files {name: bytes} replace entries. + Alignment of every entry is preserved as the lowest-set-bit of its original relative offset (capped).""" + e = '<' if orig[6:8] == LE_BOM else '>' + hlen = struct.unpack_from(e + 'H', orig, 4)[0] + data_off = struct.unpack_from(e + 'I', orig, 0x0C)[0] + cnt = struct.unpack_from(e + 'H', orig, hlen + 6)[0] + nodes = [list(struct.unpack_from(e + 'IIII', orig, hlen + 12 + 16 * i)) for i in range(cnt)] + ents = sarc_entries(orig) + by_off = {} + for nm, (s, en) in ents.items(): + by_off[s - data_off] = nm + order = sorted(by_off) + out = bytearray() + new_nodes = {} + for rel in order: + nm = by_off[rel] + s, en = ents[nm] + blob = new_files.get(nm, orig[s:en]) + align = min(rel & -rel, 0x2000) if rel else 0x2000 + if rel == 0 and nm in ents: + align = 0x2000 if data_off % 0x2000 == 0 else 0x1000 + # keep the first file at relative 0; later files keep their original alignment + pad = (-len(out)) % max(align, 1) + out += b'\0' * pad + new_nodes[nm] = (len(out), len(out) + len(blob)) + out += blob + # patch node table + head = bytearray(orig[:data_off]) + for i in range(cnt): + h, attr, s, en = nodes[i] + name_off = (attr & 0xFFFF) * 4 + nm = None + for n2, (so, eo) in ents.items(): + if so - data_off == s: + nm = n2; break + ns, ne = new_nodes[nm] + struct.pack_into(e + 'II', head, hlen + 12 + 16 * i + 8, ns, ne) + total = len(head) + len(out) + struct.pack_into(e + 'I', head, 8, total) + return bytes(head) + bytes(out) + + +def main(): + os.makedirs(os.path.join(OUT, 'Layout'), exist_ok=True) + os.makedirs(os.path.join(OUT, 'Pack'), exist_ok=True) + jobs = [ # (output rel path, source file, inner entry or None) + ('Layout/BootUp.sblarc', 'Layout/BootUp.sblarc', None), + ('Layout/Horse.sblarc', 'Layout/Horse.sblarc', None), + ('Pack/Title.pack', 'Pack/Title.pack', 'Layout/Title.sblarc'), + ('Pack/Bootup.pack', 'Pack/Bootup.pack', 'Layout/Common.sblarc'), + ] + loaded = {} + referenced = set() + for outrel, src, inner in jobs: + raw, ents = load_archive(os.path.join(SRC, src), inner) + loaded[outrel] = (raw, ents) + for n in ents: + if n.endswith('.bflyt'): + referenced |= part_refs(raw, ents[n][0]) + report = {} + for outrel, src, inner in jobs: + raw, ents = loaded[outrel] + buf = bytearray(raw) + W = Writer(buf) + names = sorted(n[5:-6] for n in ents if n.endswith('.bflyt')) + # referenced only counts parts of THIS archive's layouts being used elsewhere + notes_all = {} + for ln in names: + notes = build_layout(ln, raw, ents, buf, W, True, referenced) + if notes: + notes_all[ln] = notes + assert len(buf) == len(raw) + report[outrel] = {'writes': [(o, a, b, w) for o, a, b, w in W.log], 'notes': notes_all} + print(f'== {outrel}: {len(W.log)} float writes in {len(notes_all)} layouts') + if not W.log: + continue + comp = yaz0_compress(bytes(buf)) if COMPRESS else None + if comp is None: + continue + assert yaz0_decompress(comp) == bytes(buf) + if inner: + pack_raw = open(os.path.join(SRC, src), 'rb').read() + newpack = pack_sarc(pack_raw, {inner: comp}) + # round-trip check on the container + old_e = sarc_entries(pack_raw); new_e = sarc_entries(newpack) + assert set(old_e) == set(new_e) + for n in old_e: + if n != inner: + assert pack_raw[old_e[n][0]:old_e[n][1]] == newpack[new_e[n][0]:new_e[n][1]], n + assert newpack[new_e[inner][0]:new_e[inner][1]] == comp + open(os.path.join(OUT, outrel), 'wb').write(newpack) + else: + open(os.path.join(OUT, outrel), 'wb').write(comp) + report['_meta'] = {'root_mode': C.ROOT_MODE, 'children_stats': dict(STATS)} + print('root mode:', C.ROOT_MODE, dict(STATS)) + json.dump(report, open(os.path.join(OUT, 'build_report.json'), 'w'), indent=1) + for k, v in report.items(): + if k == '_meta': + continue + for ln, notes in v['notes'].items(): + print(f'-- {k}: {ln}') + for n in notes: + print(' ' + n) + + +main() diff --git a/the-legend-of-zelda-breath-of-the-wild/tools/curated.py b/the-legend-of-zelda-breath-of-the-wild/tools/curated.py new file mode 100644 index 0000000..6c0cc27 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/tools/curated.py @@ -0,0 +1,401 @@ +"""Curated per-layout decisions for the BOTW 4:3 build (starts empty; filled in as layouts are reviewed).""" +import os +# Free-floating selector layout(s): names listed here are left byte-identical to stock in EVERY pass (no root scale, +# no children pass). The game builds the corner frame from the target's already-compressed rect, so our own 0.75 on +# Pa_Cursor_00 compressed it twice (corner triangles inside the box). BOTW_CURSOR_KEEP= restores the old +# (0.75) behaviour for an A/B build. +CURSOR_ROOT_KEEP = {n for n in os.environ.get('BOTW_CURSOR_KEEP', 'Cursor_00').split(',') if n} + +ROOT_SKIP = { # Pa* parts no prt1 references: game code instantiates them as children, so they stay (1,1) like every other part + 'PaAllControllerTipsNN_00','PaAppMapTemp_00','PaAppMapTime_00','PaCommonBtnTitle_00','PaDoCommandKeyNNA_00','PaDoCommandKeyNNB_00','PaDoCommandKeyNNC_00','PaMapIconKolog_00','PaMessageTipsDrcImageNN_00','PaMessageTipsDrcImgAmiiboNN_00','PaPlayerStatusUp_00','PaShortCutIconCrossNN_00','PaTitleBtn_00'} +NO_SHIFT_LAYOUT_ALL = set(ROOT_SKIP) # layouts that only get the root scale (no fill, no shifts) +NO_SHIFT_LAYOUT = set() # layouts that get root scale + fill but no edge shifts +PA_SHIFT = { # unreferenced Pa* layouts that should still get edge shifts + # real top-level screens despite the Pa prefix: pause-menu info page and cooking recipe page + 'PauseMenuInfo_00', 'PauseMenuRecipe_00', +} +FORCE_SHIFT = { # layout -> {pane names to shift whatever the rules say} + # bottom dialog sheet (276 tall, just over the small-strip threshold); its capture source moves with it + 'AppSystemWindow_00': {'N_All_00', 'N_Capture_00'}, + # --- HUD review (sec/hud) --- + # top-centre info strip shares y=190 with Pa_LocationName_00 / Pa_QuestName_00 (both edge-shifted); it was skipped only + # because its own box (h=40) stays under the 252 threshold, which would leave it 120 lower than its siblings + 'MainScreen_00': {'Pa_Information_00'}, + # loading screen top-left text T_DummyText_00 (y=250) hangs under N_RegionTypePos_00 (ty 16 + RegionType TransY + # keys), so the container walk never reached it: shift the container (its keys move with it) + 'Fade_00': {'N_RegionTypePos_00'}, + # DRC-base position of the heart gauge in the "MS" and one-hit-KO HUDs (N_Pos_00 is already shifted; the gauge's own + # base at (0,220) was not, its far edge 245 < 252) + 'MainScreenMS_00': {'Pa_HeartGauge_00'}, + 'MainScreenHeartIchigekiDLC_00': {'Pa_HeartGauge_00'}, + # bottom-centre horse spur pips: row y=-220 (far edge -247, just under the threshold) sits in the same row as + # Pa_TempMeter_00 (-222) which IS shifted; shift the pips too (parents at ty 0 -> shift is in layout units) + 'MainHorse_00': {'N_InOut_01', 'N_InOut_02', 'N_InOut_03', 'N_InOut_04', 'N_InOut_05', 'N_InOut_06', 'N_InOut_07', + 'N_InOut_08', 'N_InOut_12', 'N_InOut_13', 'N_ExtraIn_00'}, + # stacked on top of Pa_Sensor_00 in the right column (x=392); the siblings moved -120, so must the meter + 'EnergyMeterDLC_00': {'N_EnergyMeterDLC_00'}, + # Wolf Link bottom-left heart gauge (far edge -247): whole group moves; N_InOut_00 sits at ty=+10 so the sign is forced + 'WolfLinkHeartGauge_00': {'N_Capture_00', 'N_InOut_00'}, + # capture source/use pairs that must move together (verify.py section 10). Stock: the use panes sit on + # exactly the source rect; the generic rules moved only one side. + 'MessageSp_00': {'N_CaptureHigh_00', 'N_Capture_00', # sources were 'pivot split' (text counter-translated), + # but the window + 5 use panes moved: source text left behind + 'N_SunLight_00'}, # holds the circuit-arc end caps Nt_MsgDeco_09/02 at y=-235 (null + # container, under the 252 threshold): they stayed ~120 above the pill + # speaker-name plate (N_NameS_00: P_Sh_00 + T_Name_*, y=-174; centre+half height 194 < 252, so it stayed ~75 above + # the box) and its capture source N_Capture_00; the dialog box W_Base_*/W_SysBase_* (y=-235) is edge-shifted + 'Message_00': {'N_NameS_00', 'N_Capture_00'}, + 'DemoName_00': {'N_InOut_00'}, # holds P_Sh_00/P_Light_00/P_SubText_00/P_Name_00 (centre y=-240 < edge threshold) + 'DemoNameEnemy_00': {'N_In_00'}, # holds P_BigTextSh_00/P_Light_01/P_BigText_0x (centre y=-220) + 'HardModeTextDLC_00': {'N_InOut_00'}, # holds P_BigTextSh_00, partner of N_Capture_01 (edge-shifted) + 'SystemWindow_01': {'N_HardModePos_00'}, # holds P_BigTextSh_00 + T_DummyText_01, partner of N_Capture_01 + # --- Sheikah-slate review (sec/sheikah) --- + # bottom-right toast (360x80 at y -186, flush with the right edge, 134 above the bottom): corner-anchored, + # just under the strip threshold; capture source N_Capture_00 and the whole N_InOut_00 group move together + 'AppSystemWindowNoBtn_00': {'N_Capture_00', 'N_InOut_00'}, + # 512x288 capture rect that sits exactly on the mini-map pose of N_MiniMap_00 (410,-216, scale 0.4, flush + # with the bottom edge); 288 > SMALL_H so the rules skip it. N_MiniMap_00's final pose moves via LAST_KEY_SHIFT. + 'AppMapDungeon_00': {'N_Capture_01'}, +} +FORCE_SIGN = { # layout -> {pane: +1/-1} direction for FORCE_SHIFT panes whose own centre is near 0 + 'WolfLinkHeartGauge_00': {'N_InOut_00': -1}, +} +NO_SHIFT_SUBTREE = { # layout -> {pane names whose subtree stays in place} + # title / boot art: logos stay where they are (guide: "leave logos in place") + 'Title_00': {'Logo_W_00', 'Logo_W_00_JPja', 'N_Capture_01'}, + 'BootUp_00': {'Logo_W_03', 'Logo_W_00_JPja_02'}, + # pause info page: the generic small-block rule (|ay|+h/2 >= 252, h <= 266) caught blocks that are NOT + # edge-anchored. Pa_HaveNum_00: prt1 box 240x244 at y=146 whose real text sits at y 44..176, same column + # (x~84) as the unshifted Ganbari/Sp/TempMeter/SetBonus panes. N_CaptureSlideInfoR_0x / P_CaptureSlideR_0x: + # 50x200 right-of-screen slide-seam strips at y=-170 belonging to the unshifted info panel (Pa_Gear_00). + 'PauseMenuInfo_00': {'Pa_HaveNum_00', 'N_CaptureSlideInfoR_00', 'N_CaptureSlideInfoR_01', + 'P_CaptureSlideR_00', 'P_CaptureSlideR_01'}, + # --- Sheikah-slate review (sec/sheikah) --- + # focus-reticle bracket pieces: the *_01 pieces of RT/LB were authored anchored the other way round and fall + # just over the 252 strip threshold at y +-257; the other six bracket pieces are not edge items. Moving two + # of eight pieces breaks the reticle (RT_01 +120, LB_01 -120 against their siblings). + 'AppCamera_00': {'P_JudgmentRT_01', 'P_JudgmentLB_01'}, + # N_SunLight_00 is a wrapper whose only child P_3DSh_01 counter-translates back to the 3D rect (abs y -5). + # The edge rule moved the wrapper +120 and dragged the (already filled) child to [-365,595]; its twins + # P_3DSh_00/P_3D_00 sit at [-485,475]. N_Pos_00 / N_PosBase_00 are off-screen measuring anchors (y 505 / 446, + # N_PosBase x 852): moving them has no visual purpose and may be read by game code, so they stay as authored. + 'AppMapDungeon_00': {'N_SunLight_00', 'N_Pos_00', 'N_PosBase_00'}, + # the sensor pill's own pose is shifted INSIDE PaAppMapSensor_00 (PART_SHIFT_Y) so that the full-screen + # 'born' popup of that part stays centred; shifting the parent as well would double-move the pill. + 'AppPictureBook_00': {'N_MapPos_00'}, +} +NO_FILL = { # layout -> {pane names not filled} + # Link-with-bow cut-outs (732x800 art): the generic height-only fill stretched them 1.33x -> keep stock + 'Title_00': {'TitleBG_01', 'P_ImageArrow_00'}, + # DLC illustration picture (906x914): height-only fill stretched it; it grows uniformly instead (UNIFORM_GROW) + 'DLCWindow_00': {'WUPP_ALZ_illu06_1_R_ad-0'}, +} +NO_UNIFORM = {} # layout -> {pic1 names that must NOT grow in width (height only)} +EXTEND_TO_EDGE = {} # layout -> {strip pane names grown outward by the edge shift} +FORCE_FILL = { # layout -> {pane: 'h'} off-centre full-screen backdrops the + # generic rule skips (|ay|>10): grow height by K anyway. Both are dark backdrops, not captures. + 'ErrorViewer_00': {'W_Shadow': 'h'}, # 760-tall wnd1 at ay=-12 -> 1013 +} +# Capture policy. FBLayout panes are screen-capture USE panes; their SOURCE (pan1 N_Capture*, same rect) defines +# the copied framebuffer rectangle. The use pane must be drawn at the source's size or the capture is stretched. +# 'match' sources and uses keep their original size (correct whether or not the root scale reaches the +# capture rect, and whether the game reads local size as pixels or as scaled layout units); +# full-screen capture backdrops cover the central 3/4 of the 4:3 height only. +# 'grow_source' sources AND uses grow together by K (full coverage; needs the capture rect to follow +# root scale x pane size, i.e. rect = size * root scale). +CAPTURE_POLICY = 'fullframe' +# 'fullframe' (children mode) framebuffer-copy SOURCES keep their stock local size (the engine copies a rect of +# the source's LOCAL size at its global centre); every FBLayout USE pane keeps its stock PROJECTED +# size: local h = stock h / ROOT_SY^n, n = number of 0.75-scaled panes in its parent chain (code-scaled +# panes are forced to scale 1 by the game and do not count). Full-frame backdrops therefore project to +# exactly 720 (960 local under a 0.75 parent, 720 local as a code-scaled direct child). +# In root mode this behaves like 'match'. + +# ---- Sheikah-slate window: the 608 high scanning window becomes 608 + 2*DELTA = 848 so it still meets the +# edge strips (walls / moya / deco text bars) that moved out by DELTA. Everything that is the same window +# (vignettes, scissor/clip, overlays) gets the same exact height. NON-capture panes only: capture +# source/use pairs keep CAPTURE_POLICY (see the notes at PaAppMapSensor_00 in PART_FILL). +WINDOW_H = 848.0 +EXACT_H = { # layout -> {pane: exact height, grown around the pane centre} + 'AppCamera_00': {'W_Shadow_00': WINDOW_H, 'N_Scissor_00': WINDOW_H}, + 'SeekPadMenuBG_00': {'W_Shadow_00': WINDOW_H}, + 'AppMap_00': {'W_Shadow_00': WINDOW_H, 'P_VisitMark_01': WINDOW_H}, +} +LAST_KEY_SHIFT = { # layout -> {pane: dy}: final pose of a multi-key TransY curve moves by dy + # mini-map poses: the clip windows land in the bottom-right corner (AppMap_00 at (510,-240), 166x166; + # AppMapDungeon_00 at (410,-216), flush with the bottom edge) and must keep their distance from the edge. + 'AppMap_00': {'N_Cut_00': -120.0, 'N_Cut_01': -120.0}, + 'AppMapDungeon_00': {'N_MiniMap_00': -120.0}, +} +PART_FILL = { # referenced part layout -> {pane: mode} + # modes: 'h' height xK, 'u' uniform xK, 'H' height grown to exactly PART_FILL_H (default + # 2*HALF_VIS), 'U' same but uniform. No TransY/SizeH anim on any of these panes (checked + # against all bflans of each part). + 'PaSeekPadScanningLine_00': {'P_BootBG_00': 'h'}, # White8 dim 1280x720, camera/scope backdrop + # (PaCameraPointer_00 scope vignettes 320x608 / 1280x608 are window-sized, NOT captures (textures CameraPointerL/R_00, + # wnd1): PART_EXACT_H below -- sheikah's 848 replaces the base 'H' (960) fills) + # PaAppMapSensor_00 'born' popup: full-screen backdrops centred on the screen at every use site. + # MERGE DECISION: P_FBLayout_00 (FBLayout use pane, 1280x720, same rect as source N_Capture_02) is NOT grown + # (dpad 'match' policy: capture use panes keep the size of their source); P_CaptureBorn_00 and the other + # panes carry no FBLayout texture and stay sheikah's 'u'/'h' fills. + 'PaAppMapSensor_00': { + 'P_BG_00': 'u', 'White8_00': 'u', 'P_BG_01': 'u', 'P_Abstract_00': 'u', + 'P_Abstract_01': 'u', 'P_CaptureBorn_00': 'u', 'P_Born_01': 'u'}, + 'Pa_AppMapOpenEf_00': {'P_CaptureBorn_00': 'u', 'P_BornBg_00': 'u'}, +} +# FBLayout use panes in parts, with their same-part source (grown only under CAPTURE_POLICY == 'grow_source'). +# PaPauseQuest_00/P_CaptureMask_00 has no source inside the part: never grown (its source lives in the parent). +PART_CAPTURE_FILL = { + 'PaSystemWindow_02': {'P_Capture_00': 'h', 'N_Capture_00': 'h'}, + 'PaDLCTipsBefore_00': {'P_Light_01': 'h', 'N_Capture_00': 'h'}, + 'PaAppMapSensor_00': {'P_FBLayout_00': 'h', 'N_Capture_02': 'h'}, # merge: sheikah's P_FBLayout_00 fill, source added (untested variant) +} +if CAPTURE_POLICY == 'grow_source': + for _k, _v in PART_CAPTURE_FILL.items(): + PART_FILL.setdefault(_k, {}).update(_v) +PART_EXACT_H = { # referenced part layout -> {pane: exact height} + # MERGE DECISION: P_ScanningLine_00 is an FBLayout capture USE pane (1280x608); growing it to 848 without a matching + # source stretches/blurs the capture (dpad rule), so it keeps its stock size. The frame walls still move out 120; + # the window-to-wall gap is exempted in verify (CONT_EXEMPT). + 'PaCameraPointer_00': {'P_CameraPointerL_00': WINDOW_H, 'P_CameraPointerR_00': WINDOW_H, + 'W_Shadow_00': WINDOW_H}, # scope vignettes = the same window + 'PaAppMapSensor_00': {'W_Shadow_00': WINDOW_H}, # popup vignette = same window +} +PART_SHIFT_Y = { # part -> {pane: signed dy in layout units}; use sites may be off-origin + # sensor pill (bottom-right HUD row, same row as Comp/Time/Temp which moved -120). Only the pill group + # moves; the popup backdrops (N_Capture_01/02, N_BornBg_*) stay centred on the screen. N_BornPos_00's + # BornMove end pose moves with it (start pose = popup centre is the first key / a single-key curve). + 'PaAppMapSensor_00': {'N_Capture_00': -120.0, 'N_InOut_00': -120.0, 'N_BornEf_00': -120.0, + 'N_BornPos_00': -120.0}, +} +PART_TY_SCALE = { # part -> {pane: factor on TransY (static + all keys + slopes)} + # scope light-sweep bars travel the window height: stretch their travel with the window (848/608) + 'PaCameraPointer_00': {'P_AbstractL_00': WINDOW_H / 608.0, 'P_AbstractR_00': WINDOW_H / 608.0}, +} +PART_GROW_H = { # part -> {pane: height added around its centre}; no SizeH/TransY anim allowed + # Round 10 (played and checked): map player locator (PaMapPlayer_00, only user AppMap_00/Pa_PlayerNavi_00). The code + # reads N_PosSize_00 by name as the box the locator bubble is clamped to and shown outside of. Stock 1200x590 = the 720 + # view minus 65 per edge; the 4:3 map view is 960 tall, so the box grows by 2*120 (65 per edge kept). With the stock box + # the bubble showed pinned 237 units above centre while Link's own icon was visible above it. + 'PaMapPlayer_00': {'N_PosSize_00': 240.0}, +} +PART_FILL_H = {} # exact target height for 'H'/'U' modes (default 2*HALF_VIS) +# N_Deco_00 corner/edge ornaments of the Sheikah frame: every piece is a corner-anchored picture whose outer +# edge touches y=+-360. Each piece moves rigidly by DELTA towards its own edge (top group +, bottom group -), so +# corner caps keep touching their side segments and nothing is stretched (textures keep their aspect). +FRAME_CORNERS = ({f'P_BlurSh_{i:02d}' for i in range(7)} | {f'P_Core_{i:02d}' for i in range(7)} + | {f'P_Abst_{i:02d}' for i in range(7)} | {f'P_Alb_{i:02d}' for i in range(10)} + | {f'P_Ind_{i:02d}' for i in range(9)} | {f'P_Em_{i:02d}' for i in range(6)}) +PART_SHIFT = { # referenced part layout -> {pane names edge-shifted by DELTA} + # bottom-left location-name banners (users: MainScreen_00 / MainDungeon_00, both at layout origin); N_Capture_00 + # (text capture source, centred) stays + 'PaLocationNameS_00': {'N_In_00'}, + 'PaLocationNameHokoraS_00': {'N_In_00'}, + # loading screen (Fade_00) logo + load bar, bottom-right; only user Fade_00/Pa_LoadBar_00 (chain 0.75) + 'PaFadeBar_00': {'P_TitleLogo_00', 'P_BarUS_00', 'P_JPBase_00', 'P_BarJP_00', 'P_CNTWBase_00', 'P_BarCNTW_00'}, + # shrine-camera pin row at the bottom of the viewfinder (y=-255 in part space) + 'PaCameraPointer_00': {'Pa_Pin_00', 'Pa_Pin_01', 'Pa_Pin_02', 'Pa_Pin_03', 'Pa_Pin_04'}, + # bottom-right weather HUD cluster (only user: MainScreen_00) + 'PaWeather_00': {'N_InOut_00'}, + # DLC notice bottom buttons (prt1 at layout origin in DLCWindow_00); caption T_TextDLC_00 stays on the art + 'PaDLCTipsBefore_00': {'Pa_BtnL_00', 'Pa_BtnC_00'}, + # scanning-line strips/text bars that touched the 16:9 edge (users: AppCamera/AppHome/PaCameraPointer) + 'PaSeekPadScanningLine_00': { + 'P_MoyaU_01', 'P_MoyaD_01', 'P_WallU_00', 'P_WallD_00', + 'N_CaptureText_01', 'N_Capture_01', 'T_DecoU_00', 'T_DecoD_00', 'N_Align_00', + # use panes of N_CaptureText_01/N_Capture_01 (same rect y=320) -- dpad; sheikah lists the same two + 'P_Sh_00', 'P_Text_00', + # moya haze strips anchored to the old +-304 window edge -- sheikah + 'P_MoyaU_00', 'P_MoyaD_00'} | FRAME_CORNERS, + # bottom dialog sheet embedded in AppMap_00 (276 high, flush with the bottom); same treatment as the + # top-level AppSystemWindow_00 (FORCE_SHIFT above) -- sheikah + 'PaAppSystemWindow_00': {'N_Capture_00', 'N_All_00'}, + # sensor-setting sheet (1880x276 at y -185 = [-323,-47], 37 px above the bottom edge; users AppMap_00 and + # AppMapDungeon_00 at the layout origin). Same 276 px sheet family as the system window; it sits over the + # bottom HUD row (Comp/Time/Temp/sensor pill, all moved -120), so it moves with it. N_Capture_00 is the + # capture source of the title text (same y as T_SensorTitle_00/P_Sh_00). -- sheikah + 'PaAppMapSensorSetting_00': {'N_All_00', 'N_Capture_00'}, +} + + + + + +# --------------------------------------------------------------------------------------------- +# Root-scale mechanism. +# 'root' : RootPane scale Y = 0.75 (original technique). +# 'children' : RootPane stays (1,1); every DIRECT child of RootPane of a top-level layout gets +# TransY x0.75 and ScaleY x0.75 (static + every TransY/ScaleY key and slope), which is +# geometrically identical to the root scale. Why it exists: the game's own code writes +# RootPane scale ((S,S/2) or (1,1), see REPORT.md: 0x1a38860 and ~20 overrides), so a +# root scale authored in the BFLYT can be overwritten at runtime. +# Environment variable BOTW_ROOT_MODE overrides this value (used to build both variants). +import os as _os +ROOT_MODE = _os.environ.get('BOTW_ROOT_MODE', 'children') +assert ROOT_MODE in ('root', 'children'), ROOT_MODE + +# Pane names whose ScaleX/ScaleY the game CODE overwrites (found by static scan of main: +# findPane(name) result stored to pane+0x48/+0x4c, see REPORT.md section 2). In 'children' mode a +# direct child with one of these names does NOT receive the scale factor itself (the game would +# replace it with (1,1)/(S,...)); the factor is pushed down to its own children instead and the pane +# gets TransY x factor and SizeH x factor so that attach/size geometry stays equivalent. +CODE_SCALE_PANES = { + 'N_All_00', 'N_BlurIn_00', 'N_CaptureBG_01', 'N_CaptureBlur_00', 'N_Capture_00', 'N_CopyRight_00', + 'N_InOutDemo_00', 'N_InOut_00', 'N_LoopLD_00', 'N_LoopLT_00', 'N_LoopRD_00', 'N_LoopRT_00', + 'N_SetOff_00', 'P_BG_00', 'P_Black_00', 'P_CaptureMask_00', 'P_CaptureSlideR_00', 'P_CaptureSlideR_01', + 'P_Capture_00', 'P_Capture_01', 'P_Grad_00', 'Pa_Temp_01', 'Pa_Time_01', 'T_Text_00', 'T_Time_00', + # Pause-menu page containers (PauseMenu_00 / PauseMenuBG_00 root children); factor goes to their children. + # (Round 6 blamed these for the Memories overlap; the real cause is NO_SCALE_SUBTREES below, round 7.) + 'N_Slide_00', 'N_Slide_01', 'N_Slide_02', +} +# Subtrees left completely at stock scale/translation/size (not even pushed down to children). +# PauseMenu_00/N_InOutQuest_02 holds Pa_Quest_00 (Adventure Log page). With ScaleY 0.75 on it, on Pa_Quest_00, or on the +# root children inside PaPauseQuest_00, the Memories list rows #6+ draw on top of #5. Found in round 7 by in-game bisect +# (pack-only tests: all pause layouts stock = clean; only PauseMenu_00 stock = clean; only N_InOutQuest_02 stock = clean). +NO_SCALE_SUBTREES = {'PauseMenu_00': {'N_InOutQuest_02'}} +NO_SCALE_NAMES = set().union(*NO_SCALE_SUBTREES.values()) # pane names (unique across layouts) skipped by build/verify visit rules +# Round 9: the stock Adventure Log page is squeezed to 0.75 width by the game but keeps full height, so its text and art +# looked narrow. PART_SQUASH_Y = {part layout: {direct children of its RootPane}} gives those panes ScaleY and TransY x0.75 +# (static + keys) about the part centre, BELOW the levels round 7 ruled out (N_InOutQuest_02, Pa_Quest_00, all +# PaPauseQuest_00 root children at once). Each part here is used by exactly one layout, at the origin. +# Never squashed: Null_00 (full-height art), Null_01 (P_CaptureMask_00, full-frame mask), N_Cut_00 (list container/clip). +# Squashed: detail panel (frames, title/NPC/place/caption, Memories preview, CLEAR stamp capture), category tabs, and the +# five list row slots (row pitch 70 -> 52.5). Played and checked: quest list + description (no more mid-word cut-off) and +# Memories with rows #6/#7 below #5 (no overlap). Two other variants were built for the bisect and not needed: panel only, +# and row contents only (PaChallengeListBtn_00 N_Born_00 + B_Hit_00, pitch kept). +PART_SQUASH_Y = { + 'PaPauseQuest_00': {'N_Type_00', 'N_TypeDemo_00', 'N_Capture_00', 'W_Base_00', 'W_Base_01', 'W_Base_02', 'N_Category_00'}, + 'PaPageChallenge5_00': {f'Pa_Btn_{i:02d}' for i in range(5)}, +} +# Gameplay-HUD enlargement (round 8): scale a HUD group by HUD_SCALE about a screen corner/anchor +# so it is as large as on 16:9 (1/0.75 = 1.3333) instead of 75% of it. {layout: {pane: (anchor_x, anchor_y)}}; anchors and +# pane translation are in the pane's PARENT-local units and the parent chain must have identity scale (true for children of +# the code-scaled N_All_00). BOTW_HUD_SCALE=1.0 turns it off. +HUD_SCALE = float(_os.environ.get('BOTW_HUD_SCALE', '1.3333333')) # 1.0 = off (also the baseline build for verify check 20) +_TL, _BR = (-640.0, 360.0), (640.0, -360.0) # visible-canvas corners (layout units, parent chain identity) +HUD_PANES = { + 'MainScreen_00': { + 'N_State_00': _TL, # hearts + 'Pa_SinJu_00': _TL, 'Pa_SinJu_01': _TL, 'Pa_SinJu_02': _TL, 'Pa_SinJu_03': _TL, # Divine Beast gauges (left edge) + 'Pa_Sensor_00': _BR, 'Pa_SoundGauge_00': _BR, 'Pa_TempMeter_00': _BR, 'Pa_Time_00': _BR, # sensor / noise / temperature / clock + }, + 'MainShortCut_00': {'N_MainAll_00': _TL}, # weapon / shield / bow / arrow icons +} +# Pane names whose translation the game code writes (cannot be factored; reported only). +CODE_TRANS_PANES = {'N_Pos_00', 'N_Full_00', 'N_Gauge_00', 'N_DmcCapturePos_00', 'N_CopyRight_00', + 'N_TextOut_00', 'T_TextBox'} +PIVOT_SPLIT = { # layout -> {pan1 containers never shifted whole; children judged separately} + # N_State_01 sits at the bottom-left corner (-554,-314) and its child Pa_PlayerStatusUp_00 counter-translates + # +608 to the TOP-left (abs y 294, under the hearts). The child is itself an edge pane, so the generic pivot + # test ("child not edge") missed it and shifting the container moved the child 120 TOWARDS the centre (174). + 'PauseMenuInfo_00': {'N_State_01'}, +} +PROP_GROW = { # layout -> {pane: 'h'} screen-proportional wnd1 decoration, height x K + # (centre kept, no coverage requirement). Stock: 574-tall rule lines / 608-tall vignette inside a 720 screen. + # 'SeekPadMenuBG_00': W_Shadow_00 'h' (608 -> 811) DROPPED in the merge: Sheikah-slate layout, sheikah's EXACT_H 848 wins +} + +# Art that grows UNIFORMLY (width and height x K, centre kept): textured pictures that must keep their aspect. +# Title wallpaper slots 0 and 6: 1920x1080 sky + foreground at ty -30/-45, skipped by the generic fill rule (|ay|>10). +UNIFORM_GROW = { + 'Title_00': {'P_MainV_00', 'P_MainV_01', 'P_MainV_02', 'P_MainV_03', + 'P_MainVOE_00', 'P_MainVOE_01', 'P_MainVE_00', 'P_MainVE_01'}, + 'DLCWindow_00': {'WUPP_ALZ_illu06_1_R_ad-0'}, +} +# Edge-anchored decoration that must move out WITH the header/footer rows: height += amount (pre-scale units), centre kept. +# (x K would scale the distance to the edge, not keep it.) PauseMenuBG_00: BlackBG 758 -> 998 (outer edges 480 / -518), +# W_Line rings 574 -> 814. +EDGE_GROW = { + 'PauseMenuBG_00': {'W_BlackBG_00': 2 * 120.0, 'W_Line_00': 2 * 120.0, 'W_Line_02': 2 * 120.0}, +} +# Title wallpaper cut-outs (round 3): leaf panes under a 0.75 parent. Height x K alone is not enough: the leaf's own +# TransY (static + every key) must also be x K (parent carries 0.75; K*0.75 = 1 keeps the stock screen fraction). +# TransX/tx are NOT touched (right-anchored TitleBGLink keys are the exit from the screen). +UNIFORM_TY_GROW = { # layout -> panes grown uniformly x K by an own writer (TransY keys allowed) + 'Title_00': {'P_ImageArrow_00', 'TitleBG_01', 'P_Image_Gurdian_00', 'TitleBG_03', 'P_ImageHorse_00', 'TitleBG_02', + 'TitleBG_04', 'TitleBG_06', 'TitleBGLink_00', 'TitleBGLink_01'}, +} +LEAF_TY = { # layout -> panes whose static ty and TransY keys/slopes are x K + 'Title_00': {'P_ImageArrow_00', 'TitleBG_01', 'P_Image_Gurdian_00', 'TitleBG_03', 'P_ImageHorse_00', 'TitleBG_02', + 'TitleBG_04', 'TitleBG_06', 'TitleBGLink_00', 'TitleBGLink_01', + 'P_MainV_00', 'P_MainV_01', 'P_MainV_02', 'P_MainV_03', + 'P_MainVOE_00', 'P_MainVOE_01', 'P_MainVE_00', 'P_MainVE_01'}, +} +# live pane <-> capture-copy twin (must stay identical in the built layout) +TITLE_TWINS = [('P_ImageArrow_00', 'TitleBG_01'), ('P_Image_Gurdian_00', 'TitleBG_03'), ('P_ImageHorse_00', 'TitleBG_02'), + ('TitleBG_04', 'TitleBG_06'), ('TitleBGLink_00', 'TitleBGLink_01'), ('P_MainV_00', 'P_MainV_02'), + ('P_MainV_01', 'P_MainV_03'), ('P_MainVOE_00', 'P_MainVE_00'), ('P_MainVOE_01', 'P_MainVE_01')] +# CaptureBGColor (subtree-to-texture) sources that are full-frame glow layers: the source keeps its stock local size +# (the offscreen ortho is +-w/2 x +-h/2 of the LOCAL size), children keep the 0.75 pushdown, uses -> local h/0.75^n. +CAPTURE_BG_FULLFRAME = {'Title_00': {'N_Capture_00'}} +# panes whose SizeH (static and every key equal to 720) goes to the target: the Sheikah map scissor / capture uses +# (the 0.75 chain would clip the map to the middle 540 of 720). Keys at the mini-map pose (166/192/...) stay. +# Round 10 (played and checked): the capture SOURCES N_Capture_00-04 follow their uses (round 3 kept them at stock). +# Stock keeps each source and its use the same size in every pose (720 full map, 192 mini-map). With only the uses at 960 +# the terrain and grid were 1.33x too tall (grid cells measured 77.5 x 103 px) and drifted against the correct map names +# and icons when panning; with source = use they are square again (311 x 310 px). Black8_01 (the map backdrop inside +# N_Capture_00) already reaches 960 through the generic fill. +MAP_CAPTURE_PAIRS = {'N_Capture_00': 'P_MapCapture_00', 'N_Capture_01': 'P_MapCaptureBlur_00', + 'N_Capture_02': 'P_MapCaptureBlur_01', 'N_Capture_03': 'P_MapCaptureBlur_02', + 'N_Capture_04': 'P_MapCaptureBlur_03'} +SIZEH_RETARGET = { + 'AppMap_00': {'N_Cut_00': 960.0, 'P_MapCapture_00': 960.0, 'P_MapCaptureBlur_00': 960.0, 'P_MapCaptureBlur_01': 960.0, + 'P_MapCaptureBlur_02': 960.0, 'P_MapCaptureBlur_03': 960.0, + **{src: 960.0 for src in MAP_CAPTURE_PAIRS}}, +} +# CaptureApplyScale framebuffer sources (only these two exist in the game: the D-pad icon-list edge masks, 90x98 under a +# 0.75 chain). The engine multiplies the copy rect by (parent scale x own scale) only when a global VR-type flag is on, so +# the build must be correct with the flag on AND off: local h = stock h x 0.75 and own ScaleY = stock / 0.75^n (n = number of +# 0.75-scaled ancestors). Flag off: rect = 73.5 units; flag on: 73.5 x 0.75 x 1.333 = 73.5. The use panes stay as they are. +CAPTURE_APPLY_INVARIANT = {'MainShortCut_00': {'N_Capture_00', 'N_Capture_01'}} +# plain capture sources whose height simply follows their 0.75-scaled host (static SizeH and SizeH keys x 0.75): the HUD icon +# base capture; its TransY is NOT changed (the code writes N_DmcCapturePos_00 itself). +SRC_H_SCALE = {'MainShortCut_00': {'N_DmcCapture_00'}} +# panes that must move exactly like an anchor pane of the same layout (verify.py check 17): +# layout -> (anchor pane, {followers}). MessageSp_00: the circuit-arc end caps hang off N_SunLight_00 and must stay +# centred on the pill W_Base_01. +SHIFT_FOLLOW = {'MessageSp_00': ('W_Base_01', {'N_SunLight_00'})} +# panes exempt from the "ends inside the 4:3 height" checks (reviewed overshoot) +OVERSHOOT_OK = {} +for _d in (FORCE_FILL, UNIFORM_GROW, EDGE_GROW, UNIFORM_TY_GROW, LEAF_TY): + for _l, _n in _d.items(): + OVERSHOOT_OK.setdefault(_l, set()).update(_n) +# txt1 panes the game rescales by name (CODE_SCALE_PANES): when children_pass pushes SizeH x0.75 into them the glyphs +# must be squashed too (fontSizeY and lineSpace x0.75), or 3-line tips overflow their 0.75 box. +TXT_FONT_Y_LAYOUTS = {'MessageTipsRunTime_00', 'MessageTipsPauseMenu_00'} + +CONT_EXEMPT = {'P_ScanningLine_00'} # panes excluded from the frame-continuity check (capture-use window kept at stock size) + + +# ---- fullframe capture policy tables ---- +# Layouts whose capture panes are masked map views / Sheikah windows: untouched by the capture pass. +CAPTURE_SKIP_LAYOUTS = {'AppMap_00', 'AppMapDungeon_00'} +# Use panes whose size the game code sets itself at runtime (slide seams): untouched. +CAPTURE_SKIP_PREFIX = ('P_CaptureSlide',) +# Part layouts whose FBLayout use pane is a framebuffer copy: pane -> same rule as top-level uses, with n taken from +# the host prt1's parent chain (all use sites must agree, build.py warns and skips otherwise). +PART_CAPTURE_USE = { + 'PaPauseQuest_00': ['P_CaptureMask_00'], # source N_Capture_00 lives in PauseMenu_00 + 'PaSystemWindow_02': ['P_Capture_00'], # source N_Capture_00 in the part; host AppCamera_00 +} + + +# ---- Stamina wheel (PaGanbariGauge_01 = circle, PaGanbariGaugeEx_00 = extra-stamina bar) ---- +# The game code (class holding Pa_Ganbari_00 / Pa_GanbariEx_00, writes at 0x117c8e8 / 0x117cf24) overwrites both ScaleX and +# ScaleY of the host panes with one distance-based value (0.75..1.0), so a 0.75 on the host's ScaleY is lost and the wheel +# is drawn stretched. The squash lives in the part instead: the panes that hold every visible (capture-USE) picture of the +# part get ScaleY x0.75 (the CaptureOn sources stay stock; the uses just sample them into a flatter quad). The hosts' +# ScaleY is then put back to what the part-internal squash needs: net 0.75 everywhere (verify check 21). +PART_SY = { + 'PaGanbariGauge_01': {'N_All_00'}, + 'PaGanbariGaugeEx_00': {'N_AllL_00', 'N_AllL_01', 'N_AllR_00', 'N_AllR_01'}, +} +# layout -> {host pane: factor on its ScaleY applied AFTER the children pass}. MainScreen3D_00 hosts are direct root children +# (children pass already x0.75; x1/0.75 returns them to stock 1.0 because the part now squashes). PauseMenuInfo_00 hosts sit +# under a 0.75 chain (N_State_00), which the part would double: they get 1/0.75 so the chain nets 0.75 again. +HOST_SY_FACTOR = { + 'MainScreen3D_00': {'Pa_Ganbari_00': 1 / 0.75, 'Pa_GanbariEx_00': 1 / 0.75}, + 'PauseMenuInfo_00': {'Pa_Ganbari_00': 1 / 0.75, 'Pa_GanbariEx_00': 1 / 0.75}, +} +if os.environ.get('BOTW_GANBARI_FIX', '1') == '0': + PART_SY, HOST_SY_FACTOR = {}, {} diff --git a/the-legend-of-zelda-breath-of-the-wild/tools/hand-edited/exefs/1.6.0.pchtxt b/the-legend-of-zelda-breath-of-the-wild/tools/hand-edited/exefs/1.6.0.pchtxt new file mode 100644 index 0000000..ec505be --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/tools/hand-edited/exefs/1.6.0.pchtxt @@ -0,0 +1,21 @@ +@nsobid-8E9978D50BDD20B4C8395A106C27FFDE + +@flag print_values +@flag offset_shift 0x100 + +// Native 4x3 Aspect Ratio: 3D aspect ratio 16:9 -> exactly 4:3 (BOTW 1.6.0 only). +// Replaces the three aspect instructions used by the community 1.6.0 aspect patch (which writes fmov s0,#1.3125, 1.56% +// under 4/3) with LDR S0 of the exact float 4/3 = 3FAAAAAB, planted in zero padding after nearby RET instructions. +// Do NOT enable together with another BOTW aspect patch: they patch the same three addresses. + +@enabled +// 0x00E0AD68 was fdiv s0,s0,s1 -> ldr s0,#+0x104C (literal at 0xE0BDB4) +00E0AD68 6082001C +00E0BDB4 ABAAAA3F +// 0x015C2148 was fdiv s0,s0,s1 -> ldr s0,#+0xF0 (literal at 0x15C2238) +015C2148 8007001C +015C2238 ABAAAA3F +// 0x01271870 was ldr s0,[x0,#0xb0] -> ldr s0,#+8 (literal at 0x1271878, right after the ret) +01271870 4000001C +01271878 ABAAAA3F +@stop diff --git a/the-legend-of-zelda-breath-of-the-wild/tools/lyt.py b/the-legend-of-zelda-breath-of-the-wild/tools/lyt.py new file mode 100644 index 0000000..4147331 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/tools/lyt.py @@ -0,0 +1,269 @@ +"""SARC / Yaz0 / BFLYT / BFLAN reader for BOTW (Switch) that records byte offsets for in-place patching. + +Ported from the SMBW reference tools. BOTW differences: Yaz0 (.sblarc) archives, layouts authored at 1280x720, +one big archive (Common.sblarc) holding hundreds of layouts + animations. +""" +import struct, re + +LE_BOM = bytes([255, 254]) + + +# ---------------------------------------------------------------- Yaz0 +def yaz0_decompress(b): + assert b[:4] == b'Yaz0' + n = struct.unpack_from('>I', b, 4)[0] + out = bytearray(n) + o = 0 + p = 16 + L = len(b) + while o < n: + c = b[p]; p += 1 + for i in range(8): + if o >= n: + break + if c & (0x80 >> i): + out[o] = b[p]; p += 1; o += 1 + else: + x = (b[p] << 8) | b[p + 1]; p += 2 + d = (x & 0xFFF) + 1 + l = x >> 12 + if l == 0: + l = b[p] + 18; p += 1 + else: + l += 2 + s = o - d + if d >= l: + out[o:o + l] = out[s:s + l] + else: + for k in range(l): + out[o + k] = out[s + k] + o += l + return bytes(out) + + +def yaz0_compress(data, level=None): + """Greedy LZ77 Yaz0 encoder (hash-chain). Output is valid Yaz0; size differs from Nintendo's encoder.""" + n = len(data) + out = bytearray(b'Yaz0' + struct.pack('>I', n) + b'\0' * 8) + head = {} + prev = [-1] * n + i = 0 + grp = bytearray() + flags = 0 + nb = 0 + + def insert(pos): + if pos + 2 < n: + k = data[pos:pos + 3] + prev[pos] = head.get(k, -1) + head[k] = pos + + while i < n: + best_l, best_d = 0, 0 + if i + 2 < n: + k = data[i:i + 3] + cand = head.get(k, -1) + tries = 0 + maxl = min(0x111, n - i) + while cand >= 0 and i - cand <= 0x1000 and tries < 32: + l = 3 + while l < maxl and data[cand + l] == data[i + l]: + l += 1 + if l > best_l: + best_l, best_d = l, i - cand + if l == maxl: + break + cand = prev[cand] + tries += 1 + if best_l >= 3: + d = best_d - 1 + if best_l < 18: + grp += bytes([((best_l - 2) << 4) | (d >> 8), d & 0xFF]) + else: + grp += bytes([d >> 8, d & 0xFF, best_l - 18]) + for k in range(best_l): + insert(i + k) + i += best_l + else: + flags |= 0x80 >> nb + grp.append(data[i]) + insert(i) + i += 1 + nb += 1 + if nb == 8: + out.append(flags); out += grp + flags = 0; nb = 0; grp = bytearray() + if nb: + out.append(flags); out += grp + return bytes(out) + + +# ---------------------------------------------------------------- SARC +def sarc_entries(data): + """Return {name: (abs_start, abs_end)} for every file in a SARC.""" + assert data[:4] == b'SARC', data[:4] + e = '<' if data[6:8] == LE_BOM else '>' + hlen = struct.unpack_from(e + 'H', data, 4)[0] + data_off = struct.unpack_from(e + 'I', data, 0x0C)[0] + p = hlen + assert data[p:p + 4] == b'SFAT' + count = struct.unpack_from(e + 'H', data, p + 6)[0] + q = p + 12 + count * 16 + assert data[q:q + 4] == b'SFNT' + names_base = q + 8 + out = {} + for i in range(count): + h, attr, s, en = struct.unpack_from(e + 'IIII', data, p + 12 + i * 16) + no = (attr & 0xFFFF) * 4 + nm = data[names_base + no: data.index(b'\0', names_base + no)].decode() + out[nm] = (data_off + s, data_off + en) + return out + + +PANE_MAGIC = {b'pan1', b'pic1', b'txt1', b'wnd1', b'bnd1', b'prt1', b'scr1', b'ali1'} + + +class Pane: + def __init__(self, kind, name, off, tx, ty, sx, sy, w, h, rot, origin): + self.kind, self.name, self.off = kind, name, off + self.tx, self.ty, self.sx, self.sy, self.w, self.h = tx, ty, sx, sy, w, h + self.rot, self.origin = rot, origin + self.children, self.parent = [], None + self.usd = b'' + + TX, TY, SX, SY, W, H = 44, 48, 68, 72, 76, 80 + + def walk(self): + yield self + for c in self.children: + yield from c.walk() + + def path(self): + p, n = [], self + while n: + p.append(n.name); n = n.parent + return '/'.join(reversed(p)) + + +def parse_flyt(d, base=0): + """Parse a BFLYT at d[base:]. Returns (layout_w, layout_h, root Pane).""" + assert d[base:base + 4] == b'FLYT' + assert d[base + 4:base + 6] == LE_BOM + hlen = struct.unpack_from(' cave{i + 1}')) +# cave: 3x (ldr s0, lit ; b back) + literal +for i in range(3): + pc = CAVE + 8 * i + lines.append((pc, LDR_S_LITERAL(0, pc, LIT), f'cave{i + 1}: ldr s0, lit')) + lines.append((pc + 4, B(pc + 4, RETS[i]), f'cave{i + 1}: b back')) +lines.append((LIT, 0x3FAAAAAB, 'literal 1.3333334f')) + +for off, w, note in lines: + b = struct.pack('> 2) & 3 + + +def parent_vert_origin(p): + return (p.origin >> 6) & 3 + + +def is_nominal_null(p): + return p.kind == 'pan1' and (p.w, p.h) == (30, 40) + + +def annotate(root): + """Absolute centre/size in root-local units (rotation ignored).""" + root.ax = root.ay = root.ay_origin = 0.0 + root.asx = root.asy = 1.0 + root.parent_sy = 1.0 + + def rec(p): + for c in p.children: + c.asx, c.asy = p.asx * c.sx, p.asy * c.sy + pvo = parent_vert_origin(c) + base_local = 0.0 + if pvo: + pv = vert_origin(p) if p is not root else 0 + rc = -p.h / 2 if pv == 1 else p.h / 2 if pv == 2 else 0.0 + base_local = rc + (p.h / 2 if pvo == 1 else -p.h / 2) + px, py = p.ax + p.asx * c.tx, p.ay_origin + p.asy * (base_local + c.ty) + vo = vert_origin(c) + hh = c.h * c.asy + c.ay_origin = py + c.ay = py - hh / 2 if vo == 1 else py + hh / 2 if vo == 2 else py + c.ax = px + c.ah, c.aw = abs(hh), abs(c.w * c.asx) + c.parent_sy = p.asy + rec(c) + root.ah, root.aw = root.h, root.w + rec(root) + + +def materials(raw, s): + """List of (name, [texture names]) for the bflyt at raw[s:].""" + hlen = struct.unpack_from('_.bflan""" + pre = 'anim/' + layout_name + '_' + return [n for n in ents if n.startswith(pre) and n.endswith('.bflan')] diff --git a/the-legend-of-zelda-breath-of-the-wild/tools/verify.py b/the-legend-of-zelda-breath-of-the-wild/tools/verify.py new file mode 100644 index 0000000..706f826 --- /dev/null +++ b/the-legend-of-zelda-breath-of-the-wild/tools/verify.py @@ -0,0 +1,1298 @@ +"""Verify a build against the ORIGINAL layouts (independent of build.py's decisions). + +usage: python -I verify.py +""" +import sys, os, struct, json, collections +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from rules import * +import curated as C + +SRC, OUT = sys.argv[1], sys.argv[2] +rep = json.load(open(os.path.join(OUT, 'build_report.json'))) +MODE = rep.get('_meta', {}).get('root_mode', 'root') # mode the build used +JOBS = [('Layout/BootUp.sblarc', None), ('Layout/Horse.sblarc', None), + ('Pack/Title.pack', 'Layout/Title.sblarc'), ('Pack/Bootup.pack', 'Layout/Common.sblarc')] +fails, warns = [], [] +if MODE != C.ROOT_MODE: + fails.append(f'build used ROOT_MODE={MODE!r} but verify runs with {C.ROOT_MODE!r} (set BOTW_ROOT_MODE the same)') +CSTAT = collections.Counter() + + +def top_eligible(ln, lw, lh): + """Layouts the build treats as top-level and scales (same condition as build.py).""" + return (lw, lh) == (1280.0, 720.0) and ln not in C.ROOT_SKIP and ln not in C.CURSOR_ROOT_KEEP + + +def tl(p): + """children mode (old tree): True when build.children_pass visits pane p (direct child of the root, or child of a + visited, unrotated, code-rescaled pane).""" + if p.parent is None or p.name in C.NO_SCALE_NAMES: + return False + if p.parent.parent is None: + return True + q = p.parent + return q.name in C.CODE_SCALE_PANES and q.rot == (0.0, 0.0, 0.0) and tl(q) + + +def kind(p): + """'scale' | 'pd' (code-rescaled: factor goes to children/SizeH) | None (untouched), for an OLD-tree pane.""" + if not tl(p) or p.rot != (0.0, 0.0, 0.0): + return None + return 'pd' if p.name in C.CODE_SCALE_PANES else 'scale' + + +def norm_children(rt): + """children mode: annotate() values of the new tree are ROOT_SY x the root-mode equivalent in Y; undo that + so every geometric check below stays in root-local units exactly as for the root mode.""" + for q in rt.walk(): + if q is rt: + continue + q.ay *= K; q.ay_origin *= K; q.ah *= K; q.asy *= K + if q.parent is not rt: + q.parent_sy *= K +cont_stats = {} +seen_lk = set() +ALL_REFS = set() +for _o, _i in JOBS: + _r, _e = load_archive(os.path.join(SRC, _o), _i) + for _n in _e: + if _n.endswith('.bflyt'): + ALL_REFS |= part_refs(_r, _e[_n][0]) + + +def _norm_tree(ln, rt, lw, lh): + """children mode: bring the new tree's annotate() values back to root-local units (same helper as the other checks).""" + if MODE == 'children' and top_eligible(ln, lw, lh) and ln not in ALL_REFS: + norm_children(rt) + + +def _ty_root_local(a_old, v): + """children mode: a visited pane's TransY (static or key) carries the factor ROOT_SY (+ the root-edge base term); + undo it so shifts are compared in the old units. a_old: the pane in the OLD tree.""" + if MODE == 'children' and tl(a_old): + base = 0.0 + pvo = parent_vert_origin(a_old) if a_old.parent.parent is None else 0 + if pvo: + base = a_old.parent.h / 2 if pvo == 1 else -a_old.parent.h / 2 + return (v - (ROOT_SY - 1) * base) / ROOT_SY + return v + + +def F(m): fails.append(m) +def Wn(m): warns.append(m) + + +# ---- Sheikah frame helpers ---- +def xrange_(p): + h = p.origin & 3 # 0 centre, 1 left (anchor = left edge), 2 right (anchor = right edge) + return (p.ax, p.ax + p.aw) if h == 1 else (p.ax - p.aw, p.ax) if h == 2 else (p.ax - p.aw / 2, p.ax + p.aw / 2) + + +def yrange_(p): + return (p.ay - p.ah / 2, p.ay + p.ah / 2) + + +def ygap(a, b): + (alo, ahi), (blo, bhi) = yrange_(a), yrange_(b) + return max(blo - ahi, alo - bhi) + + +def xoverlap(a, b): + (alo, ahi), (blo, bhi) = xrange_(a), xrange_(b) + return min(ahi, bhi) - max(alo, blo) + + +def continuity(tag, po_list, pn_list): + """Frame continuity: every pair of drawn leaf panes that touched (vertical gap <= 1.5 px) or overlapped while + sharing horizontal extent in the ORIGINAL must still touch/overlap in the new tree. Returns number of pairs.""" + leaf = [(a, b) for a, b in zip(po_list, pn_list) + if a.kind in ('pic1', 'txt1', 'wnd1', 'prt1') and a.ah >= 1 and a.aw >= 1 + and not (a.kind == 'prt1' and a.ah > 300) and a.name not in getattr(C, 'CONT_EXEMPT', ())] # big prt1 boxes are layout-sized placeholders (Pa_Deco_00) + n = 0 + for i in range(len(leaf)): + for j in range(i + 1, len(leaf)): + a, b = leaf[i][0], leaf[j][0] + if xoverlap(a, b) <= 2 or ygap(a, b) > 1.5: + continue + n += 1 + a2, b2 = leaf[i][1], leaf[j][1] + if ygap(a2, b2) > 1.5 or xoverlap(a2, b2) <= 2: + F(f'{tag}: frame continuity broken {a.name} / {b.name} ' + f'(gap {ygap(a, b):.1f} -> {ygap(a2, b2):.1f})') + return n + + +assert abs(C.WINDOW_H - (608 + 2 * DELTA)) < 1e-6, 'WINDOW_H must be the 608 window grown by 2*DELTA' + + +# 0. game-files policy (docs/game-files-policy.md): every archive in the output must differ from the original, and no +# archive the build left unchanged may be present (a stale copy from an older build would ship an original file). +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + if not rep[outrel]['writes']: + F(f'{outrel}: present in the output but the build changed nothing in it (stale or original archive)') + continue + if load_archive(n_path, inner)[0] == load_archive(os.path.join(SRC, outrel), inner)[0]: + F(f'{outrel}: identical to the original archive (must not be shipped)') +for root_dir, _, fnames in os.walk(OUT): + for fn in fnames: + rel = os.path.relpath(os.path.join(root_dir, fn), OUT).replace(os.sep, '/') + if rel not in {o for o, _ in JOBS} and rel != 'build_report.json': + F(f'{rel}: not a build output (only {sorted(o for o, _ in JOBS)} may be in the output dir)') + +for outrel, inner in JOBS: + if not rep[outrel]['writes']: + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + F(f'{outrel}: output missing'); continue + n_raw, n_ents = load_archive(n_path, inner) + # 1. structure + if len(o_raw) != len(n_raw): F(f'{outrel}: decompressed size differs'); continue + if {k: (v[0], v[1]) for k, v in o_ents.items()} != {k: (v[0], v[1]) for k, v in n_ents.items()}: + F(f'{outrel}: SARC table differs') + # 2. changed bytes == logged writes + logged = {} + for off, a, b, what in rep[outrel]['writes']: + logged[off] = b # last write wins + changed = set() + diff = [i for i in range(len(o_raw)) if o_raw[i] != n_raw[i]] if len(o_raw) < 4_000_000 else None + if diff is None: + import itertools + diff = [] + # chunked compare + step = 1 << 20 + for st in range(0, len(o_raw), step): + a, b = o_raw[st:st + step], n_raw[st:st + step] + if a != b: + diff += [st + i for i in range(len(a)) if a[i] != b[i]] + covered = set() + for off in logged: + for i in range(4): + covered.add(off + i) + stray = [i for i in diff if i not in covered] + if stray: F(f'{outrel}: {len(stray)} changed bytes outside logged writes (first {stray[0]:#x})') + for off, val in logged.items(): + got = struct.unpack_from(' 1e-4 * max(1, abs(val)): + F(f'{outrel}: logged write at {off:#x} not present ({got} != {val})') + # 3. re-parse everything + fl = sorted(n for n in n_ents if n.endswith('.bflyt')) + referenced = ALL_REFS + for n in n_ents: + if n.endswith('.bflan'): + try: parse_flan(n_raw, n_ents[n][0]) + except Exception as ex: F(f'{outrel}: {n} fails to parse: {ex}') + for n in fl: + ln = n[5:-6] + so, _ = o_ents[n]; sn, _ = n_ents[n] + try: + lw, lh, ro = parse_flyt(o_raw, so); _, _, rn = parse_flyt(n_raw, sn) + except Exception as ex: + F(f'{outrel}: {n} fails to parse: {ex}'); continue + # 4. parts keep root (1, 1) + if ln in referenced and (rn.sx, rn.sy) != (ro.sx, ro.sy): + F(f'{ln}: part root changed') + if MODE == 'children' and (rn.sx, rn.sy) != (ro.sx, ro.sy): + F(f'{ln}: children mode must leave RootPane scale untouched, got ({rn.sx},{rn.sy})') + if (MODE == 'root' and ln not in referenced and ln not in ('Fade_00', 'Thanks_00') + and ln not in __import__('curated').ROOT_SKIP and ln not in C.CURSOR_ROOT_KEEP and (lw, lh) == (1280.0, 720.0)): + if abs(rn.sy - ro.sy * ROOT_SY) > 1e-6: F(f'{ln}: top-level root scale {rn.sy}') + if ln in referenced: + # 4b. curated part fills / shifts: geometry re-derived from the original + fills = C.PART_FILL.get(ln, {}) + shifts = C.PART_SHIFT.get(ln, set()) + exact = C.PART_EXACT_H.get(ln, {}) + shift_y = C.PART_SHIFT_Y.get(ln, {}) + ty_scale = C.PART_TY_SCALE.get(ln, {}) + grow_h = C.PART_GROW_H.get(ln, {}) + if fills or shifts or exact or shift_y or ty_scale or grow_h: + for an in layout_anims(n_ents, ln): + for pane, im, tm, tg, ct, keys in parse_flan(n_raw, n_ents[an][0]): + if pane == 'RootPane' and not im: + F(f'{ln}: {an} animates RootPane') + annotate(ro); annotate(rn) + po = {p.path(): p for p in ro.walk()}; pn = {p.path(): p for p in rn.walk()} + if set(po) != set(pn): + F(f'{ln}: part pane set differs'); continue + no_ = {}; nn_ = {} + for p in po.values(): no_.setdefault(p.name, p) + for p in pn.values(): nn_.setdefault(p.name, p) + for pname, mode in fills.items(): + a, b = no_.get(pname), nn_.get(pname) + if a is None or b is None: + F(f'{ln}: curated part pane {pname} missing'); continue + factor = (C.PART_FILL_H.get(ln, 2 * HALF_VIS) / a.h) if mode in 'HU' else K + if abs(b.h - a.h * factor) > 0.5: + F(f'{ln}/{pname}: height {b.h:.1f}, expected {a.h * factor:.1f}') + if mode in 'uU' and abs(b.w - a.w * factor) > 0.5: + F(f'{ln}/{pname}: width {b.w:.1f}, expected {a.w * factor:.1f}') + if abs(b.ay - a.ay) > 1.5: + F(f'{ln}/{pname}: fill moved the centre (ay {a.ay:.1f} -> {b.ay:.1f})') + if b.ah < 2 * HALF_VIS - 1: + F(f'{ln}/{pname}: grown to {b.ah:.0f}, short of {2 * HALF_VIS:.0f}') + for pname in sorted(shifts): + a, b = no_.get(pname), nn_.get(pname) + if a is None or b is None: + F(f'{ln}: curated part pane {pname} missing'); continue + sign = 1 if a.ay > 0 else -1 + want = sign * DELTA / a.parent_sy + if abs((b.ty - a.ty) - want) > 0.5: + F(f'{ln}/{pname}: shift {b.ty - a.ty:.1f}, expected {want:.1f}') + pairs = [(a, b)] + for ca, cb in pairs: + if abs(ca.ay) + ca.ah / 2 <= H0 / 2 + 1 and abs(cb.ay) + cb.ah / 2 > HALF_VIS + 1: + F(f'{ln}/{pname}/{ca.name}: now extends to {abs(cb.ay) + cb.ah / 2:.0f} (> {HALF_VIS:.0f})') + pairs.extend(zip(ca.children, cb.children)) + # exact-height windows + for pname, hh in exact.items(): + a, b = no_.get(pname), nn_.get(pname) + if a is None or b is None: + F(f'{ln}: curated exact pane {pname} missing'); continue + if abs(b.h - hh) > 0.5: F(f'{ln}/{pname}: exact height {b.h:.1f}, expected {hh:.1f}') + if abs(hh - C.WINDOW_H) > 1e-6: F(f'{ln}/{pname}: exact height {hh} is not the window height') + if abs(b.ay - a.ay) > 1.5: F(f'{ln}/{pname}: exact-height pane moved its centre') + # round 10: fixed height growth (stock + dh, centre kept, width/scale/translation X untouched) + for pname, dh in grow_h.items(): + a, b = no_.get(pname), nn_.get(pname) + if a is None or b is None: + F(f'{ln}: curated grow-h pane {pname} missing'); continue + if abs(b.h - (a.h + dh)) > 0.5: F(f'{ln}/{pname}: height {b.h:.1f}, expected {a.h + dh:.1f}') + if abs(b.w - a.w) > 0.01 or abs(b.sy - a.sy) > 1e-6 or abs(b.tx - a.tx) > 0.01: + F(f'{ln}/{pname}: grow-h changed width/scale/x') + if abs(b.ay - a.ay) > 0.5: F(f'{ln}/{pname}: grow-h moved the centre (ay {a.ay:.1f} -> {b.ay:.1f})') + if abs(b.w - a.w) > 0.5: F(f'{ln}/{pname}: exact-height pane changed width') + # explicit signed shifts: static ty, and ONLY the final pose of multi-key TransY curves + oa = {}; na = {} + for an in layout_anims(n_ents, ln): + for pane, im, tm, tg, ct, keys in parse_flan(o_raw, o_ents[an][0]): + if not im and tg == 1: oa[(an, pane)] = keys + for pane, im, tm, tg, ct, keys in parse_flan(n_raw, n_ents[an][0]): + if not im and tg == 1: na[(an, pane)] = keys + for pname, dy in shift_y.items(): + a, b = no_.get(pname), nn_.get(pname) + if a is None or b is None: + F(f'{ln}: curated shift-y pane {pname} missing'); continue + if abs((b.ty - a.ty) - dy) > 0.5: F(f'{ln}/{pname}: shift-y {b.ty - a.ty:.1f}, expected {dy:.1f}') + for (an, pn_), ko in oa.items(): + if pn_ != pname: continue + kn = na[(an, pn_)] + for idx, (x, y) in enumerate(zip(ko, kn)): + last = idx == len(ko) - 1 and len(ko) >= 2 + want = x.value + dy if last else x.value + if abs(y.value - want) > 0.01: + F(f'{ln}/{pname}: {an} key {idx} value {y.value:.2f}, expected {want:.2f}') + for pname, fac in ty_scale.items(): + a, b = no_.get(pname), nn_.get(pname) + if a is None or b is None: + F(f'{ln}: curated ty-scale pane {pname} missing'); continue + if abs(b.ty - a.ty * fac) > 0.01: F(f'{ln}/{pname}: ty {b.ty:.2f}, expected {a.ty * fac:.2f}') + for (an, pn_), ko in oa.items(): + if pn_ != pname: continue + for x, y in zip(ko, na[(an, pn_)]): + if abs(y.value - x.value * fac) > 0.01: + F(f'{ln}/{pname}: {an} key value {y.value:.2f}, expected {x.value * fac:.2f}') + # frame continuity inside the part (touching / overlapping pairs must stay so) + # (PaAppMapSensor_00 mixes two groups that overlap by coincidence - popup shadow vs pill effect + # lines - and PaDLCTipsBefore_00's buttons leave the art by design: both excluded) + if ln in ('PaSeekPadScanningLine_00', 'PaCameraPointer_00', 'PaAppSystemWindow_00', + 'PaAppMapSensorSetting_00'): + cont_stats[ln] = continuity(ln, list(ro.walk()), list(rn.walk())) + continue + annotate(ro); annotate(rn) + po = {p.path(): p for p in ro.walk()}; pn = {p.path(): p for p in rn.walk()} + if set(po) != set(pn): F(f'{ln}: pane set differs'); continue + elig = top_eligible(ln, lw, lh) + # 0. scale integrity (both modes): ScaleX never changes anywhere; ScaleY changes only where the mode says + for path, a in po.items(): + b = pn[path] + hf = C.HUD_SCALE if (abs(C.HUD_SCALE - 1.0) > 1e-6 and a.name in C.HUD_PANES.get(ln, {})) else 1.0 + gf = C.HOST_SY_FACTOR.get(ln, {}).get(a.name, 1.0) # stamina-wheel host compensation (check 21) + if abs(b.sx - a.sx * hf) > (1e-6 if hf != 1.0 else 0): + F(f'{ln}/{a.name}: ScaleX changed {a.sx} -> {b.sx}') + if a is ro: + continue + kd = kind(a) if (MODE == 'children' and elig) else None + if MODE == 'children' and elig and tl(a): + if kd is None: + if b.sy != a.sy: F(f'{ln}/{a.name}: rotated pane must stay unscaled') + CSTAT['rotated_visited'] += 1 + elif kd == 'pd': + if b.sy != a.sy: F(f'{ln}/{a.name}: code-rescaled pane ScaleY changed {a.sy} -> {b.sy}') + CSTAT['pushdown'] += 1 + else: + if abs(b.sy - a.sy * ROOT_SY * hf * gf) > 1e-6: F(f'{ln}/{a.name}: ScaleY {b.sy}, expected {a.sy * ROOT_SY * hf * gf}') + CSTAT['scaled'] += 1 + elif gf != 1.0: + if abs(b.sy - a.sy * gf) > 1e-6: F(f'{ln}/{a.name}: stamina host ScaleY {b.sy}, expected {a.sy * gf}') + elif b.sy != a.sy and a.name not in C.CAPTURE_APPLY_INVARIANT.get(ln, ()): # check 16 owns these + F(f'{ln}/{a.name}: ScaleY changed {a.sy} -> {b.sy} (only visited panes may change, and only in children mode)') + if MODE == 'children' and elig: + # 10. direct-child animation keys follow the static value; ScaleY keys scale by ROOT_SY + for an in layout_anims(n_ents, ln): + olds = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(o_raw, o_ents[an][0]) if not im_} + news = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(n_raw, n_ents[an][0]) if not im_} + for (pn_, tg_), ko in olds.items(): + if tg_ not in (1, 7): + continue + a = next((q for q in ro.walk() if q.name == pn_ and tl(q)), None) + if a is None: + continue + if tg_ == 1 and pn_ in C.LAST_KEY_SHIFT.get(ln, {}): + continue # final pose moved on purpose (checked by the last-key check below) + b = pn[a.path()] + kn = news[(pn_, tg_)] + if tg_ == 7: + want = ROOT_SY if kind(a) == 'scale' else 1.0 + for x, y in zip(ko, kn): + if x.slope is None: continue + if abs(y.value - x.value * want) > 1e-4 * max(1, abs(x.value)) or abs(y.slope - x.slope * want) > 1e-4 * max(1, abs(x.slope)): + F(f'{ln}/{pn_}: ScaleY keys in {an} not x{want}'); break + CSTAT['sy_key_curves'] += 1 + else: + base = 0.0 + pvo = parent_vert_origin(a) if a.parent is ro else 0 + if pvo: base = ro.h / 2 if pvo == 1 else -ro.h / 2 + sh = (b.ty - (ROOT_SY - 1) * base) / ROOT_SY - a.ty + okay_add = okay_mul = True + for x, y in zip(ko, kn): + eq = (y.value - (ROOT_SY - 1) * base) / ROOT_SY + if abs(eq - x.value - sh) > 0.02: okay_add = False + if abs(eq - x.value * K) > 0.02 * max(1, abs(x.value)): okay_mul = False + if x.slope is not None and abs(y.slope / ROOT_SY - x.slope) > 1e-3 * max(1, abs(x.slope)) and abs(y.slope / ROOT_SY - x.slope * K) > 1e-3 * max(1, abs(x.slope)): + okay_add = okay_mul = False + if not (okay_add or okay_mul): + F(f'{ln}/{pn_}: TransY keys in {an} inconsistent with the static value after the x{ROOT_SY} factor') + CSTAT['ty_key_curves'] += 1 + norm_children(rn) + # animation checks + for an in layout_anims(n_ents, ln): + for pane, im, tm, tg, ct, keys in parse_flan(n_raw, n_ents[an][0]): + if pane == 'RootPane' and not im: F(f'{ln}: {an} animates RootPane') + for path, a in po.items(): + b = pn[path] + if a is ro: continue + vis_o = abs(a.ay) - a.ah / 2 < H0 / 2 and a.ah > 0 + # 5. nothing that was on screen ends past the new visible edge + # (FORCE_FILL panes are reviewed exceptions: they intentionally overshoot one edge) + if (vis_o and a.name not in C.OVERSHOOT_OK.get(ln, ()) + and abs(b.ay) + b.ah / 2 > HALF_VIS + 1 and abs(a.ay) + a.ah / 2 <= H0 / 2 + 1): + F(f'{ln}/{a.name}: now extends to {abs(b.ay) + b.ah / 2:.0f} (> {HALF_VIS:.0f})') + # 6. filled panes cover the visible area and are centred + if b.ah > a.ah + 0.5 and b.kind in ('pic1', 'wnd1', 'scr1', 'pan1'): + if b.ah < 2 * HALF_VIS - 1 and abs(b.ay) < 5 and a.name not in C.PROP_GROW.get(ln, {}) and a.name not in C.EXACT_H.get(ln, ()): + Wn(f'{ln}/{a.name}: grown to {b.ah:.0f}, short of {2 * HALF_VIS:.0f}') + if abs(b.ay) > 1 and abs(a.ay) <= 1: + Wn(f'{ln}/{a.name}: grown but off-centre ({b.ay:.0f})') + # 8. full-width element that touched the old edge now touches the new one (or was a deliberate keep) + touched = abs(abs(a.ay) + a.ah / 2 - H0 / 2) <= 1.5 and a.aw >= 0.95 * lw and a.ah < H0 * 0.9 + if touched and abs(abs(b.ay) + b.ah / 2 - HALF_VIS) > 1.5: + Wn(f'{ln}/{a.name}: full-width strip touched the old edge, now at {abs(b.ay) + b.ah / 2:.0f}') + # 7. fill pane with a size animation on the grown axis: keys must be scaled by exactly K + if b.ah > a.ah + 0.5 and a.name not in C.SIZEH_RETARGET.get(ln, {}): # retargeted panes: check 15 + for an in layout_anims(n_ents, ln): + olds = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(o_raw, o_ents[an][0]) if not im_} + news = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(n_raw, n_ents[an][0]) if not im_} + ko = olds.get((a.name, 9)) + if ko is None: + continue + kn = news[(a.name, 9)] + want = K * (ROOT_SY if (MODE == 'children' and elig and kind(a) == 'pd') else 1.0) + for x, y in zip(ko, kn): + if abs(y.value - x.value * want) > 1e-3 * max(1, abs(x.value)) or (x.slope is not None and abs(y.slope - x.slope * want) > 1e-3 * max(1, abs(x.slope))): + F(f'{ln}/{a.name}: height keys in {an} not scaled by {want:.4f}') + break + # 6a. top-level exact-height windows and final-pose shifts + for pname, hh in C.EXACT_H.get(ln, {}).items(): + a = next((p for p in po.values() if p.name == pname), None) + b = next((p for p in pn.values() if p.name == pname), None) + if a is None or b is None: F(f'{ln}: exact-height pane {pname} missing'); continue + # root mode: the pane's own SizeH; children mode: effective (root-local) height, since the factor may sit on ScaleY + hh_now, hh_want = (b.h, hh) if MODE == 'root' else (b.ah, hh * a.ah / a.h) + if abs(hh_now - hh_want) > 0.5: F(f'{ln}/{pname}: exact height {hh_now:.1f}, expected {hh_want:.1f}') + if abs(hh - C.WINDOW_H) > 1e-6: F(f'{ln}/{pname}: exact height {hh} is not the window height') + if abs(b.ay - a.ay) > 1.5 or abs(b.w - a.w) > 0.5: F(f'{ln}/{pname}: exact-height pane moved / changed width') + lk = C.LAST_KEY_SHIFT.get(ln, {}) + if lk: + for an in layout_anims(n_ents, ln): + olds = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(o_raw, o_ents[an][0]) if not im_} + news = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(n_raw, n_ents[an][0]) if not im_} + for pname, dy in lk.items(): + ko = olds.get((pname, 1)) + if ko is None or len(ko) < 2: continue + seen_lk.add((ln, pname)) + a_lk = next((p for p in po.values() if p.name == pname), None) + for idx, (x, y) in enumerate(zip(ko, news[(pname, 1)])): + want = x.value + (dy if idx == len(ko) - 1 else 0) + yv = _ty_root_local(a_lk, y.value) if (a_lk is not None and elig) else y.value # children mode: undo x ROOT_SY + if abs(yv - want) > 0.01: + F(f'{ln}/{pname}: {an} TransY key {idx} {yv:.2f}, expected {want:.2f}') + # 6b. curated force fills: grown by exactly K around their centre, covering the 4:3 height + for pname in C.FORCE_FILL.get(ln, ()): + a = next((p for p in po.values() if p.name == pname), None) + b = next((p for p in pn.values() if p.name == pname), None) + if a is None or b is None: + F(f'{ln}: force-fill pane {pname} missing'); continue + if MODE == 'root' and abs(b.h - a.h * K) > 0.5: + F(f'{ln}/{pname}: force-fill height {b.h:.1f}, expected {a.h * K:.1f}') + if abs(b.ah - a.ah * K) > 0.5: + F(f'{ln}/{pname}: force-fill effective height {b.ah:.1f}, expected {a.ah * K:.1f}') + if abs(b.ay - a.ay) > 1.5: + F(f'{ln}/{pname}: force-fill moved the centre (ay {a.ay:.1f} -> {b.ay:.1f})') + if b.ah < 2 * HALF_VIS - 1: + F(f'{ln}/{pname}: force-fill grown to {b.ah:.0f}, short of {2 * HALF_VIS:.0f}') + +# 9. curated parts: every prt1 use site must keep the geometry the part edit assumed. +# Scale must stay (1, 1); shifted parts must sit at the layout origin; filled panes must cover +# the 4:3 height at every use site (combined centre = prt1 origin + part-local pane centre; +# X is not checked: the mod never changes horizontal geometry). +part_roots = {} +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + n_raw, n_ents = load_archive(n_path, inner) + for part in set(C.PART_FILL) | set(C.PART_SHIFT) | set(C.PART_EXACT_H) | set(C.PART_SHIFT_Y) | set(C.PART_TY_SCALE): + nm = 'blyt/' + part + '.bflyt' + if nm in n_ents and part not in part_roots: + _, _, rt = parse_flyt(n_raw, n_ents[nm][0]) + annotate(rt) + part_roots[part] = {p.name: p for p in rt.walk()} +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + n_raw, n_ents = load_archive(n_path, inner) + for n in n_ents: + if not n.endswith('.bflyt'): + continue + _, _, rt = parse_flyt(n_raw, n_ents[n][0]) + secs = [p for mag, p, s in flyt_tags(n_raw, n_ents[n][0], {b'prt1'})] + panes = [q for q in rt.walk() if q.kind == 'prt1'] + if len(secs) != len(panes): + Wn(f'{n}: prt1 section/pane count mismatch, use-site check skipped') + continue + annotate(rt) + if MODE == 'children' and top_eligible(n[5:-6], *parse_flyt(n_raw, n_ents[n][0])[:2]) and n[5:-6] not in ALL_REFS: + norm_children(rt) + for p, q in zip(secs, panes): + part = prt1_name(n_raw, p) + if part not in part_roots: + continue + if abs(q.asx - 1) > 1e-4 or abs(q.asy - 1) > 1e-4: + F(f'{part}: used by {n[5:-6]}/{q.name} at scale ({q.asx:.3f},{q.asy:.3f}); part edit assumes (1, 1)') + if part in C.PART_SHIFT and (abs(q.ax) > 1 or abs(q.ay_origin) > 1): + F(f'{part}: shifted part used by {n[5:-6]}/{q.name} off-origin ({q.ax:.1f},{q.ay_origin:.1f})') + for pname in C.PART_SHIFT_Y.get(part, ()): + pp = part_roots[part].get(pname) + if pp is None: continue + cy = q.ay_origin + pp.ay + if abs(cy) + pp.ah / 2 > HALF_VIS + 1: + F(f'{part}/{pname}: after shift-y it extends to {abs(cy) + pp.ah / 2:.0f} in {n[5:-6]}') + for pname in C.PART_FILL.get(part, ()): + pp = part_roots[part].get(pname) + if pp is None: + continue + cy = q.ay_origin + pp.ay + short = HALF_VIS - (pp.ah / 2 - abs(cy)) + if short > 64: + F(f'{part}/{pname}: {short:.0f}px short at one edge in {n[5:-6]}') + elif short > 24: + Wn(f'{part}/{pname}: {short:.0f}px short at one edge in {n[5:-6]}') + +# 10. HUD review extensions (sec/hud): (a) recurse through prt1 parts: nothing on screen in the original may end past the +# new visible edge once the part's own (shifted) contents are placed under the final prt1 position; +# (b) every TransY key of a shifted pane moved by exactly the pane's shift (independent of build.py); +# (c) HUD layouts: unshifted bottom/top blocks whose far edge was within 40 of the old edge are reported. +HUD_LAYOUTS = ['MainScreen_00', 'MainScreenMS_00', 'MainScreen3D_00', 'MainDungeon_00', 'MainHorse_00', 'MainHardMode_00', + 'Rupee_00', 'KeyNum_00', 'KologNum_00', 'MamoNum_00', 'Time_00', 'AkashiNum_00', 'EnergyMeterDLC_00', + 'WolfLinkHeartGauge_00', 'MainScreenHeartIchigekiDLC_00', 'DLCSinJuAkashiNum_00'] +_o_raw, _o_ents = load_archive(os.path.join(SRC, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') +_n_raw, _n_ents = load_archive(os.path.join(OUT, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + + +def _prts(raw, s): + return {p: prt1_name(raw, p) for m, p, sz in flyt_tags(raw, s, {b'prt1'})} + + +def _extents(ln, bo, bn, path, out, depth=0): + nm = 'blyt/' + ln + '.bflyt' + if nm not in _o_ents or depth > 4: + return + _lw, _lh, a_root = parse_flyt(_o_raw, _o_ents[nm][0]); _, _, b_root = parse_flyt(_n_raw, _n_ents[nm][0]) + annotate(a_root); annotate(b_root) + if depth == 0: + _norm_tree(ln, b_root, _lw, _lh) + pr = _prts(_o_raw, _o_ents[nm][0]) + for a, b in zip(a_root.walk(), b_root.walk()): + if a is a_root: + continue + if a.kind == 'prt1': + _extents(pr.get(a.off), bo + a.ay_origin, bn + b.ay_origin, path + '/' + a.name, out, depth + 1) + elif a.kind in ('pic1', 'txt1', 'wnd1') and a.ah > 0: + out.append((abs(bo + a.ay) + a.ah / 2, abs(bn + b.ay) + b.ah / 2, path + '/' + a.name, a.name)) + + +for _ln in HUD_LAYOUTS: + if 'blyt/' + _ln + '.bflyt' not in _o_ents: + continue + _out = [] + _extents(_ln, 0.0, 0.0, _ln, _out) + for o_, n_, p_, nm_ in _out: + if n_ > HALF_VIS + 1 and o_ <= H0 / 2 + 1 and nm_ not in C.OVERSHOOT_OK.get(_ln, ()) and 'ColdBG' not in nm_: + F(f'{p_}: far edge {o_:.0f} -> {n_:.0f} (> {HALF_VIS:.0f}) through part contents') + if o_ <= H0 / 2 + 1 and 0 < n_ - o_ < 119 and 'Scanning' not in p_: + Wn(f'{p_}: moved by {n_ - o_:.0f}, not the full {DELTA:.0f} (partial shift / fill)') + # (b) TransY key consistency + nm = 'blyt/' + _ln + '.bflyt' + _lw, _lh, ra = parse_flyt(_o_raw, _o_ents[nm][0]); _, _, rb = parse_flyt(_n_raw, _n_ents[nm][0]) + _apo = {} + _dty_a = {} + dty = {} + for a, b in zip(ra.walk(), rb.walk()): + if a is ra: + continue + _apo.setdefault(a.name, a) + d_ = _ty_root_local(a, b.ty) - a.ty + if abs(d_) > 1e-3: + dty[a.name] = d_ + for an in layout_anims(_o_ents, _ln): + ko = parse_flan(_o_raw, _o_ents[an][0]); kn = parse_flan(_n_raw, _n_ents[an][0]) + for (p_, im_, tm_, tg_, ct_, ks_), (_, _, _, _, _, kk_) in zip(ko, kn): + if im_ or tg_ != 1 or p_ not in dty or p_ in C.OVERSHOOT_OK.get(_ln, ()): + continue + for x_, y_ in zip(ks_, kk_): + yv_ = _ty_root_local(_apo[p_], y_.value) if p_ in _apo else y_.value + if abs((yv_ - x_.value) - dty[p_]) > 0.5 and abs(yv_ - x_.value * K) > 0.5: + F(f'{_ln}/{p_}: TransY key in {an} moved {yv_ - x_.value:.1f}, pane moved {dty[p_]:.1f}') + break + # (c) unshifted blocks near the old edge + annotate(ra); annotate(rb) + _norm_tree(_ln, rb, _lw, _lh) + for a, b in zip(ra.walk(), rb.walk()): + if a is ra or a.kind not in ('pic1', 'txt1', 'wnd1', 'prt1') or a.ah <= 0 or a.ah >= EDGE_MAXH: + continue + if abs(b.ay - a.ay) < 1e-3 and abs(a.ay) + a.ah / 2 >= THRESH - 40 and abs(a.ay) + a.ah / 2 <= H0 / 2 and abs(a.ay) > 100: + Wn(f'{_ln}/{a.name}: unshifted, far edge {abs(a.ay) + a.ah / 2:.0f} (old edge 360, threshold {THRESH:.0f})') + + +# ---- P. pause-menu / pivot / proportional-growth checks (additive) --------------------------------------- +PAUSE_SET = lambda ln: ln.startswith('PauseMenu') or ln in ('MessageTipsPauseMenu_00', 'SeekPadMenuBG_00') +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for n in sorted(o_ents): + if not n.endswith('.bflyt') or n not in n_ents: + continue + ln = n[5:-6] + lw, lh, ro = parse_flyt(o_raw, o_ents[n][0]); _, _, rn = parse_flyt(n_raw, n_ents[n][0]) + if ln in ALL_REFS or (lw, lh) != (1280.0, 720.0): + continue + annotate(ro); annotate(rn) + _norm_tree(ln, rn, lw, lh) + po = list(ro.walk()); pn = list(rn.walk()) + if len(po) != len(pn): + continue + by_o = {p.name: p for p in po}; by_n = {p.name: p for p in pn} + # P1. nothing is moved TOWARDS the centre by the edge pass (a child counter-translating out of a shifted + # container: the container moved outward, the child ended up closer to the centre than it was). + # Hard failure for the pause set, warning elsewhere (other sections own those layouts). + for a, b in zip(po, pn): + if a is ro or abs(b.ah - a.ah) > 0.5 or a.name in C.FORCE_SIGN.get(ln, {}): # FORCE_SIGN: direction chosen on purpose (hud) + continue + dy = b.ay - a.ay + if abs(a.ay) > 5 and abs(dy) > 0.5 and a.ay * dy < 0: + msg = f'{ln}/{a.name}: moved towards the centre (y {a.ay:.0f} -> {b.ay:.0f}); container shifted outward but child counter-translates' + (F if PAUSE_SET(ln) else Wn)(msg) + # P2. curated NO_SHIFT_SUBTREE / PIVOT_SPLIT contracts + for nm in C.NO_SHIFT_SUBTREE.get(ln, ()): + r0 = by_o.get(nm) + if r0 is None: + F(f'{ln}: NO_SHIFT_SUBTREE pane {nm} missing'); continue + for a in r0.walk(): + b = by_n[a.name] + if abs(b.ay - a.ay) > 0.5 or abs(b.ah - a.ah) > 0.5: + F(f'{ln}/{a.name}: inside NO_SHIFT_SUBTREE {nm} but moved ({a.ay:.0f} -> {b.ay:.0f})') + for nm in C.PIVOT_SPLIT.get(ln, ()): + a, b = by_o.get(nm), by_n.get(nm) + if a is None: + F(f'{ln}: PIVOT_SPLIT pane {nm} missing'); continue + if abs(_ty_root_local(a, b.ty) - a.ty) > 1e-3: + F(f'{ln}/{nm}: PIVOT_SPLIT container was shifted whole') + for ka, kb in zip(a.children, b.children): + want = (1 if ka.ay > 0 else -1) * DELTA + if abs(ka.ay) >= THRESH and abs((kb.ay - ka.ay) - want) > 0.5: + F(f'{ln}/{ka.name}: PIVOT_SPLIT child moved {kb.ay - ka.ay:.1f}, expected {want:.1f}') + # P4. proportional growth: height exactly xK, width/centre untouched, inside the 4:3 height + for nm in C.PROP_GROW.get(ln, ()): + a, b = by_o.get(nm), by_n.get(nm) + if a is None: + F(f'{ln}: PROP_GROW pane {nm} missing'); continue + if abs(b.h - a.h * K) > 0.5: F(f'{ln}/{nm}: prop-grow height {b.h:.1f}, expected {a.h * K:.1f}') + if abs(b.w - a.w) > 0.5: F(f'{ln}/{nm}: prop-grow changed width') + if abs(b.ay - a.ay) > 1.5: F(f'{ln}/{nm}: prop-grow moved the centre') + if abs(b.ay) + b.ah / 2 > HALF_VIS + 1 and nm not in C.OVERSHOOT_OK.get(ln, ()): + F(f'{ln}/{nm}: prop-grow extends to {abs(b.ay) + b.ah / 2:.0f} (> {HALF_VIS:.0f})') + # P5. pause set: every pane except the reviewed FORCE_FILL backdrops ends inside the 4:3 height + if PAUSE_SET(ln): + for b in pn: + if b is rn or b.name in C.OVERSHOOT_OK.get(ln, ()) or b.kind == 'pan1' and (b.w, b.h) == (30, 40): + continue + if abs(b.ay) + b.ah / 2 > HALF_VIS + 1: + F(f'{ln}/{b.name}: pause pane ends at {abs(b.ay) + b.ah / 2:.0f} (> {HALF_VIS:.0f})') + +# 10. screen-capture source/use consistency (FBLayout textures). A SOURCE is a pan1 whose name contains +# 'Capture'; a USE is a pic1 with an FBLayout* texture. Whatever the game does with the copied rectangle +# (scaled layout units or raw local pixels), a use pane drawn at another size than its source distorts +# and blurs the capture, and a pair that sat on the same rect must keep moving together. +# a. a use pane's w/h may change only together with an identical stock-equal-rect source (grow_source policy) +# b. a source whose size changed needs every stock-equal-rect use pane to end at exactly the same size +# c. stock-equal-rect source/use pairs keep the same net vertical displacement +n_pairs = 0 +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for n in sorted(o_ents): + if not n.endswith('.bflyt') or n not in n_ents: + continue + ln = n[5:-6] + lw, lh, ro = parse_flyt(o_raw, o_ents[n][0]); _, _, rn = parse_flyt(n_raw, n_ents[n][0]) + annotate(ro); annotate(rn) + _norm_tree(ln, rn, lw, lh) + mats = materials(o_raw, o_ents[n][0]) + pn_ = {p.path(): p for p in rn.walk()} + srcs = [p for p in ro.walk() if p.kind == 'pan1' and 'Capture' in p.name and 'Pos' not in p.name] + uses = [] + for p in ro.walk(): + if p.kind != 'pic1': + continue + mi = struct.unpack_from(' 0.5 or abs(sh(un) - sh(u)) > 0.5 + mates = [s_ for s_ in srcs if same_rect(s_, u)] + if size_changed: + ok = any(abs(sw(pn_[m.path()]) - sw(un)) <= 0.5 and abs(sh(pn_[m.path()]) - sh(un)) <= 0.5 for m in mates) + if not ok: + F(f'{ln}/{u.name}: capture use pane resized {sw(u):.0f}x{sh(u):.0f} -> {sw(un):.0f}x{sh(un):.0f} ' + f'without an identically resized source (stretched/blurred capture)') + for m in mates: + mn = pn_[m.path()] + n_pairs += 1 + if (abs(sw(mn) - sw(m)) > 0.5 or abs(sh(mn) - sh(m)) > 0.5) and ( + abs(sw(mn) - sw(un)) > 0.5 or abs(sh(mn) - sh(un)) > 0.5): + F(f'{ln}/{m.name}->{u.name}: source resized to {sw(mn):.0f}x{sh(mn):.0f}, use pane is {sw(un):.0f}x{sh(un):.0f}') + if abs((mn.ay - m.ay) - (un.ay - u.ay)) > 1.5: + F(f'{ln}/{m.name}->{u.name}: source moved {mn.ay - m.ay:+.0f}, use pane {un.ay - u.ay:+.0f} ' + f'(pair sat on the same rect in the original)') +print(f'capture source/use pairs checked: {n_pairs}') + +for ln_, pn_ in {(l, p_) for l, d in C.LAST_KEY_SHIFT.items() for p_ in d} - seen_lk: + F(f'{ln_}/{pn_}: curated last-key pane had no multi-key TransY curve to check') + +# 11. fullframe capture geometry (children mode). Independent of build.py: pairs are re-derived from the STOCK +# layout. Engine model (see curated.CAPTURE_POLICY): the copied rect has the source pane's LOCAL size at its +# global centre; the use pane draws the whole texture, so it is undistorted only when its projected height +# (local h x product of the scales in its chain; panes the game code rescales by name count as 1) equals the +# stock projected height AND the source keeps its stock local size. +def _proj_chain(p): + f = 1.0 + while p is not None and p.parent is not None: + f *= 1.0 if p.name in C.CODE_SCALE_PANES else p.sy + p = p.parent + return f + + +def _fb_uses(raw, s, root): + mats = materials(raw, s) + for u in root.walk(): + if u.kind != 'pic1': + continue + mi = struct.unpack_from(' 1.0: + F(f'{ln}/{qo.name}->{part}/{pname}: part capture use projects {pb:.1f}, stock {ps:.1f}') + if not top_eligible(ln, lw, lh) or ln in ALL_REFS or ln in C.CAPTURE_SKIP_LAYOUTS or ln in C.CURSOR_ROOT_KEEP: + continue + nmap = {id(a): b for a, b in zip(lo, lnw)} + for u in _fb_uses(o_raw, o_ents[n][0], ro): + if u.name.startswith(C.CAPTURE_SKIP_PREFIX): + continue + cands = [q for q in lo if q.kind == 'pan1' and 'Capture' in q.name and 'Pos' not in q.name + and abs(q.ax - u.ax) <= 2 and abs(q.ay - u.ay) <= 2 and abs(q.aw - u.aw) <= 2 + and abs(q.ah - u.ah) <= 2 and abs(q.w - u.w) <= 2 and abs(q.h - u.h) <= 2] + if not cands or any((b'CaptureBGColor' in q.usd and q.name not in C.CAPTURE_BG_FULLFRAME.get(ln, ())) + or b'CaptureApplyScale' in q.usd for q in cands): + continue + n_fb += 1 + un = nmap[id(u)] + ps, pb = u.h * _proj_chain(u), un.h * _proj_chain(un) + if abs(ps - pb) > 1.0: + F(f'{ln}/{u.name}: capture use projects {pb:.1f}, stock {ps:.1f} (source rect {cands[0].h:.0f}) ' + f'-> distorted / partial capture') + if abs(un.w - u.w) > 0.5: + F(f'{ln}/{u.name}: capture use width changed {u.w:.0f} -> {un.w:.0f}') + if u.h >= 0.95 * H0 and abs(u.ay) < 10 and pb < H0 - 1.0: + F(f'{ln}/{u.name}: full-frame capture use projects only {pb:.1f} of {H0:.0f} (bars)') + for q in cands: + qn = nmap[id(q)] + if abs(qn.h - q.h) > 0.5 or abs(qn.w - q.w) > 0.5: + F(f'{ln}/{q.name}: capture source size changed {q.w:.0f}x{q.h:.0f} -> {qn.w:.0f}x{qn.h:.0f}') +print(f'check 11: {n_fb} framebuffer-capture use panes checked against the stock projected size') + +# 12. selector layouts in CURSOR_ROOT_KEEP stay byte-identical to stock (layout, animations). +n_cur = 0 +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for ln in C.CURSOR_ROOT_KEEP: + for nm in o_ents: + if nm == 'blyt/' + ln + '.bflyt' or nm.startswith('anim/' + ln + '_'): + n_cur += 1 + if nm not in n_ents or o_raw[o_ents[nm][0]:o_ents[nm][1]] != n_raw[n_ents[nm][0]:n_ents[nm][1]]: + F(f'{nm}: must be byte-identical to stock (CURSOR_ROOT_KEEP) but differs') +print(f'check 12: {n_cur} CURSOR_ROOT_KEEP files compared byte-for-byte') + + +# 13. round-2 curated geometry (independent of build.py): EDGE_GROW, UNIFORM_GROW (+ Title wallpaper coverage), +# Fade_00 corner items, tip text font squash. Values are compared in root-local units (children mode normalised). +n13 = 0 +SKY = {'P_MainV_00', 'P_MainV_02', 'P_MainVE_00', 'P_MainVOE_00'} # must cover the whole 4:3 height +FORE = {'P_MainV_01', 'P_MainV_03', 'P_MainVE_01', 'P_MainVOE_01'} # foregrounds: bottom must reach the edge +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for n in sorted(o_ents): + if not n.endswith('.bflyt'): + continue + ln = n[5:-6] + want = (set(C.EDGE_GROW.get(ln, ())) | set(C.UNIFORM_GROW.get(ln, ())) | set(C.UNIFORM_TY_GROW.get(ln, ())) + | ({'T_DummyText_00'} if ln == 'Fade_00' else set())) + if not want and ln not in C.TXT_FONT_Y_LAYOUTS: + continue + lw, lh, ro = parse_flyt(o_raw, o_ents[n][0]); _, _, rn = parse_flyt(n_raw, n_ents[n][0]) + annotate(ro); annotate(rn) + _norm_tree(ln, rn, lw, lh) + po = {p.path(): p for p in ro.walk()} + pn = {p.path(): p for p in rn.walk()} + for path, a in po.items(): + b = pn[path] + if a.name in C.EDGE_GROW.get(ln, {}): + n13 += 1 + amt = C.EDGE_GROW[ln][a.name] + if abs(b.ah - (a.ah + amt)) > 0.6: + F(f'{ln}/{a.name}: edge-grow height {b.ah:.1f}, expected {a.ah + amt:.1f}') + if abs(b.ay - a.ay) > 1.0: + F(f'{ln}/{a.name}: edge-grow moved the centre {a.ay:.1f} -> {b.ay:.1f}') + top_o, bot_o = a.ay + a.ah / 2, a.ay - a.ah / 2 + top_n, bot_n = b.ay + b.ah / 2, b.ay - b.ah / 2 + if abs((top_n - top_o) - amt / 2) > 1.0 or abs((bot_o - bot_n) - amt / 2) > 1.0: + F(f'{ln}/{a.name}: edge distances changed by ({top_n - top_o:.1f}, {bot_o - bot_n:.1f}), expected {amt / 2:.0f} each') + if a.name in C.UNIFORM_GROW.get(ln, ()) or a.name in C.UNIFORM_TY_GROW.get(ln, ()): + n13 += 1 + if abs(b.ah - a.ah * K) > 0.6 or abs(b.aw - a.aw * K) > 0.6: + F(f'{ln}/{a.name}: uniform grow {b.aw:.0f}x{b.ah:.0f}, expected {a.aw * K:.0f}x{a.ah * K:.0f}') + want_ay = a.ay * K if a.name in C.LEAF_TY.get(ln, ()) else a.ay + if abs(b.ay - want_ay) > 1.0: + F(f'{ln}/{a.name}: uniform grow centre {b.ay:.1f}, expected {want_ay:.1f}') + if ln == 'Title_00': + top_n, bot_n = b.ay + b.ah / 2, b.ay - b.ah / 2 + if a.name in SKY and (top_n < HALF_VIS - 1 or bot_n > -HALF_VIS + 1): + F(f'{ln}/{a.name}: wallpaper sky covers y [{bot_n:.0f}, {top_n:.0f}], not the full +-{HALF_VIS:.0f}') + if a.name in FORE and bot_n > -HALF_VIS + 1: + F(f'{ln}/{a.name}: wallpaper foreground ends at y {bot_n:.0f}, above the bottom edge') + if ln == 'Fade_00' and a.name == 'T_DummyText_00': + n13 += 1 + if abs((b.ay - a.ay) - DELTA) > 1.0: + F(f'{ln}/{a.name}: top-left text moved {b.ay - a.ay:.1f}, expected +{DELTA:.0f}') + if ln in C.TXT_FONT_Y_LAYOUTS and a.kind == 'txt1' and a.name in C.CODE_SCALE_PANES and tl(a) and MODE == 'children': + n13 += 1 + fo = [struct.unpack_from(' 1e-4 or abs(fn[1] - fo[1] * ROOT_SY) > 1e-3 or abs(fn[2] - fo[2] * ROOT_SY) > 1e-3: + F(f'{ln}/{a.name}: tip text font (X, Y, lineSpace) {fn} vs stock {fo}: expected Y and lineSpace x{ROOT_SY}') +print(f'check 13: {n13} round-2 curated panes checked') + +# 14. parts whose edge panes were shifted for round 2 (PaFadeBar_00): shifted -DELTA / +DELTA in local units +for part in ('PaFadeBar_00',): + for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + nm = 'blyt/' + part + '.bflyt' + if nm not in o_ents: + continue + _, _, po = parse_flyt(o_raw, o_ents[nm][0]); _, _, pn = parse_flyt(n_raw, n_ents[nm][0]) + annotate(po); annotate(pn) + mo = {q.name: q for q in po.walk()}; mn = {q.name: q for q in pn.walk()} + for pname in C.PART_SHIFT[part]: + if pname not in mo: + F(f'{part}/{pname}: missing'); continue + d = mn[pname].ay - mo[pname].ay + if abs(abs(d) - DELTA) > 1.0 or (d > 0) != (mo[pname].ay > 0): + F(f'{part}/{pname}: moved {d:.1f}, expected {DELTA:.0f} towards its own edge') + +# 15. round 3: Title wallpaper (TransY keys x K, live/capture twins identical), glow source/uses, Sheikah map scissor. +n15 = 0 +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for ln in sorted(set(C.LEAF_TY) | set(C.CAPTURE_BG_FULLFRAME) | set(C.SIZEH_RETARGET)): + nm = 'blyt/' + ln + '.bflyt' + if nm not in o_ents: + continue + lw, lh, ro = parse_flyt(o_raw, o_ents[nm][0]); _, _, rn = parse_flyt(n_raw, n_ents[nm][0]) + po = {p.name: p for p in ro.walk()}; pn = {p.name: p for p in rn.walk()} + # TransY keys of leaf panes are exactly x K (static value too); TransX untouched + for an in layout_anims(n_ents, ln): + olds = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(o_raw, o_ents[an][0]) if not im_} + news = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(n_raw, n_ents[an][0]) if not im_} + for (pname, tgt), ko in olds.items(): + kn = news[(pname, tgt)] + if pname in C.LEAF_TY.get(ln, ()) and tgt in (0, 1): + n15 += 1 + want = K if tgt == 1 else 1.0 + for x, y in zip(ko, kn): + if abs(y.value - x.value * want) > 1e-3 * max(1, abs(x.value)) or ( + x.slope is not None and abs(y.slope - x.slope * want) > 1e-3 * max(1, abs(x.slope))): + F(f'{ln}/{pname}: {an} target {tgt} keys not x{want:.3f}') + break + if ln in C.SIZEH_RETARGET and pname in C.SIZEH_RETARGET[ln] and tgt == 9: + n15 += 1 + for i, (x, y) in enumerate(zip(ko, kn)): + want_v = C.SIZEH_RETARGET[ln][pname] if abs(x.value - H0) < 0.5 else x.value + if abs(y.value - want_v) > 0.01: + F(f'{ln}/{pname}: {an} SizeH key {i} {y.value:.1f}, expected {want_v:.1f}') + for pname in C.LEAF_TY.get(ln, ()): + a, b = po.get(pname), pn.get(pname) + if a is None or b is None: + F(f'{ln}/{pname}: leaf-ty pane missing'); continue + n15 += 1 + if abs(b.ty - a.ty * K) > 0.01: + F(f'{ln}/{pname}: static ty {b.ty:.2f}, expected {a.ty * K:.2f}') + if abs(b.tx - a.tx) > 0.01: + F(f'{ln}/{pname}: tx changed ({a.tx:.1f} -> {b.tx:.1f}); only ty may change') + if ln == 'Title_00' and MODE == 'children': + for x, y in C.TITLE_TWINS: + a, b = pn.get(x), pn.get(y) + n15 += 1 + if a is None or b is None or abs(a.h - b.h) > 0.01 or abs(a.w - b.w) > 0.01 or abs(a.ty - b.ty) > 0.01 or abs(a.tx - b.tx) > 0.01: + F(f'{ln}: live pane {x} and capture twin {y} differ in size/position') + src = pn.get('N_Capture_00'); so = po.get('N_Capture_00') + n15 += 1 + if src is None or abs(src.h - so.h) > 0.01 or abs(src.w - so.w) > 0.01: + F(f'{ln}/N_Capture_00: glow source must keep its stock local size {so.w:.0f}x{so.h:.0f}') + for p in src.children: + n15 += 1 + if abs(p.sy - 0.75) > 1e-4: + F(f'{ln}/N_Capture_00/{p.name}: glow child must carry the 0.75 pushdown, sy={p.sy}') + for name, q in pn.items(): + if name.startswith('P_Light_') or (name.startswith('P_Blur_') and name != 'P_Blur_08'): + n15 += 1 + if abs(q.h - 960.0) > 0.01: + F(f'{ln}/{name}: glow use local height {q.h:.0f}, expected 960 (projects 720 under the 0.75 chain)') + for pname, tgt in C.SIZEH_RETARGET.get(ln, {}).items(): + a, b = po.get(pname), pn.get(pname) + n15 += 1 + if a is None or b is None or abs(b.h - tgt) > 0.01: + F(f'{ln}/{pname}: static SizeH {None if b is None else b.h}, expected {tgt}') + if ln == 'AppMap_00': + # round 10: each map capture source has the same size as its use (static and every SizeH key), as in stock + for sname, uname in C.MAP_CAPTURE_PAIRS.items(): + s_, u_ = pn.get(sname), pn.get(uname) + n15 += 1 + if s_ is None or u_ is None or abs(s_.h - u_.h) > 0.01 or abs(s_.w - u_.w) > 0.01: + F(f'{ln}/{sname}: map capture source size differs from its use {uname}') + for an in layout_anims(n_ents, ln): + kk = {p_: ks for p_, im_, tm_, t_, ct_, ks in parse_flan(n_raw, n_ents[an][0]) if not im_ and t_ == 9} + for sname, uname in C.MAP_CAPTURE_PAIRS.items(): + if (sname in kk) != (uname in kk): + F(f'{ln}/{sname}: SizeH animated on only one of source/use {uname} in {an}') + elif sname in kk and [round(k.value, 3) for k in kk[sname]] != [round(k.value, 3) for k in kk[uname]]: + F(f'{ln}/{sname}: SizeH keys differ from its use {uname} in {an}') +print(f'check 15: {n15} round-3 curated items checked') + +# 16. CaptureApplyScale sources must give the same copy rect with the engine flag on AND off (see curated.CAPTURE_APPLY_INVARIANT), +# and plain host-following sources keep SizeH (static and keys) x ROOT_SY. +n16 = 0 +if MODE == 'children': + for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for n in sorted(o_ents): + if not n.endswith('.bflyt'): + continue + ln = n[5:-6] + lw, lh, ro = parse_flyt(o_raw, o_ents[n][0]) + if not top_eligible(ln, lw, lh) or ln in ALL_REFS: + continue + _, _, rn = parse_flyt(n_raw, n_ents[n][0]) + lo, lnw = list(ro.walk()), list(rn.walk()) + if len(lo) != len(lnw): + continue + for a, b in zip(lo, lnw): + if a.kind == 'pan1' and b'CaptureApplyScale' in a.usd: + n16 += 1 + chain = _proj_chain(b.parent) if b.parent is not None else 1.0 + rect_off = b.h + rect_on = b.h * chain * b.sy # the game code never rewrites these two panes' scale (MainShortCut setup 0x11910c0) + want = a.h * ROOT_SY + if abs(rect_off - want) > 0.5 or abs(rect_on - want) > 0.5: + F(f'{ln}/{a.name}: ApplyScale source copy rect {rect_off:.1f} (flag off) / {rect_on:.1f} (flag on), expected {want:.1f} for both') + if abs(b.w - a.w) > 0.01 or abs(b.tx - a.tx) > 0.01 or abs(b.ty - a.ty) > 0.01: + F(f'{ln}/{a.name}: ApplyScale source width/translation changed') + if a.name in C.SRC_H_SCALE.get(ln, ()): + n16 += 1 + if abs(b.h - a.h * ROOT_SY) > 0.01: + F(f'{ln}/{a.name}: SizeH {b.h:.2f}, expected {a.h * ROOT_SY:.2f}') + for ln, names in C.SRC_H_SCALE.items(): + nm = 'blyt/' + ln + '.bflyt' + if nm not in o_ents: + continue + for an in layout_anims(n_ents, ln): + olds = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(o_raw, o_ents[an][0]) if not im_} + news = {(p_, t_): ks for p_, im_, tm_, t_, ct_, ks in parse_flan(n_raw, n_ents[an][0]) if not im_} + for pname in names: + ko = olds.get((pname, 9)) + if ko is None: + continue + n16 += 1 + for x, y in zip(ko, news[(pname, 9)]): + if abs(y.value - x.value * ROOT_SY) > 1e-3 * max(1, abs(x.value)): + F(f'{ln}/{pname}: {an} SizeH key {y.value:.2f}, expected {x.value * ROOT_SY:.2f}') + break +print(f'check 16: {n16} ApplyScale / host-following capture sources checked') + +# 17. followers (e.g. the arc end caps of the system message pill) must have moved exactly like their anchor pane. +n17 = 0 +for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + for ln, (anchor, followers) in C.SHIFT_FOLLOW.items(): + nm = 'blyt/' + ln + '.bflyt' + if nm not in o_ents: + continue + _, _, ro = parse_flyt(o_raw, o_ents[nm][0]) + _, _, rn = parse_flyt(n_raw, n_ents[nm][0]) + annotate(ro) + annotate(rn) + if MODE == 'children': + norm_children(rn) + po = {p.name: p for p in ro.walk()} + pn = {p.name: p for p in rn.walk()} + d_anchor = pn[anchor].ay - po[anchor].ay + for f in followers: + n17 += 1 + d = pn[f].ay - po[f].ay + if abs(d - d_anchor) > 1.0: + F(f'{ln}/{f}: moved {d:.1f} but its anchor {anchor} moved {d_anchor:.1f}') +print(f'check 17: {n17} anchor/follower pairs checked') + +# 18. the Pause-menu page containers keep ScaleY 1 (the game's list code reads it; 0.75 here displaces Memories rows #6+). +n18 = 0 +if MODE == 'children': + for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + n_raw, n_ents = load_archive(n_path, inner) + for ln in ('PauseMenu_00', 'PauseMenuBG_00'): + nm = 'blyt/' + ln + '.bflyt' + if nm not in n_ents: + continue + _, _, rn = parse_flyt(n_raw, n_ents[nm][0]) + for c in rn.children: + if c.name in ('N_Slide_00', 'N_Slide_01', 'N_Slide_02'): + n18 += 1 + if abs(c.sy - 1.0) > 1e-4: + F(f'{ln}/{c.name}: ScaleY {c.sy:.4f}, must stay 1 (Memories list rows #6+ break otherwise)') +if MODE == 'children' and n18 != 6: + F(f'check 18: expected 6 Pause-menu page containers (3 in PauseMenu_00, 3 in PauseMenuBG_00), found {n18}') +print(f'check 18: {n18} Pause-menu page containers checked') + +# 19. PauseMenu_00/N_InOutQuest_02 (Adventure Log page, holds Pa_Quest_00) and its subtree stay at stock scale/translation/size +# (any 0.75 there makes Memories rows #6+ draw on top of #5, round 7). +n19 = 0 +if MODE == 'children': + for outrel, inner in JOBS: + n_path = os.path.join(OUT, outrel) + if not os.path.exists(n_path): + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(n_path, inner) + nm = 'blyt/PauseMenu_00.bflyt' + if nm not in n_ents: + continue + _, _, ro = parse_flyt(o_raw, o_ents[nm][0]) + _, _, rn = parse_flyt(n_raw, n_ents[nm][0]) + po = {q.name: q for q in ro.walk()} + pn = {q.name: q for q in rn.walk()} + for top in C.NO_SCALE_SUBTREES.get('PauseMenu_00', ()): + if top not in po or top not in pn: + F(f'check 19: PauseMenu_00/{top} not found') + continue + for qo in po[top].walk(): + qn = pn.get(qo.name) + n19 += 1 + if qn is None or any(abs(getattr(qn, f) - getattr(qo, f)) > 1e-4 for f in ('sx', 'sy', 'tx', 'ty', 'w', 'h')): + F(f'check 19: PauseMenu_00/{qo.name} differs from stock (must stay stock, Memories rows break otherwise)') +if MODE == 'children' and n19 == 0: + F('check 19: no N_InOutQuest_02 subtree panes found') +print(f'check 19: {n19} Adventure Log page panes checked against stock') +# 20. round-8 HUD enlargement (only when HUD_SCALE != 1): compared against the HUD_SCALE=1 build of the same sources +# (BOTW_HUD_BASE=): each HUD pane is scaled by HUD_SCALE about its anchor (static values and animation keys). +n20 = 0 +if MODE == 'children' and abs(C.HUD_SCALE - 1.0) > 1e-6: + base = os.environ.get('BOTW_HUD_BASE') + if not base: + F('check 20: set BOTW_HUD_BASE to the HUD_SCALE=1 build output dir') + else: + b_raw, b_ents = load_archive(os.path.join(base, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + n_raw, n_ents = load_archive(os.path.join(OUT, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + S = C.HUD_SCALE + for ln, spec in C.HUD_PANES.items(): + nm = 'blyt/' + ln + '.bflyt' + _, _, rb = parse_flyt(b_raw, b_ents[nm][0]); _, _, rn = parse_flyt(n_raw, n_ents[nm][0]) + pb = {q.name: q for q in rb.walk()}; pn = {q.name: q for q in rn.walk()} + for name, (ax, ay) in spec.items(): + if name not in pb: + F(f'check 20: {ln}/{name} not found'); continue + a, b = pb[name], pn[name] + n20 += 1 + want = {'sx': a.sx * S, 'sy': a.sy * S, 'tx': ax + S * (a.tx - ax), 'ty': ay + S * (a.ty - ay)} + for k, w in want.items(): + if abs(getattr(b, k) - w) > 1e-3: + F(f'check 20: {ln}/{name} {k} {getattr(b, k):.4f}, expected {w:.4f}') + ob = {} + for an in layout_anims(b_ents, ln): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(b_raw, b_ents[an][0]): + if not is_mat and pane in spec and target in (0, 1, 6, 7) and ctype == 2: + ob[(an, pane, target)] = ks + for an in layout_anims(n_ents, ln): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(n_raw, n_ents[an][0]): + if (an, pane, target) not in ob: + continue + ax, ay = spec[pane] + for ko, kn in zip(ob[(an, pane, target)], ks): + a0 = ax if target == 0 else ay + wv = a0 + S * (ko.value - a0) if target in (0, 1) else ko.value * S + n20 += 1 + if abs(kn.value - wv) > 1e-3 or abs(kn.slope - ko.slope * S) > 1e-3: + F(f'check 20: {ln}/{pane} key target {target} in {an}: {kn.value:.3f}/{kn.slope:.3f}, expected {wv:.3f}/{ko.slope * S:.3f}') +print(f'check 20: {n20} HUD panes/keys checked') +# 21. stamina wheel: the part panes in PART_SY carry ScaleY/TransY x ROOT_SY (the code-written host scale cannot), and the +# net Y squash of every wheel host chain is ROOT_SY (host ScaleY x parent chain x part pane / stock part pane). +n21 = 0 +if MODE == 'children' and C.PART_SY: + s_raw, s_ents = load_archive(os.path.join(SRC, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + o_raw, o_ents = load_archive(os.path.join(OUT, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + for part, names in C.PART_SY.items(): + a0, b0 = s_ents['blyt/' + part + '.bflyt'][0], o_ents['blyt/' + part + '.bflyt'][0] + sa = {p.name: p for p in parse_flyt(s_raw, a0)[2].walk()} + sb = {p.name: p for p in parse_flyt(o_raw, b0)[2].walk()} + for nm in names: + if abs(sb[nm].sy - sa[nm].sy * ROOT_SY) > 1e-6: F(f'check 21: {part}/{nm} ScaleY {sb[nm].sy}, expected {sa[nm].sy * ROOT_SY}') + if abs(sb[nm].ty - sa[nm].ty * ROOT_SY) > 1e-6: F(f'check 21: {part}/{nm} TransY {sb[nm].ty}') + n21 += 1 + for nm in sa: # nothing else in the part may change its scale + if nm not in names and sb[nm].sy != sa[nm].sy: F(f'check 21: {part}/{nm} ScaleY changed unexpectedly') + for ln, hosts in C.HOST_SY_FACTOR.items(): + sa = {p.name: p for p in parse_flyt(s_raw, s_ents['blyt/' + ln + '.bflyt'][0])[2].walk()} + sb = {p.name: p for p in parse_flyt(o_raw, o_ents['blyt/' + ln + '.bflyt'][0])[2].walk()} + for h in hosts: + chain_a = chain_b = 1.0 + q = sa[h] + while q: chain_a *= q.sy; q = q.parent + q = sb[h] + while q: chain_b *= q.sy; q = q.parent + if abs(chain_b - chain_a * ROOT_SY) > 1e-5 and abs(chain_b - chain_a * 1.0) > 1e-5: + F(f'check 21: {ln}/{h} host chain ScaleY {chain_b:.4f} vs stock {chain_a:.4f}') + n21 += 1 +print(f'check 21: {n21} stamina-wheel panes/chains checked') +# 22. round-9 Adventure Log squash (PART_SQUASH_Y): each listed pane is a direct RootPane child of its part +# with ScaleY and TransY exactly x0.75 of stock (animation keys too); every other pane of that part is stock; the part +# is used by exactly one layout (PaChallengeListBtn_00 fills the 5 row slots of PaPageChallenge5_00). +n22 = 0 +if C.PART_SQUASH_Y: + o_raw, o_ents = load_archive(os.path.join(SRC, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + n_raw, n_ents = load_archive(os.path.join(OUT, 'Pack/Bootup.pack'), 'Layout/Common.sblarc') + for part, names in C.PART_SQUASH_Y.items(): + nm = 'blyt/' + part + '.bflyt' + _, _, ro = parse_flyt(o_raw, o_ents[nm][0]); _, _, rn = parse_flyt(n_raw, n_ents[nm][0]) + po_, pn_ = list(ro.walk()), list(rn.walk()) + if [p.name for p in po_] != [p.name for p in pn_]: + F(f'check 22: {part} pane list changed'); continue + if names - {p.name for p in ro.children}: + F(f'check 22: {part}: {sorted(names - {p.name for p in ro.children})} are not direct RootPane children') + for a, b in zip(po_, pn_): + n22 += 1 + sq = a.parent is ro and a.name in names + want = {'sx': a.sx, 'sy': a.sy * (ROOT_SY if sq else 1), 'tx': a.tx, 'ty': a.ty * (ROOT_SY if sq else 1), + 'w': a.w, 'h': a.h} + for k, w in want.items(): + if abs(getattr(b, k) - w) > 1e-4: + F(f'check 22: {part}/{a.name} {k} {getattr(b, k):.4f}, expected {w:.4f}') + ok_ = {} + for an in layout_anims(o_ents, part): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(o_raw, o_ents[an][0]): + if not is_mat and target in (1, 7): + ok_[(an, pane, target)] = ks + for an in layout_anims(n_ents, part): + for pane, is_mat, tmag, target, ctype, ks in parse_flan(n_raw, n_ents[an][0]): + if (an, pane, target) not in ok_: + continue + f = ROOT_SY if pane in names else 1.0 + for ko, kn in zip(ok_[(an, pane, target)], ks): + n22 += 1 + if abs(kn.value - ko.value * f) > 1e-4: + F(f'check 22: {part}/{pane} key target {target} in {an}: {kn.value:.4f}, expected {ko.value * f:.4f}') + users = sorted(n[5:-6] for n in n_ents if n.endswith('.bflyt') + and any(prt1_name(n_raw, p) == part for mag, p, s in flyt_tags(n_raw, n_ents[n][0], {b'prt1'}))) + if len(users) != 1: + F(f'check 22: {part} is used by {users}, the squash assumes exactly one layout (the Adventure Log page chain)') +if MODE == 'children' and n22 == 0: + F('check 22: no PART_SQUASH_Y panes checked') +print(f'check 22: {n22} squashed-part panes/keys checked') +print('continuity pairs checked:', cont_stats) +print('mode:', MODE, dict(CSTAT)) +# 10. bnd1 / cursor-like panes must stay glued to their visual partners. +# For every bnd1 and every pane named *Cursor*/*Select*/*Focus*/*Hit*/*Sel* (all layouts, parts included): +# a) its own world centre moved exactly like its parent's (no private shift, no private growth), +# b) it moved like every visual sibling (pic1/wnd1/txt1/prt1) under the same parent, unless that sibling +# is a deliberately grown fill pane (then only the centre must match), +# c) its absolute Y scale changed by exactly the root factor of its layout (0.75, or 1.0 for +# ROOT_SKIP / CURSOR_ROOT_KEEP / parts), never anything else. +import re as _re +_PAT = _re.compile(r'cursor|select|focus|(^|_)hit(_|\d|$)|(^|_)sel(_|\d|$)', _re.I) +_n10 = 0 +for outrel, inner in JOBS: + if not rep[outrel]['writes']: + continue + o_raw, o_ents = load_archive(os.path.join(SRC, outrel), inner) + n_raw, n_ents = load_archive(os.path.join(OUT, outrel), inner) + for n in sorted(o_ents): + if not n.endswith('.bflyt'): + continue + ln = n[5:-6] + _, _, ro = parse_flyt(o_raw, o_ents[n][0]); _, _, rn = parse_flyt(n_raw, n_ents[n][0]) + annotate(ro); annotate(rn) + if MODE == 'children' and ln not in ALL_REFS and top_eligible(ln, ro.w, ro.h): + norm_children(rn) + po_, pn_ = list(ro.walk()), list(rn.walk()) + if len(po_) != len(pn_): + continue + is_part = ln in ALL_REFS + want_ratio = 1.0 if (is_part or ln in C.ROOT_SKIP or ln in C.CURSOR_ROOT_KEEP + or (ro.w, ro.h) != (1280.0, 720.0) or ln in ('Fade_00', 'Thanks_00')) else ROOT_SY + oi = {id(p): i for i, p in enumerate(po_)} + for a, b in zip(po_, pn_): + if a is ro or not (a.kind == 'bnd1' or _PAT.search(a.name)): + continue + _n10 += 1 + tag = f'{ln}/{a.path()}' + wa, wb = a.asy * ro.sy, b.asy * rn.sy # annotate() excludes the root's own scale + if MODE == 'root' and wa and abs(wb / wa - want_ratio) > 1e-4: + F(f'{tag}: abs Y scale ratio {wb / wa:.4f}, expected {want_ratio}') + if a.kind == 'bnd1' and (abs(b.h - a.h) > 1e-3 or abs(b.w - a.w) > 1e-3): + F(f'{tag}: bnd1 resized ({a.w}x{a.h} -> {b.w}x{b.h})') + par_a, par_b = a.parent, b.parent + if par_a is None: + continue + da = b.ay - a.ay + if par_a is not ro and abs(da - (par_b.ay - par_a.ay)) > 1.0 and abs(par_b.h - par_a.h) < 1e-3: + F(f'{tag}: moved {da:.1f} but parent {par_a.name} moved {par_b.ay - par_a.ay:.1f}') + for sa, sb in zip(par_a.children, par_b.children): + if sa is a or sa.kind not in ('pic1', 'wnd1', 'txt1', 'prt1'): + continue + ds = sb.ay - sa.ay + grown = abs(sb.h - sa.h) > 0.5 + if abs(ds - da) > 1.0 and not grown: + F(f'{tag}: separated from sibling {sa.name} (hit/cursor {da:.1f}, sibling {ds:.1f})') + elif abs(ds - da) > 1.0 and grown and abs(sb.ay - sa.ay) > 1.0: + F(f'{tag}: grown sibling {sa.name} also moved its centre ({ds:.1f}) while hit/cursor moved {da:.1f}') +print(f'check 10: {_n10} bnd1/cursor-like panes compared against partners') + +print(f'FAILS: {len(fails)}') +for m in fails[:80]: print(' FAIL', m) +print(f'WARNINGS: {len(warns)}') +for m in warns[:80]: print(' warn', m) +sys.exit(1 if fails else 0) + +