diff --git a/.github/release-games.json b/.github/release-games.json index 868fea1..ee94682 100644 --- a/.github/release-games.json +++ b/.github/release-games.json @@ -9,7 +9,7 @@ "title_id": "010015100B514000", "game_version": "1.2.1", "build_id": "FF773E90972D544EB79406EAA65396D53C43EFB9", - "layout_count": 127 + "layout_count": 129 } } } diff --git a/super-mario-bros-wonder/AGENTS.md b/super-mario-bros-wonder/AGENTS.md index 3f038df..c056b85 100644 --- a/super-mario-bros-wonder/AGENTS.md +++ b/super-mario-bros-wonder/AGENTS.md @@ -6,9 +6,9 @@ Read the root [`../AGENTS.md`](../AGENTS.md) first. This file is the **source of - Title ID `010015100B514000`, **version 1.2.1 only**, build ID `FF773E90972D544EB79406EAA65396D53C43EFB9`. - Tested on Eden (yuzu family) with Graphics > Aspect Ratio > **Force 4:3**, on Windows (where agents can probe memory and take screenshots) and on the tester's Retroid Pocket Nova (Android). Other emulators and console are untested. -- Mod folder: `mod/Native 4x3 Aspect Ratio/` = `exefs/1.2.1.pchtxt` + `romfs/Layout/*.Nin_NX_NVN.blarc.zs` (115 changed archives) + `romfs/BancMapUnit/*.bcett.byml.zs` (12 stage edits: Course152_Sub4, Course411_Course, Course415_Course, Course417_Course, Course403_Course, Course400_Course, Course401_Course, Course408_Course, Course407_Course, World001, Course022_Main, Course853_Main) + `README.txt` (ships with the mod; holds no install steps, only the link to `README.md#install`, the one install guide). Named "Nova Aspect Ratio 4x3 Native" before v1.0.0; don't rename it again. +- Mod folder: `mod/Native 4x3 Aspect Ratio/` = `exefs/1.2.1.pchtxt` + `romfs/Layout/*.Nin_NX_NVN.blarc.zs` (115 changed archives) + `romfs/BancMapUnit/*.bcett.byml.zs` (13 stage edits: Course152_Sub4, Course411_Course, Course415_Course, Course417_Course, Course403_Course, Course400_Course, Course401_Course, Course408_Course, Course407_Course, World001, Course022_Main, Course853_Main, Course290_Main) + `romfs/Event/EventFlow/CourseDemo_PreFinalBattle.bfevfl.zs` (Course290 intro cutscene camera) + `README.txt` (ships with the mod; holds no install steps, only the link to `README.md#install`, the one install guide). Named "Nova Aspect Ratio 4x3 Native" before v1.0.0; don't rename it again. - Installed for testing at `%APPDATA%\eden\load\010015100B514000\Native 4x3 Aspect Ratio`. Sync with the game closed: `robocopy "mod\Native 4x3 Aspect Ratio" "%APPDATA%\eden\load\010015100B514000\Native 4x3 Aspect Ratio" /MIR` (mirror: deletes archives the build no longer ships). -- Releases: tag prefix `smbw` (`.github/release-games.json`); procedure in the root AGENTS.md "Releasing". `layout_count` there counts every file under `romfs/` (115 layouts + 12 stage files = 127); bump it when that number changes. +- Releases: tag prefix `smbw` (`.github/release-games.json`); procedure in the root AGENTS.md "Releasing". `layout_count` there counts every file under `romfs/` (115 layouts + 13 stage files + 1 event file = 129); bump it when that number changes. ## Local inputs (outside the repo) @@ -30,11 +30,11 @@ python tools/verify.py tools /romfs/Layout # must r # then replace mod/Native 4x3 Aspect Ratio/romfs/Layout/ with /romfs/Layout/* (delete first: the build # leaves unchanged archives out, so a stale file would otherwise stay); update layout_count in release-games.json -# Stage edits (BancMapUnit): rebuild from the originals, then check the shipped files -python tools/build_stage.py # writes /romfs/BancMapUnit/*.bcett.byml.zs +# Stage and event edits (BancMapUnit, EventFlow): rebuild from the originals, then check the shipped files +python tools/build_stage.py # writes BancMapUnit/ and Event/EventFlow/ python tools/build_stage.py --verify "mod/Native 4x3 Aspect Ratio/romfs" # must report 0 problem(s) python -B -m unittest discover -s tools -p test_build_stage.py -v # synthetic float/string-edit safety tests; no originals needed -# then replace mod/Native 4x3 Aspect Ratio/romfs/BancMapUnit/ with /romfs/BancMapUnit/* +# then copy /romfs/ into mod/Native 4x3 Aspect Ratio/romfs/ # Code patch: regenerate patch lines, then disassemble the shipped file $env:SMBW_MAIN_BIN = '\main-1.2.1.bin' # PowerShell (bash: export SMBW_MAIN_BIN=...) @@ -53,18 +53,19 @@ A rebuild from the 1.2.1 originals reproduces the committed `romfs/Layout` byte | `ghidra/DecompileAt.java` | Headless decompile of the functions containing given addresses (import the flat image as raw AArch64 at base 0) | | `byml.py [--grep text]` | Dump BYML/BGYML (and `.zs`) level/stage/event data | | `bymlpatch.py` | Same-size in-place edit of one BYML value (or an actor's `--translate` / `--scale`), recompressed | -| `build_stage.py` | Stage edit tables (`EDITS`, `GYAML_EDITS`): builds the shipped `BancMapUnit` files from the originals; `--verify` exits 1 unless each differs only in declared float/string edits; Gyaml edits also require exact parsed-tree scope | +| `build_stage.py` | Stage edit tables (`EDITS`, `BG_EDITS`, `BELT_EDITS`, `GYAML_EDITS`, `RAIL_EDITS`): builds the shipped `BancMapUnit` files from the originals; `--verify` exits 1 unless each differs only in declared float/string edits; Gyaml edits also require exact parsed-tree scope | | `scan_autoscroll_ends.py ` | Surveys RomFS course rails and autoscroll actors for intermediate pauses (>= 120 frames) and prints AUTOSCROLL_ENDS table for gen_zoom_v2.py | +| `audit_autoscroll_relays.py [mod_target]` | Simulates autoscroll rail movement, computes switch activation frames, traces signal relays, and verifies timing synchronization between stock 16:9 and 4:3 | | `gen_zoom_v2.py` | Camera patch generator (caves A-H, Y, K, per-area base and delta, boss table, autoscroll ends table); asserts delta <= max(0, (27.5556 - G*4/3)/2) | | `verify_pchtxt.py [file]` | Disassembles every enabled line of a patch file | Ghidra headless (Java 21): `analyzeHeadless -process main-1.2.1.bin -noanalysis -scriptPath tools/ghidra -postScript DecompileAt.java "6c66b8,2e2b30"`. -Flat image layout (1.2.1): `.text` 0x0-0x2138650, `.ro` 0x2139000-0x338BC78, `.data` 0x338C000-0x3728DF8. Code cave: zero bytes 0x2138650-0x2139000 (executable, patchable), used 0x2138780-0x2138F23 (caves A, B, G helper, G, D, E, F1, F2, Y, K, boss table, autoscroll ends table, H; 0x2138988-0x21389FF, 0x2138DC0-0x2138DFF free). Spare .bss words used as mailboxes: 0x037D1F00-0x037D1F3B (0x037D1F04 = current area RootAreaHash). +Flat image layout (1.2.1): `.text` 0x0-0x2138650, `.ro` 0x2139000-0x338BC78, `.data` 0x338C000-0x3728DF8. Code cave: zero bytes 0x2138650-0x2139000 (executable, patchable), used 0x2138780-0x2138F23 (caves A, A helper 02138988, B, G helper, G, D, E, F1, F2, Y, K, boss table, autoscroll ends table, H; 0x2138DC0-0x2138DFF free). Spare .bss words used as mailboxes: 0x037D1F00-0x037D1F3B (0x037D1F04 = current area RootAreaHash). ## Current state (2026-11-07) -Shipped patch `exefs/1.2.1.pchtxt`: 11 hooks (`verify_pchtxt.py`). Includes area-hash mailbox (`0x037D1F04`), cave Y (fight camera pin at y 3.25 in Course152_Sub4, hook `0x006C66E8`), cave K (`GetCameraBoundBox2f` Y bounds at `0x01781B70` for Bowser Jr. swim AI navigation), `BOSS` table entries for full-arena zooms (Course150, Course152, Course411 Break Time! Wonder Token Tunes, Course415 Break Time! Bouncy Tunes, Course417 Break Time! Trottin' Piranha Plants, Course403 Break Time! Zip-Go-Round, Course008_Sub2 Angry Spikes Sinkin' Pipes Wonder area, Course400_Course Break Time! Pop Up, Hoppo!, Course401, Course404_Main, and Course407 at G = 20.6667, delta = 0.0; Course408 uses G = 18.5, delta = 0.0), and autoscroll end-stop table (`TABLE_ENDS`) with Cave G helper (`0x02138914`) to keep autoscroll cameras locked during mid-scroll pauses. Course409 is reverted to stock and remains on the TODO list. +Shipped patch `exefs/1.2.1.pchtxt`: 11 hooks (`verify_pchtxt.py`, 363 patch lines, SHA-256 `9d470505ebce2a9c435cfb2cd742f579d9363c53df614b0d2eafcb07f3cfa59a`). Includes area-hash mailbox (`0x037D1F04`), cave A opening fists zoom-out helper `A_HELPER` (`0x02138988`), cave Y (fight camera pin at y 3.25 in Course152_Sub4, hook `0x006C66E8`), cave K (`GetCameraBoundBox2f` Y bounds at `0x01781B70` for Bowser Jr. swim AI navigation), `BOSS` table entries for full-arena zooms (Course150, Course152, Course411 Break Time! Wonder Token Tunes, Course415 Break Time! Bouncy Tunes, Course417 Break Time! Trottin' Piranha Plants, Course403 Break Time! Zip-Go-Round, Course008_Sub2 Angry Spikes Sinkin' Pipes Wonder area, Course400_Course Break Time! Pop Up, Hoppo!, Course401, Course404_Main, and Course407 at G = 20.6667, delta = 0.0; Course408 uses G = 18.5, delta = 0.0), and autoscroll end-stop table (`TABLE_ENDS`) with Cave G helper (`0x02138914`) to keep autoscroll cameras locked during mid-scroll pauses. Course409 is reverted to stock and remains on the TODO list. **Course400 framing approved and Hoppo spawn fix applied (2026-11-06):** the maintainer confirmed the full-room framing and camera lock look good in Windows/Eden. To eliminate the visible mid-air spawn pop-in caused by the expanded 4:3 view height ($G = 20.6667$), `EnemyKoropon` and `PopUpTag` were raised by $+5.0$ in Y ($12.0 \to 17.0$ and $16.5 \to 21.5$) via `build_stage.py`. The Hoppo now spawns off-screen above the 4:3 screen edge and drops into view as intended, with identical horizontal trajectory ($X = 3.0$). Retry and completion checks remain open. @@ -91,13 +92,14 @@ Shipped patch `exefs/1.2.1.pchtxt`: 11 hooks (`verify_pchtxt.py`). Includes area 4. `Course417_Course` (Break Time! Trottin' Piranha Plants), **visual framing user-approved in Windows/Eden; gameplay checks pending**: arch y 17.25 -> 18.545; original A01 pillars are replaced with A00 at y = 14.45 (left retains its tiny authored X/Y offsets), matching Course411/415's approved A00 alignment. Upper wall y 14 -> 14.05; lower wall y 6 -> 6.05. No scales, X/Z, note blocks, enemies or rails changed. Five float edits plus one guarded pooled-string byte change affecting only the two pillar Gyaml fields: 15 changed bytes, 6 declared edits. The A00 actor pack is supplied by the game, not shipped by the mod. All earlier stage archives remain byte-identical. 5. `Course403_Course` (Break Time! Zip-Go-Round), **visual framing user-approved in Windows/Eden; gameplay checks pending**: floor cloud (`ObjectCloudArea` Hash 3184768010431751081) Translate Y 0.0 -> -0.4, Scale X 6.0 -> 28.0. Spans X [0.0, 28.0] and drops bottom puff lobes to Y = -2.40, completely covering the unrendered sky void below the red dash floor and sealing scalloped edge gaps off-screen, while keeping the top at Y = 1.6 flush against the red dash floor. 2 float edits (7 bytes). All other 9 clouds remain stock. `build_stage.py --verify` reports 0 problems across all nine courses. 6. `Course400_Course` (Break Time! Pop Up, Hoppo!), **visual framing user-approved in Windows/Eden; Hoppo spawn fix awaiting retry**: `EnemyKoropon` (Hash 17703685394400552912) Translate Y 12.0 -> 17.0 and `PopUpTag` (Hash 3402723882765168318) Translate Y 16.5 -> 21.5 (+5.0 in Y), moving the spawn off-screen above the 4:3 view so the Hoppo drops into view as intended, while preserving horizontal placement (X = 3.0) and relative 4.5-block tag spacing. 2 float edits (8 bytes). `build_stage.py --verify` reports 0 problems across all nine courses. -7. `Course401_Course` (Break Time! Kick It, Outmaway!), **approved in Eden on 2026-11-07**: eight `ObjectBlockPushIce` actors move Y 18.0 -> 27.0 and six `ObjectBlockPushIce4x4` actors move Y 19.0 -> 28.0 (+9.0 in Y); X/Z and relative spacing are unchanged. 14 float edits; `build_stage.py --verify` covers all nine stage files. +7. `Course401_Course` (Break Time! Kick It, Outmaway!), **approved in Eden on 2026-11-07**: eight `ObjectBlockPushIce` actors move Y 18.0 -> 27.0 and six `ObjectBlockPushIce4x4` actors move Y 19.0 -> 28.0 (+9.0 in Y); X/Z and relative spacing are unchanged. 14 float edits; `build_stage.py --verify` covers all ten stage files. 8. `Course409_Main` (Break Time! Raise the Stage) is **stock and remains on the TODO list**; investigate the background/platform framing during a later play-test. 9. `Course401`, `Course404_Main`, and `Course407` have BOSS table entries at G = 20.6667, delta = 0.0. Course408 uses its stock-height CameraArea with X locked at 64.0 and Y-only `CreateTag` moves. The patch and verifier pass; all four are approved in Eden on 2026-11-07. 10. `Course407_Course` (Break Time! Watery Wonder Tokens), **approved in Eden on 2026-11-07**: revert `DVWaKaiganFarIwaA02`; adjust `DVWaKaiganFarIwaA01` (Hash `3373664933504165692`) from Translate $(23.5, 48.0, -167.5)$ / Scale $(0.7, 0.7, 0.7)$ to Translate $(23.5, 49.5, -167.5)$ / Scale $(0.82, 0.82, 0.82)$. 11. `World001` (Pipe-Rock Plateau world map), **confirmed in Eden (2026-11-09: the tester reached the lost Toad)**: subregion 22 (underground area: sign, ? block, courses 9/10, KO arena) has a fixed camera on `WorldMapCameraLookAtTag` obj479 (Hash 2929358336); its X moves 87.25 -> 91.25 so the hidden warp pipe obj513 (x 103, to the lost-Toad room) and Mario beside it are on screen (4:3 view about x 76.5-106.0; entry pipe obj29 kept). An earlier subregion 17 limit-area edit targeted the wrong area and was reverted. All nine world maps surveyed for fixed or boxed cameras cropping objects 16:9 showed (2026-11-09); only the World006 (Fungi Mines) pipe from Sunbaked Desert beside Captain Toad was a real candidate, and the tester checked it fine in game. Details: DEVELOPMENT.md section 46. 12. `Course022_Main` (W2 Outmaway Valley, Wonder autoscroll), **seed fix confirmed in Eden (2026-11-09)**: the finish Wonder Seed (obj8927, GravityOn at x 693.5) is created by `CourseDisplayBoxSwitch` obj8878 when it enters the view, timed to drop onto the tip of the goal pole carried round by the rolling snow hill. The left-aligned 4:3 scroll view (21.0 wide at G 15.75) reached the box 6.5556 blocks of scroll late, so the seed missed the pole and fell out of the course (reported 2026-11-09). All three display-box switches of the section move X -6.5556 (obj8878 715.5 -> 708.9444; the Mini Lucky Coin switches obj8931 574.5 -> 567.9444, obj8932 596.5 -> 589.9444) so they fire at the stock scroll position. The tester confirmed the seed lands on the pole; the coin switches were not separately reported. Details: DEVELOPMENT.md section 47. 13. `Course853_Main` (Sunbaked Desert Special: Pole Block Allure, autoscroll), **confirmed in Eden (2026-11-09)**: `RAIL_EDITS` on autoscroll rail `1776580222928036096`. Points 0-3 lowered in Y (17.0/17.0/25.5/41.0 -> 14.5/14.5/22.75/36.0) so the camera stays near the poles and the Wonder Flower is on screen. Final point 12 X 226.75 -> 231.335 (rail X is the view's left edge, rail Y its top) so the finale cannon `ObjectBalloonKillerHodaiLeft` (stock position 251.5, `IsFirstInCamera`) enters the 4:3 view and fires; the pole's first 0.8 blocks fall off the left edge as a trade-off. No actor edits. The tester confirmed the cannon fires and the Wonder Seed is reachable. Details: DEVELOPMENT.md sections 44-45 (section 45 corrects section 44's camera model). +14. `Course290_Main` (Bowser's Rage Stage), **confirmed in Eden (2026-11-09; the maintainer played the level and intro cutscene)**: autoscroll camera rail left-aligns the 21.0-wide 4:3 view to rail X, cutting 6.56 blocks off the right edge (or 2.89 blocks under G = 18.5). 19 `CourseDisplayBoxSwitch` triggers shifted in X (Kuribo switches `1536962149` & `14869113733391977869` to 43.77 and `578319643` to 36.48 for on-screen visibility, frame 1040 strike timing, and exact 383f relay interval; fossil switches in G = 18.5 hold shifted -2.89, return lerp switches shifted -3.57 and -4.29; vertical shaft and Bowser statue shifted -6.56; switch 4029477259 kept stock to fire post-pause); strike `PositionTag`s (`4814110068085501760` to 38.28125, `12276017923517845206` to 42.28125) and `LastBossWonderBadSmokeTag`s (`2306045187355644410` to 38.03125, `5602005781468990395` to 41.53125) calibrated against live Eden positions at strike frame 1040; Kuribo spawns (`2542738868` to 42.5, `1405933960` to 46.5) shifted left -3.5 in X to align walking Goombas to the bolt tags; 7 smoke plane actors (`DVCommonTorideKemuriB`/`A`) shifted ±1.5 in Y across opening fists and fossil sections to cover G = 18.5 zoom-out; 3 left rhythm pipes (`SoundRhythmObjectUpDownDokan`) and 3 singing Piranha Plants (`EnemySoundRunRunPackun`) shifted right by +2.0 blocks in X to compress the rhythm section away from the left edge (total 38 actor edits). Wall 2 right edge (pts 2-3) and Wall 5 left edge (pts 0-1) in `BgUnits[0]` shifted +2.0 in X across both `Walls` (4 bg edits) and `BeltRails` (4 belt edits) to move the pipe floor gap from [177, 183] to [179, 185] with aligned visuals and collision. On `Rail 185828596`: pt 8 shifted to 102.0, pts 9-11 shifted +3.28 in X (115.28, 128.28, 128.28) centering the vertical shaft climb, and post-statue rhythm pause plateau pts 16-17 shifted 174.0 -> 179.0 in X to frame the singing plants and right Spike thrower simultaneously (6 rail edits). Total 52 edits; verified with `audit_autoscroll_relays.py` (0 drift, all visual targets on-screen). **Layouts (`build.py`, built from the 1.2.1 originals since 2026-10-30):** 115 of the game's 235 archives ship (114 changed top-level layouts incl. the 1.2.1-only `AmiiboReadWindow`, plus `LCursor`); the other 120 are unchanged and fall back to the game's copies. top-level RootPane scale y 0.75 (`ROOT_SY`); HUD/header/footer edge-anchored (+/-180 root-local units, TransY keys shifted too); full-screen layers grown x4/3 (captures and fades height only, artwork uniform); parts layouts untouched; curated per-screen tables `FORCE_SHIFT`, `NO_SHIFT_SUBTREE`, `NO_SHIFT_LAYOUT`, `NO_FILL`. 638 float writes, 46 fill panes, `verify.py` clean. Until 2026-10-30 the mod was built from won-aar's older cache and shipped all 234 archives, so 30 screens (incl. Pause, MainMenu, Title, CourseList, talk windows, button icons) carried pre-1.2.1 layouts; the 1.2.1 rebuild applies identical edits. **Play-tested after the 1.2.1 rebuild (2026-10-31): menus, HUD, pause, maps, transitions, course clear, cursor and amiibo look good.** @@ -117,7 +119,7 @@ Shipped patch `exefs/1.2.1.pchtxt`: 11 hooks (`verify_pchtxt.py`). Includes area | `02AEEDB4 ABAAAA3F` | Aspect constant 1.7778 to 1.3333 | | `02AEE9E8`, `02AEE968`, `02AEE834`, `02AEEBD8` | Hard-coded view widths 27.5556 / 13.7778 and negatives set to 20.6667 / 10.3333 | | hook `00136A80` -> cave `02138780` | Level loader keeps 27.5556 for CameraAreas authored one screen wide (otherwise ~241 one-screen rooms shrink and box the player in) | -| hook `006C66DC` -> cave A `02138800` | Per-area base G and reach delta: boss table at `02138E00` first, else area width < 60 -> G 15.5 / delta 3.4444, else G 15.75 / delta 3.2778. Writes G `037D1F00`, current area hash `037D1F04`, delta `037D1F18`, width `037D1F1C`, controller/subject `037D1F20`/`28`; then the 16:9 reach rule | +| hook `006C66DC` -> cave A `02138800`, helper `02138988` | Per-area base G and reach delta: boss table at `02138E00` first, else area width < 60 -> G 15.5 / delta 3.4444, else large area (G 15.75 / delta 3.2778); Course290_Main opening fists/fossil holds G 18.5 until fixed X 100, lerping to 15.75 over fixed X 100..112 in A helper (`02138988`). Writes G `037D1F00`, current area hash `037D1F04`, delta `037D1F18`, width `037D1F1C`, controller/subject `037D1F20`/`28`; then the 16:9 reach rule | | hook `002E2B30` -> cave B `02138900` | View height: stock `fmov s1,#15.5`, then `fmax` with G | | `006C6358`, `006C6364` -> caves F1/F2 `02138D00`/`02138D20` | Camera-controller half-extents use G; width scaled by G/15.5 | | hooks `00833B00`, `005E428C` -> caves D `02138B00`, E `02138C00` | Bowser Jr. pipe display box kept at authored size when G > 15.5 | diff --git a/super-mario-bros-wonder/docs/DEVELOPMENT.md b/super-mario-bros-wonder/docs/DEVELOPMENT.md index 218e2c5..d8f229f 100644 --- a/super-mario-bros-wonder/docs/DEVELOPMENT.md +++ b/super-mario-bros-wonder/docs/DEVELOPMENT.md @@ -209,7 +209,7 @@ Cave W (hook `0x01C5B694` in `FluidTagInfo::method4` `0x01C5B658`, which returns **Status:** built and verified (`verify_pchtxt.py`, words diffed against the generator, cave G disassembled). User-confirmed 2026-11-03 in Eden: the Course002 seed is reachable and the Course101 airship autoscroll + Wonder Flower still work. -**Scan of the bug class (read-only review, QA-checked against the stage data):** only `AutoScrollControlSignalFrame` and `SoundRhythmAutoScrollControlSignalFrame` call `SetAutoScrollPos`, so the fix covers every stopped autoscroll. `Course061_Sub2` (seed x 595.0, rail end 570.75) was 0.03 blocks inside the old reach and now has 3.3; coins and display-box triggers at stops in Course002 (mid-rail pause at x 166), Course010, Course064_Sub1, Course290 and Course858 also come into view. Not covered: while a scroll moves the view stays left-aligned (the rightmost 6.56 blocks appear only after 2 s still; centring would make the left push edge 3.3 blocks earlier than stock), and Course857_Main's stops last 104 and 100 frames, under the 120-frame hold, so its `CourseDisplayBoxSwitch` triggers (a `DisplayAreaSwitch` node, not a player switch) fire later than stock instead of during the pause. Vertical autoscrolls keep the stock top edge (fixed Y = rail Y - half-height). `StopScroll` side locks are authored at the 16:9 centre, so cave H's lock X +/- delta covers their frames. POW blocks hit the visible 4:3 screen. +**Scan of the bug class (read-only review, QA-checked against the stage data):** only `AutoScrollControlSignalFrame` and `SoundRhythmAutoScrollControlSignalFrame` call `SetAutoScrollPos`, so the fix covers every stopped autoscroll. `Course061_Sub2` (seed x 595.0, rail end 570.75) was 0.03 blocks inside the old reach and now has 3.3; coins and display-box triggers at stops in Course002 (mid-rail pause at x 166), Course010, Course064_Sub1, Course290 and Course858 also come into view (note: §23 superseded this for the six `AUTOSCROLL_ENDS` stages—including `Course002_Main` and `Course290_Main`—where Cave G locks horizontal camera offset to 0.0 at intermediate pauses and vertical climbs, so `CourseDisplayBoxSwitch` triggers and actors in `[rail_X + 21.0, rail_X + 27.56]` require stage edits; see lesson learned in §44 on auditing and shifting entire relay chains via `tools/audit_autoscroll_relays.py`). Not covered: while a scroll moves the view stays left-aligned (the rightmost 6.56 blocks appear only after 2 s still; centring would make the left push edge 3.3 blocks earlier than stock), and Course857_Main's stops last 104 and 100 frames, under the 120-frame hold, so its `CourseDisplayBoxSwitch` triggers (a `DisplayAreaSwitch` node, not a player switch) fire later than stock instead of during the pause. Vertical autoscrolls keep the stock top edge (fixed Y = rail Y - half-height). `StopScroll` side locks are authored at the 16:9 centre, so cave H's lock X +/- delta covers their frames. POW blocks hit the visible 4:3 screen. ## 23. 2026-11-03: autoscroll camera locking during mid-scroll pauses (Cave G end-stop table) @@ -235,7 +235,7 @@ Every listed pause has a margin $> 0.05$ blocks from the rail's final point, pre 1. Added `AUTOSCROLL_ENDS` table in `gen_zoom_v2.py`, emitted as `TABLE_ENDS` at `0x02138E3C` (after the boss table). Each entry stores `(RootAreaHash, rail_end_X + 13.7778)` pairs terminated by `(0, 0)`. 2. Added helper in Cave G at `0x02138914`: when the 120-frame stillness counter reaches 0, Cave G jumps to helper `0x02138914`. It compares current `fixed X + delta` against the table key. - If the area is listed in the table and $|(\text{fixed X} + \Delta) - \text{key}| \le 0.05$, the camera unlocks to follow the player within $[0, 2\Delta]$. - - If the area is listed in the table but not at the end stop, desired offset remains 0.0, keeping the camera locked to scroll coordinates. + - If the area is listed in the table but not at the end stop, desired offset remains 0.0, keeping the camera locked to scroll coordinates. Because Cave G locks desired offset to 0.0 whenever $|(\text{fixed X} + \Delta) - \text{key}| > 0.05$ (both at mid-scroll horizontal plateaus and during vertical climbs where fixed X is stationary below rail_end_X), right-edge `CourseDisplayBoxSwitch` triggers and actors in `AUTOSCROLL_ENDS` courses stay cropped by 6.56 blocks until the final stop. - If the area is not listed in `TABLE_ENDS` (standard locked rooms or autoscrolls with no mid-scroll pauses), it falls through to unlocked camera follow. **Status:** Built and verified with `verify_pchtxt.py` (304 patch lines, 11 hooks). Confirmed in game on Course002 in Eden: camera remains locked during the mid-scroll singing pause, and unlocks at the final stop to reach the Wonder Seed. @@ -590,3 +590,55 @@ Stage verification passes with 0 problems (5 bytes modified, passes all BYML inv **Assumptions:** G is 15.75 here (the area is wider than 60; with 15.5 the shift would be 6.89, 0.33 blocks more), and the switch tests the current view box (as noted for Course857 in section 22). **Status:** built; `build_stage.py --verify` 0 problems (Course022_Main: 9 bytes inside 3 edits; the other stage files are byte-identical to the shipped ones), 16 stage tests pass, `check_repo.py` OK. **Confirmed in Eden on 2026-11-09:** the tester reported the seed now lands on the pole ("That fix worked"). The Mini Lucky Coin switches were not separately reported. + +## 48. 2026-11-07: Course290_Main (Bowser's Rage Stage) autoscroll triggers and rail framing + +**Context & Findings:** +In `Course290_Main` (Bowser's Rage Stage, RootAreaHash `2931365200`), autoscroll signals pass `rail_X + current_half_width` to `SetAutoScrollPos`, left-aligning the 21.0-wide 4:3 view to `rail_X` (cropping 6.56 blocks off the right edge compared to stock 16:9 width 27.56). Because `Course290_Main` is listed in `AUTOSCROLL_ENDS`, Cave G locks camera offset to 0.0 at intermediate pauses and during vertical climbs, leaving right-edge `CourseDisplayBoxSwitch` triggers unactivated and actors cropped: +1. **Bowser statue Wonder Bulls spawn (commit `20f19cb`, confirmed in Eden):** Four statue-section `CourseDisplayBoxSwitch` triggers (`777445035`, `212790001`, `12855344573256944945`, `4029477259`) shifted left by 6.56 blocks in X, ensuring `EnemyTossinGroup` spawns during the approach and the post-statue rhythm pause activates correctly. +2. **Dragon section & vertical shaft ground/bars:** Seven `CourseDisplayBoxSwitch` triggers (`999420502`, `1755951341`, `1787195044`, `1117151842`, `4273434636`, `3717095890`, `1344248650`) shifted left by 6.56 blocks in X. Shifting `999420502` (Ring 1 spawn) alongside `1755951341` (Ring 1 delete / Ring 2 spawn) and `1787195044` (dragon transform) while keeping rail `pt 6` at stock 92.0 preserves the exact stock 16:9 timing intervals (403f and 488.9f), allowing Ring 1's 300-frame roll to complete. Switch `4273434636` activates to spawn bottom snake-block ground (`ObjectBlockSnakePole 34729090`) and guide coins. On `Rail 185828596`, `pt 8` shifted right to 102.0 (framing Wall 1 without pushing the player off Wall 0) and `pts 9-11` shifted right by +3.28 (115.28, 128.28, 128.28) so the 840-frame vertical shaft climb (`CameraArea 3010860670`, X = [124.75, 152.25]) is centered at X = 138.78, framing all four vertical snake poles. +3. **Post-statue Spike thrower pause framing & rhythm pipe compression:** On `Rail 185828596`, rhythm pause plateau `pts 16-17` shifted from 174.0 to 179.0 to frame X = [179.0, 200.0] in 4:3. To prevent the left group of 3 rising rhythm pipes (`SoundRhythmObjectUpDownDokan`) and 3 singing Piranha Plants (`EnemySoundRunRunPackun`) from being clipped by the left screen edge (authored at X = 178, 180, 182), they were compressed +2.0 blocks right to X = 180, 182, 184 (6 actor edits). In `BgUnits[0]`, Wall 2 right edge (pts 2-3) and Wall 5 left edge (pts 0-1) were shifted +2.0 in X across both `Walls` (4 bg edits) and `BeltRails` (4 belt edits), moving the pipe gap from [177, 183] to [179, 185] with aligned visual geometry and collision. This cleanly frames all 3 singing plants ([179.0, 185.0]) and the right Spike thrower (`EnemyRhythmGabon` 15920962010745316511 at X = 199.0) + pipe simultaneously with 1.0 block of margin on both sides. +4. **Relay chain audit & trigger synchronization (`tools/audit_autoscroll_relays.py`, commits `f4755aa` & Item 2):** + - **Lesson learned (interval parity vs visibility):** When shifting a `CourseDisplayBoxSwitch` in an autoscroll stage, audit and shift every switch in its relay chain (including sibling effect/smoke/tilt triggers) so relative frame intervals do not collapse. However, **interval parity is not visibility** — shifting right-edge visual effect switches left by `-6.56` fires them at the stock `rail_X`, which in a narrower 4:3 view can trigger visual events while their target actors are still off-screen to the right. Visual triggers must fire when their targets are inside `[rail_X, rail_X + view_width]` while shifting the upstream spawn trigger by the same frame delta to preserve the relay interval (`383f`). + - Under opening camera $G = 18.5$ ($W = 24.67$), retuned spawn switch `578319643` to $X = 37.025$ so it activates at frame 744 (after the Pt 1 autoscroll pause), preserving the exact stock 383-frame interval to zap switches at $X = 48.33$ (frame 1127, drift 0.0f). Goombas spawn at frame 944 ($744 + 200$) and walk 183f before lightning strikes at frame 1127. Calibrated against live Eden play-test: nominal $1/32\text{ blk/frame}$ walk speed predicted $X = 40.28125$ & $44.28125$, but live in Eden lightning struck $\sim 2$ blocks to the right of both Goombas (due to faster effective walk speed and bolt impact sparkle taking effect through the $30\text{f}$ growth animation window). Aligned strike `PositionTag`s to $38.28125$ & $42.28125$ and `BadSmokeTag`s to $38.03125$ & $41.53125$, keeping all visual targets and the growth animation fully in-frame at $G = 18.5$. + - Built `tools/audit_autoscroll_relays.py` to simulate `AutoScrollControlSignalFrame` movement, verify relay timing against stock 16:9, model dynamic camera dimensions from `A_HELPER`, enforce on-screen visibility of Kuribo strike targets at $f_{\text{zap}}$ and $f_{\text{zap}} + 30$, and scan all 47 `CourseDisplayBoxSwitch` actors to categorize intentional pre-spawns vs shifted effect switches (`1060316225`, `663300194`, `17459050152995009628`, `742103869`). + - Spiked ball tilt/roll (`1060316225`, `206918284`), fossil zap relay (`663300194`, `17459050152995009628`, `742103869`, `2303338937`), dragon transform (`1787195044`), and vertical shaft switches shifted left by 6.56 blocks in X. Switch `4029477259` was kept at stock X = 206.00 to activate safely after the post-statue rhythm pause rather than prematurely during it. +5. **Opening fists zoom-out & smoke coverage (`A_HELPER`, commit `62e4816`, retuned to G = 18.5):** While shifting rail `pts 0-4` right was rejected because it pushed the left edge into the player on initial descent, a dynamic zoom-out in code cleanly resolves the fist framing. Added `A_HELPER` (`0x02138988..0x021389FC`, 29 instructions in the cave A free space) hooked from Cave A's large-area branch: for `Course290_Main` (hash `2931365200`), when fixed X $\le 40.0$, camera zoom is set to $G = 18.5$ ($W = 24.67$, reducing fist-to-view width ratio to 73% and vertical clearance $[18.00, 36.50]$ centered on Area 2220801104's $Y \in [19.5, 35.0]$); over fixed X $= 40.0 \to 55.0$, $G$ linearly lerps from $18.5 \to 15.75$ ($W = 24.67 \to 21.0$), smoothly transitioning back to the standard large-room zoom before the player reaches Wall 0 at $X = 56$. Smoke shifts scale linearly with zoom: $\text{shift} = (G - 15.5) / 2$, yielding $\pm 1.5$ at $G = 18.5$. Four background smoke actors were extended by $\pm 1.5$ in Y via `build_stage.py`: bottom smoke `DVCommonTorideKemuriB` (`15192233820085708065` and `1591783371223145825`) shifted down $-1.5$ ($Y = 19.17 \to 17.67$ and $18.50 \to 17.00$), and top smoke `DVCommonTorideKemuriA` (`5984094973414626142` and `10892834247364923251`) shifted up $+1.5$ ($Y = 36.75 \to 38.25$ and $36.85 \to 38.35$). Both smoke boundaries remain off-screen throughout the sequence. + +## 49. 2026-11-07: Course290_Main Task B (experiment): intro zoom G = 18.5 hold extension through Ring 2 roll + +**Goal & Timeline derivation:** +To give players more reaction time during the opening obstacle run, extend the $G = 18.5$ zoom hold past the looping dragon skeleton (fossil Ring 2) until it finishes rolling and lands at its end position, then return smoothly to $G = 15.75$ before dragon boarding and the vertical shaft. +1. **Ring 2 roll timeline:** Switch `1755951341` activates at frame 2542 (`rail_X = 70.831`), delay tag `1129071263` (`MapFrame: 70`) triggers Ring 2 roll at frame 2612 on rail `697259476` (`CycleFrame: 300`), which lands at Pt 5 ($X = 108.5, Y = 25.0$) at frame 2912 (`rail_X = 87.296`). In 4:3 at $G = 18.5$ ($W = 24.67$, half-width 12.33), $fixed\_X = 87.296 + 12.333 = 99.63$. +2. **Lerp return range:** Held $G = 18.5$ until $fixed\_X = 100.0$ (`rail_X = 87.67`), lerping linearly to $15.75$ over $fixed\_X \in [100.0, 112.0]$ (span 12.0 blocks, 803 frames). $G = 15.75$ is reached at `rail_X = 101.50`, well before Pt 8 (`rail_X = 102.0`, frame 3790) and the vertical shaft (Pt 10, `rail_X = 128.28`), preserving existing framing for Wall 1 and the vertical shaft. +3. **Trigger retuning:** Under $G = 18.5$, 4:3 width is 24.67 (2.89 blocks narrower than stock 16:9 27.56, rather than 6.56 blocks narrower at $G = 15.75$). Switches firing during the hold (`1060316225`, `206918284`, `663300194`, `17459050152995009628`, `999420502`, `742103869`, `1755951341`) shifted left by $-2.89$ in X. Switches in the return lerp shifted by $-(27.56 - W_{\text{act}})$: `1787195044` (dragon transform, frame 3031, $W = 23.99$) shifted $-3.57$ ($X: 136.0 \to 132.43$), `2303338937` (fossil palette, frame 3282, $W = 23.27$) shifted $-4.29$ ($X: 121.0 \to 116.71$). +4. **Void & smoke coverage:** At $G = 18.5$, Wall 0 covers down to $Y = 8.00$ for $X \in [56, 104]$. Over the gap ($X \in [104, 113]$), bottom smoke `DVCommonTorideKemuriB` `7396728262115999967` shifted down $-1.5$ in Y. Top smoke `DVCommonTorideKemuriA` `13067625065345285749` and `10206074945194904884` shifted up $+1.5$ in Y, keeping edges off-screen across the entire fossil run. +5. **Relay audit:** Extended `audit_autoscroll_relays.py` to take `--g-profile` CLI option and auto-detect from stage triggers. Simulation verifies 0 drift across all audited chains (-1f on dragon transform vs stock -251f interval, well within 5f tolerance). Built stage differs by 100 bytes across 50 declared edits; all verifiers pass. + +## 50. 2026-11-07: Course290_Main Task C: intro zoom entry ramp sizing analysis + +- **Lesson learned (cave budgeting for dual piecewise ramps):** Ramping $G$ and $\Delta$ from cutscene values ($15.75, 3.28$) to intro zoom ($18.5, 1.44$) over $fixed\_X \in [6.5, 12.0]$ requires $\ge 32$ words for dual-ramp logic. With `A_HELPER` capped at 30 words (`0x02138988..0x021389FC`, 29 used) and Cave G end padding offering only 3 free words (`0x02138AF4..0x02138AFC`), an entry ramp does not fit without restructuring existing caves; the 1.83-block snap at cutscene end remains as acceptable behavior. + +## 51. 2026-11-07: Course290_Main Task D: Kuribo strike and growth re-timing + +- **Lesson learned (autoscroll timing limits and platform bounds):** When re-timing autoscroll relays to restore stock pacing, the earliest feasible trigger frame is bounded by the trailing actor's right-edge margin ($V_{\text{right}} \ge X_2 + 1.0$), while leading actors' left positions are bounded by platform geometry ($X_1 \ge 37.0$ through the post-strike growth window). Retuning spawn switch `578319643` to $X = 36.48$ (frame 657) and zap switches `1536962149` / `14869113733391977869` to $X = 43.77$ (frame 1040) cuts the mod's growth delay vs stock from +143f (+2.38 s) down to +56f (+0.93 s) while preserving the exact 383f relay interval, 0 pop-in at spawn (off-screen by >9 blk), and full on-platform alignment. +- **Task D3 (Goomba spawn alignment to bolt strikes):** In Eden measurement, lightning bolt sparkles landed at the tags while Goomba 1 lagged to the right by ~3.5 blocks ($X \sim 42$ vs tag $38.28125$) and Goomba 2 was off-screen right ($X \sim 45.8$). Goomba spawn X, not tag X or switch timing, is the alignment knob. Shifted both `KuriboWillGrowIntoGiant` spawns left by 3.5 blocks in X (`2542738868`: $46.0 \to 42.5$, `1405933960`: $50.0 \to 46.5$). Sign rule for tuning: bolt left of Goomba = move that Goomba's spawn X left by the measured blocks; bolt right of Goomba = move it right. Both Goombas remain fully on-platform ($[37, 53]$ and $[40, 50]$) and spawn off-screen ($X \ge 37.7$ vs view right $36.71$ at f857). + + +## 52. 2026-11-08: Course290_Main intro cutscene: Bowser Jr. jump-frame patch reverted + +- `FinalCourseDemoKoopaJr.pack.zs` `KoopaJrJumpFrame` 45 -> 70 (f432b93) did not hide Bowser Jr. A probe build with 150 looked identical in Eden: he lands at about (25.6, 19.5), just below the floor, and stays until the cutscene ends. The parameter does not control what is seen, so the pack edit (and `build_actor.py`) is reverted. +- **Lesson:** the predicted fall to y 5.22 was free-fall arithmetic, never measured. Run an exaggerated probe before shipping an actor parameter edit. + + +## 53. 2026-11-09: Course290_Main intro cutscene: final camera pose Y raised to match gameplay + +- **Cutscene camera Y vs gameplay camera Y:** `CourseDemo_PreFinalBattle.bfevfl` Event50 (the final cutscene camera pose before gameplay handoff) had `TargetYpos` 27.5 (stock 16:9 bottom rest was 27.25). In 4:3 with $G = 18.5$, gameplay rests at $y = 28.75$ (bottom 19.5 + half-height 9.25), causing a 1.25-block vertical snap at cutscene end. +- Raising Event50 `TargetYpos` 27.5 -> 28.75 lifts the cutscene bottom edge from 18.25 to 19.50. With the letterbox bar covering ~0.7 block (up to $y = 20.20$), Bowser Jr. parked at $y \sim 19.5..20.1$ is fully concealed, eliminating Bug B and removing the handoff snap (Bug A) with zero gameplay impact. + +## 54. 2026-11-09: Course290_Main intro cutscene: Event26 knuckle-slam camera pose Y raised to match Event50 + +- **Knuckle slam cutscene camera Y:** `CourseDemo_PreFinalBattle.bfevfl` Event26 holds the camera pose across all 4 knuckle slams while Bowser Jr. sits in the pit. It still had stock `TargetYpos` 27.5 (view $Y \in [18.25, 36.75]$). In Eden screenshots, Bowser Jr. parked at $(X \approx 25.6, Y \approx 19.5)$ protruded 29 px ($y \in [1006, 1034]$) above the lower letterbox bar ($y \ge 1035$). +- Raising Event26 `TargetYpos` 27.5 -> 28.75 lifts the letterbox bar by ~73 px (view bottom $18.25 \to 19.50$), placing Bowser Jr.'s peak at $y = 1079$ (44 px inside the letterbox bar) and fully concealing him throughout the knuckle slams with zero actor or timing edits. +- **Camera path flattening:** Preceding Event233 uses $Y = 29.0$. With Event26 and Event50 both at $Y = 28.75$, the camera trajectory across the entire latter half of the cutscene is nearly flat ($29.0 \to 28.75 \to 28.75$), completely eliminating the sharp dip down to 27.5 and the subsequent rise back to 28.75. +- **Top void clearance:** At $Y = 28.75$, view top is $38.00$, leaving $0.25$ blocks ($15$ px) clearance below the background smoke planes at $38.25$ and $38.35$ with zero top void exposure. diff --git a/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/exefs/1.2.1.pchtxt b/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/exefs/1.2.1.pchtxt index c68e4ad..1d11f26 100644 --- a/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/exefs/1.2.1.pchtxt +++ b/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/exefs/1.2.1.pchtxt @@ -94,7 +94,7 @@ 02138888 84000054 0213888C CF020018 02138890 D1020018 -02138894 03000014 +02138894 3D000014 02138898 AF020018 0213889C B1020018 021388A0 D0B400B0 @@ -152,6 +152,35 @@ 0213897C D1B400B0 02138980 3C000014 02138984 CDCC4C3D +02138988 D0B400B0 +0213898C 10064FB9 +02138990 AF020018 +02138994 1F020F6B +02138998 6FFAFF18 +0213899C 21F8FF54 +021389A0 909641BD +021389A4 3F02001C +021389A8 103A3F1E +021389AC 1F10251E +021389B0 00223F1E +021389B4 6AF7FF54 +021389B8 FF03271E +021389BC 104A3F1E +021389C0 7F01001C +021389C4 7E01001C +021389C8 107A1F1F +021389CC 0F02261E +021389D0 3F01001C +021389D4 3E01001C +021389D8 107A1F1F +021389DC 1102261E +021389E0 B0FFFF17 +021389E4 5015B9AE +021389E8 0000C842 +021389EC ABAA6ABE +021389F0 00009441 +021389F4 ABAA2ABF +021389F8 DE715C41 02138A00 8A9A41B9 02138A04 6A4201B9 02138A08 8A9E41B9 diff --git a/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/romfs/BancMapUnit/Course290_Main.bcett.byml.zs b/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/romfs/BancMapUnit/Course290_Main.bcett.byml.zs new file mode 100644 index 0000000..5d8baab Binary files /dev/null and b/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/romfs/BancMapUnit/Course290_Main.bcett.byml.zs differ diff --git a/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/romfs/Event/EventFlow/CourseDemo_PreFinalBattle.bfevfl.zs b/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/romfs/Event/EventFlow/CourseDemo_PreFinalBattle.bfevfl.zs new file mode 100644 index 0000000..7721049 Binary files /dev/null and b/super-mario-bros-wonder/mod/Native 4x3 Aspect Ratio/romfs/Event/EventFlow/CourseDemo_PreFinalBattle.bfevfl.zs differ diff --git a/super-mario-bros-wonder/tools/audit_autoscroll_relays.py b/super-mario-bros-wonder/tools/audit_autoscroll_relays.py new file mode 100644 index 0000000..356ce43 --- /dev/null +++ b/super-mario-bros-wonder/tools/audit_autoscroll_relays.py @@ -0,0 +1,405 @@ +"""Audit autoscroll relay switch timings between stock 16:9 and native 4:3. + +Simulates AutoScrollControlSignalFrame movement along an autoscroll rail in +stock 16:9 (view width = 27.5556) vs 4:3 (view width = 21.0), computes the +activation frame of every CourseDisplayBoxSwitch (checking both X and Y box +overlap against the moving camera view), traces Links (Create, Delete, Start, +BasicSignal) and ResidentSignalDelayTag / LogicalSignalORTag chains, and flags +any sibling/relay switch pairs whose frame interval changed between stock 16:9 +and the modded .bcett.byml.zs. +""" + +import argparse +import math +import os +import sys + +# Allow importing byml from current or script directory +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from byml import parse +from bymlpatch import read + + +WIDTH_16_9 = 27.5556 +WIDTH_4_3 = 21.0 +STOCK_HEIGHT = 15.5 + + +def ease(t, curve): + t = max(0.0, min(1.0, t)) + if curve == 'QuadInOut': + return 2.0 * t * t if t < 0.5 else 1.0 - (-2.0 * t + 2.0) ** 2 / 2.0 + elif curve == 'QuartInOut': + return 8.0 * t ** 4 if t < 0.5 else 1.0 - (-2.0 * t + 2.0) ** 4 / 2.0 + return t + + +def simulate_autoscroll(tree): + """Simulate frame-by-frame trajectory of the autoscroll camera rail.""" + as_actors = [ + a for a in tree.get('Actors', []) + if a.get('Gyaml') in ('AutoScrollControlSignalFrame', 'SoundRhythmAutoScrollControlSignalFrame') + ] + if not as_actors: + return None, None, [] + + as_actor = as_actors[0] + links = [l for l in tree.get('ActorToRailLinks', []) if l.get('Src') == as_actor['Hash']] + if not links: + return None, None, [] + + rail_hash = links[0]['Dst'] + rails = [r for r in tree.get('Rails', []) if r.get('Hash') == rail_hash] + if not rails: + return None, None, [] + + pts = rails[0].get('Points', []) + if len(pts) < 2: + return None, None, [] + + traj = [] + cur_frame = 0 + pwf = as_actor.get('Dynamic', {}).get('PulledWaitFrame', 0) + p0 = pts[0]['Translate'] + for _ in range(pwf): + traj.append((cur_frame, p0[0], p0[1])) + cur_frame += 1 + + for i in range(len(pts) - 1): + p_cur = pts[i]['Translate'] + p_nxt = pts[i + 1]['Translate'] + dyn = pts[i].get('Dynamic', {}) + dur = dyn.get('SectionFrame', 60) + curve = dyn.get('PresetCurveType', 'QuadInOut') + wf = dyn.get('WaitFrame', 0) + for _ in range(wf): + traj.append((cur_frame, p_cur[0], p_cur[1])) + cur_frame += 1 + for step in range(dur): + u = step / float(dur) + alpha = ease(u, curve) + x = p_cur[0] + alpha * (p_nxt[0] - p_cur[0]) + y = p_cur[1] + alpha * (p_nxt[1] - p_cur[1]) + traj.append((cur_frame, x, y)) + cur_frame += 1 + + return as_actor, rails[0], traj + + +def get_camera_dims(rx, is_mod=False, course_name='Course290_Main', g_profile=None): + """Return (view_width, view_height) for the autoscroll camera. + + For Course290_Main in native 4:3, models A_HELPER: + - Default profile: fixed_X <= 100.0 (rail_X <= 87.6667): G = 18.5, W = 24.6667 + 100.0 < fixed_X < 112.0 (87.6667 < rail_X < 101.5): linear lerp G = 18.5 -> 15.75 + fixed_X >= 112.0 (rail_X >= 101.5): G = 15.75, W = 21.0 + - If g_profile=(x0, x1, g0, g1) is provided, calculates the rail_X thresholds + and lerp accordingly. + """ + if not is_mod or course_name != 'Course290_Main': + return (WIDTH_4_3 if is_mod else WIDTH_16_9), (15.75 if is_mod else STOCK_HEIGHT) + if g_profile is None: + g_profile = (100.0, 112.0, 18.5, 15.75) + x0, x1, g0, g1 = g_profile + rx0 = x0 - g0 * (2.0 / 3.0) + rx1 = x1 - g1 * (2.0 / 3.0) + if rx <= rx0: + g = g0 + elif rx >= rx1: + g = g1 + else: + span = x1 - x0 + dg = g1 - g0 + denom = 1.0 - (dg / span) * (2.0 / 3.0) + num = rx + (g0 - (dg * x0 / span)) * (2.0 / 3.0) + fx = num / denom + g = g0 + dg * (fx - x0) / span + return g * 4.0 / 3.0, g + + +def compute_switch_activations(tree, trajectory, is_mod=False, course_name='Course290_Main', g_profile=None): + """Find the first frame where each CourseDisplayBoxSwitch overlaps the camera view in X and Y.""" + switches = [a for a in tree.get('Actors', []) if a.get('Gyaml') == 'CourseDisplayBoxSwitch'] + activations = {} + for sw in switches: + h = sw['Hash'] + tx, ty = sw['Translate'][0], sw['Translate'][1] + sx = sw.get('Scale', [1.0, 1.0, 1.0])[0] + sy = sw.get('Scale', [1.0, 1.0, 1.0])[1] + bx1, bx2 = tx - sx / 2.0, tx + sx / 2.0 + by1, by2 = ty - sy / 2.0, ty + sy / 2.0 + act_frame = None + for f, rx, ry in trajectory: + vw, vh = get_camera_dims(rx, is_mod=is_mod, course_name=course_name, g_profile=g_profile) + cx1, cx2 = rx, rx + vw + cy1, cy2 = ry - vh, ry + if bx2 >= cx1 and bx1 <= cx2 and by2 >= cy1 and by1 <= cy2: + act_frame = f + break + activations[h] = act_frame + return activations + + +def trace_switch_links(tree): + """Trace outgoing links and signal relays from CourseDisplayBoxSwitch actors.""" + actors_by_hash = {a['Hash']: a for a in tree.get('Actors', [])} + links = tree.get('Links', []) + signal_links = [ + l for l in links + if l.get('Name') in ('Create', 'Delete', 'Start', 'BasicSignal') + ] + + switch_targets = {} + switches = [a['Hash'] for a in tree.get('Actors', []) if a.get('Gyaml') == 'CourseDisplayBoxSwitch'] + + for sh in switches: + visited = set() + targets = set() + queue = [sh] + while queue: + curr = queue.pop(0) + if curr in visited: + continue + visited.add(curr) + out = [l for l in signal_links if l.get('Src') == curr] + for l in out: + dst = l.get('Dst') + dst_act = actors_by_hash.get(dst, {}) + gyaml = dst_act.get('Gyaml', '') + targets.add((l.get('Name'), dst, gyaml)) + if 'Tag' in gyaml or 'Signal' in gyaml: + queue.append(dst) + switch_targets[sh] = targets + + return switch_targets + + +def audit_stage(orig_tree, mod_tree, course_name='Course290_Main', tolerance=5.0, g_profile=None): + """Audit switch activation intervals between stock 16:9 and mod 4:3.""" + _, _, traj_stock = simulate_autoscroll(orig_tree) + _, _, traj_mod = simulate_autoscroll(mod_tree) + + if not traj_stock or not traj_mod: + print(f"[{course_name}] No autoscroll rail found or simulation failed.") + return 0 + + if course_name == 'Course290_Main' and g_profile is None: + sw1060 = next((a for a in mod_tree.get('Actors', []) if a.get('Hash') == 1060316225), None) + if sw1060 and sw1060.get('Translate', [0])[0] > 68.5: + g_profile = (100.0, 112.0, 18.5, 15.75) + else: + g_profile = (40.0, 55.0, 18.5, 15.75) + + acts_stock = compute_switch_activations(orig_tree, traj_stock, is_mod=False, course_name=course_name) + acts_mod = compute_switch_activations(mod_tree, traj_mod, is_mod=True, course_name=course_name, g_profile=g_profile) + + print(f"=== Autoscroll Relay Audit: {course_name} ===") + print(f"Trajectory length: stock={len(traj_stock)}f, mod={len(traj_mod)}f") + print(f"Audited switches: {len(acts_stock)} total CourseDisplayBoxSwitch actors") + if course_name == 'Course290_Main' and g_profile: + print(f"Camera zoom G profile: x0={g_profile[0]}, x1={g_profile[1]}, g0={g_profile[2]}, g1={g_profile[3]}\n") + else: + print() + + # Defined relay chains for Course290_Main + relay_groups = [ + ("Kuribo Grow & Zap Relay", [ + (578319643, 1536962149, "Kuribo Spawn -> Zap 1"), + (578319643, 14869113733391977869, "Kuribo Spawn -> Zap 2"), + (1536962149, 14869113733391977869, "Zap 1 -> Zap 2 (Sibling)"), + ], 20.0), + ("Tilt, Spiked Ball & Fossil Zap Relay", [ + (1060316225, 206918284, "Zap 67.5 -> Screen Tilt / Spiked Ball Roll"), + (206918284, 663300194, "Screen Tilt -> Zap 85.5"), + (663300194, 17459050152995009628, "Zap 85.5 -> Zap 87.5"), + (17459050152995009628, 999420502, "Zap 87.5 -> Fossil Ring 1 Spawn"), + (999420502, 742103869, "Fossil Ring 1 Spawn -> Zap 93.0"), + (742103869, 1755951341, "Zap 93.0 -> Ring 1 Delete / Ring 2 Spawn"), + (1755951341, 2303338937, "Ring 2 Spawn -> Zap 108.5"), + (2303338937, 1787195044, "Zap 108.5 -> Dragon Transform"), + ], 5.0), + ("Vertical Shaft & Statue Section (pts 16-17 pause shifted +5.5 by design)", [ + (1117151842, 4273434636, "Shaft Approach -> Snake Ground Spawn"), + (777445035, 12855344573256944945, "Statue TossinGroup -> Pre-Pause Packun"), + (12855344573256944945, 212790001, "Pre-Pause Packun -> Rhythm Pause Trigger"), + ], 60.0), + ] + + flagged = 0 + + for group_name, pairs, group_tol in relay_groups: + print(f"--- {group_name} ---") + for h1, h2, desc in pairs: + s1 = acts_stock.get(h1) + s2 = acts_stock.get(h2) + m1 = acts_mod.get(h1) + m2 = acts_mod.get(h2) + + if s1 is None or s2 is None or m1 is None or m2 is None: + print(f" [MISSING] {desc} ({h1} -> {h2}): frame lookup failed") + flagged += 1 + continue + + stock_interval = s2 - s1 + mod_interval = m2 - m1 + drift = mod_interval - stock_interval + + status = "OK" + if abs(drift) > group_tol: + status = f"DRIFT ({drift:+.1f}f)" + flagged += 1 + + print( + f" [{status:^7s}] {desc:42s} | " + f"16:9: [{s1:5d} -> {s2:5d}] ({stock_interval:5d}f) | " + f"4:3: [{m1:5d} -> {m2:5d}] ({mod_interval:5d}f) | drift: {drift:+5.1f}f" + ) + print() + + # Special check: verify switch 4029477259 fires AFTER rhythm pause in both stock and mod + s_pause_resume = 6730 # Approx frame where scroll leaves pt 17 (X = 174.0) in stock + s_4029 = acts_stock.get(4029477259) + m_4029 = acts_mod.get(4029477259) + print("--- Rhythm Pause Exit Check: Switch 4029477259 ---") + print(f" Stock 16:9 activation frame: {s_4029}") + print(f" Mod 4:3 activation frame: {m_4029}") + # pt 17 starts at frame 6027, ends at 6370 in mod + if m_4029 is not None and m_4029 >= 6370: + print(" [ OK ] Switch 4029477259 correctly activates AFTER the rhythm pause.\n") + else: + print(f" [ WARN ] Switch 4029477259 activated at frame {m_4029} (during rhythm pause!).\n") + flagged += 1 + + # On-Screen Visibility Check (Course290_Main) + if course_name == 'Course290_Main': + print("--- Kuribo On-Screen Visibility Check ---") + actors_by_hash = {a['Hash']: a for a in mod_tree.get('Actors', [])} + f_zap = acts_mod.get(1536962149) + if f_zap is None: + print(" [FAIL] Kuribo zap switch 1536962149 did not activate!") + flagged += 1 + else: + enforced_targets = [ + (4814110068085501760, "Kuribo Strike Tag 1 (PositionTag)", 38.28125), + (12276017923517845206, "Kuribo Strike Tag 2 (PositionTag)", 42.28125), + (2306045187355644410, "Kuribo Smoke Tag 1 (BadSmokeTag)", 38.03125), + (5602005781468990395, "Kuribo Smoke Tag 2 (BadSmokeTag)", 41.53125), + ] + for check_f, label in [(f_zap, "Lightning Strike (f_zap)"), (f_zap + 30, "Growth Animation (f_zap + 30)")]: + if check_f >= len(traj_mod): + print(f" [FAIL] Frame {check_f} beyond trajectory length {len(traj_mod)}") + flagged += 1 + continue + rx = traj_mod[check_f][1] + vw, _ = get_camera_dims(rx, is_mod=True, course_name=course_name, g_profile=g_profile) + v_left, v_right = rx, rx + vw + print(f" {label:32s} | Frame {check_f:5d} | View: [{v_left:6.2f}, {v_right:6.2f}]") + for th, desc, expected_x in enforced_targets: + act = actors_by_hash.get(th) + actual_x = act['Translate'][0] if act else expected_x + is_on = (v_left <= actual_x <= v_right) + matches_expected = (act is not None and abs(actual_x - expected_x) <= 0.001) + status = "OK" if (is_on and matches_expected) else ("MISMATCH" if not matches_expected else "OFFSCREEN") + if not is_on or not matches_expected: + flagged += 1 + print(f" [{status:^9s}] {desc:36s} | Target X = {actual_x:6.2f} (expected {expected_x:.5f})") + print() + + # Target Visibility Scan for all 47 CourseDisplayBoxSwitch actors + print("--- CourseDisplayBoxSwitch Target Visibility Scan (Course290_Main) ---") + SHIFTED_EFFECT_SWITCHES = {1060316225, 663300194, 17459050152995009628, 742103869, 1787195044, 2303338937} + switch_targets = trace_switch_links(mod_tree) + switches = [a for a in mod_tree.get('Actors', []) if a.get('Gyaml') == 'CourseDisplayBoxSwitch'] + scan_results = [] + for sw in sorted(switches, key=lambda a: a['Translate'][0]): + sh = sw['Hash'] + f = acts_mod.get(sh) + if f is None: + continue + rx = traj_mod[f][1] + vw, _ = get_camera_dims(rx, is_mod=True, course_name=course_name, g_profile=g_profile) + v_left, v_right = rx, rx + vw + targets = [actors_by_hash[dst] for _, dst, _ in switch_targets.get(sh, set()) if dst in actors_by_hash] + off_targets = [t for t in targets if t.get('Translate') and (t['Translate'][0] < v_left or t['Translate'][0] > v_right)] + if off_targets: + category = "Shifted Effect Switch" if sh in SHIFTED_EFFECT_SWITCHES else "Intentional Pre-Spawn" + scan_results.append((sh, sw['Translate'][0], f, v_left, v_right, category, off_targets)) + + print(f"Total switches audited: {len(switches)} | Switches with targets beyond view edge: {len(scan_results)}\n") + print(f"{'Switch Hash':<22s} | {'Switch X':>8s} | {'Act Frame':>9s} | {'View Range':>16s} | {'Category':<22s} | {'Off-screen Target Examples'}") + print("-" * 120) + for sh, sx, f, vl, vr, cat, off_targets in scan_results: + examples = ", ".join(f"{t.get('Gyaml')}(X={t.get('Translate')[0]:.1f})" for t in off_targets[:2]) + if len(off_targets) > 2: + examples += f" (+{len(off_targets)-2} more)" + print(f"{sh:<22d} | {sx:8.2f} | {f:9d} | [{vl:6.2f}, {vr:6.2f}] | {cat:<22s} | {examples}") + print() + + if flagged == 0: + print("Audit result: 0 drift/timing problem(s) detected across all audited relays.") + else: + print(f"Audit result: {flagged} problem(s) detected.") + + return flagged + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('orig_romfs', nargs='?', default=None, + help="Path to extracted original RomFS (or set SMBW_ORIG_ROMFS)") + parser.add_argument('mod_target', nargs='?', default=None, + help="Path to modded RomFS or .bcett.byml.zs file (defaults to repo mod folder)") + parser.add_argument('--course', default='Course290_Main', + help="Course name to audit (default: Course290_Main)") + parser.add_argument('--tolerance', type=float, default=5.0, + help="Max allowed frame drift before flagging (default: 5.0f)") + parser.add_argument('--g-profile', default=None, + help="Camera zoom G profile as 'x0,x1,g0,g1' (e.g. '100,112,18.5,15.75'). If omitted, auto-detected from stage triggers.") + args = parser.parse_args() + + g_profile = None + if args.g_profile: + try: + parts = [float(p.strip()) for p in args.g_profile.split(',')] + assert len(parts) == 4 + g_profile = tuple(parts) + except Exception: + sys.exit("Error: --g-profile must be four comma-separated floats: x0,x1,g0,g1 (e.g. 100,112,18.5,15.75)") + + orig_romfs = args.orig_romfs or os.environ.get('SMBW_ORIG_ROMFS') + if not orig_romfs: + # Check standard workspace extracted path if present + default_extracted = os.path.join( + os.path.dirname(__file__), '..', '..', 'extracted', 'romfs-1.2.1' + ) + if os.path.isdir(default_extracted): + orig_romfs = default_extracted + else: + sys.exit("Usage: python audit_autoscroll_relays.py [mod_target] [--course COURSE]\n" + "Or set the SMBW_ORIG_ROMFS environment variable.") + + mod_target = args.mod_target + if not mod_target: + mod_target = os.path.join( + os.path.dirname(__file__), '..', 'mod', 'Native 4x3 Aspect Ratio', 'romfs' + ) + + orig_path = (orig_romfs if orig_romfs.endswith('.zs') + else os.path.join(orig_romfs, 'BancMapUnit', f'{args.course}.bcett.byml.zs')) + mod_path = (mod_target if mod_target.endswith('.zs') + else os.path.join(mod_target, 'BancMapUnit', f'{args.course}.bcett.byml.zs')) + + if not os.path.exists(orig_path): + sys.exit(f"Original stage file not found: {orig_path}") + if not os.path.exists(mod_path): + sys.exit(f"Modded stage file not found: {mod_path}") + + orig_tree = parse(read(orig_path)) + mod_tree = parse(read(mod_path)) + + problems = audit_stage(orig_tree, mod_tree, course_name=args.course, tolerance=args.tolerance, g_profile=g_profile) + sys.exit(0 if problems == 0 else 1) + + +if __name__ == '__main__': + main() diff --git a/super-mario-bros-wonder/tools/build_stage.py b/super-mario-bros-wonder/tools/build_stage.py index ec6bad6..f27d3a3 100644 --- a/super-mario-bros-wonder/tools/build_stage.py +++ b/super-mario-bros-wonder/tools/build_stage.py @@ -1,13 +1,14 @@ -"""Stage (BancMapUnit) edits for the 4:3 mod: same-size float and guarded actor-type edits from the 1.2.1 originals. +"""Stage (BancMapUnit) and Event (EventFlow) edits for the 4:3 mod: same-size float and guarded actor-type edits from the 1.2.1 originals. usage: python build_stage.py - Writes /romfs/BancMapUnit/.bcett.byml.zs for every course in EDITS. + Writes /romfs/BancMapUnit/.bcett.byml.zs for every course in EDITS and + /romfs/Event/EventFlow/.bfevfl.zs for every flow in EVENT_EDITS. python build_stage.py --verify - Checks the shipped files in /BancMapUnit: exactly the declared courses, each differing from its - original only in the declared float/string edits. Exits 1 on any problem. + Checks the shipped files in : exactly the declared courses/events, each differing from its + original only in the declared edits. Exits 1 on any problem. - is the extracted 1.2.1 romfs (needs BancMapUnit/). + is the extracted 1.2.1 romfs (needs BancMapUnit/ and Event/EventFlow/). """ import os, struct, sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) @@ -128,6 +129,122 @@ (23.5, 48.0, -167.5), (23.5, 49.5, -167.5)), ('Course407_Course', 3373664933504165692, 'DVWaKaiganFarIwaA01', 'Scale', (0.699999988079071, 0.699999988079071, 0.699999988079071), (0.82, 0.82, 0.82)), + # Course290_Main (Bowser's Rage Stage - Kuribo grow & zap relay retuning for on-screen visibility & strike alignment): + # Under opening camera G = 18.5 (view width 24.67), retune zap switches 1536962149 and 14869113733391977869 to X = 43.77 + # so they fire at rail X = 18.63 (frame 1040, view [18.63, 43.30]), framing all strike and smoke tags on-screen. + # Retune spawn switch 578319643 to X = 36.48 so it activates at frame 657, preserving + # the exact stock 383-frame relay interval (frame 1040 - 657 = 383f, drift 0.0f). + # With 200f spawn delay (frame 857), Kuribos walk 183f before lightning strikes at frame 1040. + # Calibrated against stock and Eden play-test: Goombas walk faster/further than nominal 1/32 blk/frame (reaching X ~ 38.3 & 42.3). + # Align strike PositionTags and BadSmokeTags to where the Goombas actually are in Eden: + # Goomba 1 at X = 38.28125 (tag 38.28125, smoke 38.03125); Goomba 2 at X = 42.28125 (tag 42.28125, smoke 41.53125). + # Growth fires 30f later at frame 1070, fully on-screen in view [20.28, 44.95]. + ('Course290_Main', 578319643, 'CourseDisplayBoxSwitch', 'Translate', + (38.5, 20.537498474121094, 0.0), (36.48, 20.537498474121094, 0.0)), + ('Course290_Main', 1536962149, 'CourseDisplayBoxSwitch', 'Translate', + (44.0, 34.051910400390625, 0.0), (43.77, 34.051910400390625, 0.0)), + ('Course290_Main', 14869113733391977869, 'CourseDisplayBoxSwitch', 'Translate', + (44.0, 33.16312026977539, 0.0), (43.77, 33.16312026977539, 0.0)), + ('Course290_Main', 4814110068085501760, 'PositionTag', 'Translate', + (43.25, 24.0, 0.0), (38.28125, 24.0, 0.0)), + ('Course290_Main', 12276017923517845206, 'PositionTag', 'Translate', + (46.25, 28.0, 0.0), (42.28125, 28.0, 0.0)), + ('Course290_Main', 2306045187355644410, 'LastBossWonderBadSmokeTag', 'Translate', + (43.0, 35.5, 0.0), (38.03125, 35.5, 0.0)), + ('Course290_Main', 5602005781468990395, 'LastBossWonderBadSmokeTag', 'Translate', + (45.5, 35.5, 0.0), (41.53125, 35.5, 0.0)), + # Shift Goomba spawns left by 3.5 blocks (Task D3) to align walking Goombas to bolt strikes at tags 38.28125 & 42.28125: + ('Course290_Main', 2542738868, 'KuriboWillGrowIntoGiant', 'Translate', + (46.0, 23.0, 0.0), (42.5, 23.0, 0.0)), + ('Course290_Main', 1405933960, 'KuriboWillGrowIntoGiant', 'Translate', + (50.0, 28.5, 0.0), (46.5, 28.5, 0.0)), + # Course290_Main (Bowser's Rage Stage - Tilt, rolling spiked ball, fossil rings & dragon relay): + # With the intro zoom G = 18.5 hold extended to fixed_X in [100.0, 112.0] (rail_X in [87.67, 101.50]), the 4:3 + # camera width is 24.67 (2.89 blocks narrower than stock 16:9 27.56, rather than 6.56 blocks narrower at G = 15.75). + # Shift triggers firing during the G = 18.5 hold (1060316225, 206918284, 663300194, 17459050152995009628, 999420502, + # 742103869, 1755951341) left by -2.89 blocks in X. + # Shift triggers firing during the return lerp according to view width at activation: + # - 1787195044 (dragon transform, frame 3031, W = 23.99) shifted by -3.57 blocks (X: 136.0 -> 132.43). + # - 2303338937 (fossil palette, frame 3282, W = 23.27) shifted by -4.29 blocks (X: 121.0 -> 116.71). + # This preserves 0-drift relative timing across the entire rolling obstacle and zap obstacle course. + ('Course290_Main', 1060316225, 'CourseDisplayBoxSwitch', 'Translate', + (73.5, 34.513580322265625, 0.0), (70.61111450195312, 34.513580322265625, 0.0)), + ('Course290_Main', 206918284, 'CourseDisplayBoxSwitch', 'Translate', + (81.5, 20.342161178588867, 0.0), (78.61111450195312, 20.342161178588867, 0.0)), + ('Course290_Main', 663300194, 'CourseDisplayBoxSwitch', 'Translate', + (88.5, 35.5, 0.0), (85.61111450195312, 35.5, 0.0)), + ('Course290_Main', 17459050152995009628, 'CourseDisplayBoxSwitch', 'Translate', + (89.5, 35.5, 0.0), (86.61111450195312, 35.5, 0.0)), + ('Course290_Main', 999420502, 'CourseDisplayBoxSwitch', 'Translate', + (90.5, 21.96936798095703, 0.0), (87.61111450195312, 21.96936798095703, 0.0)), + ('Course290_Main', 742103869, 'CourseDisplayBoxSwitch', 'Translate', + (98.52086639404297, 35.10392761230469, 0.0), (95.6319808959961, 35.10392761230469, 0.0)), + ('Course290_Main', 1755951341, 'CourseDisplayBoxSwitch', 'Translate', + (106.0, 19.168628692626953, 0.0), (103.11111450195312, 19.168628692626953, 0.0)), + ('Course290_Main', 2303338937, 'CourseDisplayBoxSwitch', 'Translate', + (121.0, 34.49203872680664, 0.0), (116.70992279052734, 34.49203872680664, 0.0)), + ('Course290_Main', 1787195044, 'CourseDisplayBoxSwitch', 'Translate', + (136.0, 26.0, 0.0), (132.43197631835938, 26.0, 0.0)), + # Course290_Main (Bowser's Rage Stage - Vertical shaft ground & guide coins): + # Switch 4273434636 (stock min_x = 146.50, missed by 4:3 right edge at 146.0) fires to spawn the bottom + # horizontal snake-block ground (ObjectBlockSnakePole 34729090 at Y = 27.5..31.5) and guide coins before + # the vertical shaft climb. Switches 1117151842, 3717095890, and 1344248650 spawn intermediate snake poles. + ('Course290_Main', 1117151842, 'CourseDisplayBoxSwitch', 'Translate', + (146.0, 32.5, 0.0), (139.44, 32.5, 0.0)), + ('Course290_Main', 4273434636, 'CourseDisplayBoxSwitch', 'Translate', + (152.5449676513672, 25.0, 0.0), (145.9849676513672, 25.0, 0.0)), + ('Course290_Main', 3717095890, 'CourseDisplayBoxSwitch', 'Translate', + (155.3033447265625, 47.0, 0.0), (148.7433447265625, 47.0, 0.0)), + ('Course290_Main', 1344248650, 'CourseDisplayBoxSwitch', 'Translate', + (155.8292236328125, 58.66417694091797, 0.0), (149.2692236328125, 58.66417694091797, 0.0)), + # Course290_Main (Bowser's Rage Stage - Bowser statue section): SetAutoScrollPos left-aligns the 21.0-wide + # 4:3 view to the autoscroll rail, cutting 6.56 blocks off the right edge vs stock 16:9 (27.56). Shift the + # statue-section CourseDisplayBoxSwitch triggers left by 6.56 blocks in X so EnemyTossinGroup spawns during + # the slow approach (pt 13->14, rail X 147.94) before the scroll reaches the statue at X = 156.5, and the + # post-statue pause/Packun switch (12855344573256944945) enters the 4:3 view (max X 195.0) at rail X = 174.0. + # Note: switch 4029477259 is intentionally kept at stock X = 206.00457763671875 (min_x = 202.82) so it fires + # after the rhythm pause (pt 17 -> pt 18) instead of prematurely during the pause. + ('Course290_Main', 777445035, 'CourseDisplayBoxSwitch', 'Translate', + (198.0, 52.0, 0.0), (191.44, 52.0, 0.0)), + ('Course290_Main', 212790001, 'CourseDisplayBoxSwitch', 'Translate', + (223.04513549804688, 51.73638153076172, 0.0), (216.48513549804688, 51.73638153076172, 0.0)), + ('Course290_Main', 12855344573256944945, 'CourseDisplayBoxSwitch', 'Translate', + (199.5, 52.0, 0.0), (192.94, 52.0, 0.0)), + # Course290_Main (Bowser's Rage Stage - Post-statue rhythm pause singing plants & pipes): + # In 4:3 (width 21.0), with the rhythm pause plateau at rail X = 179.0, the camera frames X = [179.0, 200.0]. + # Shift the 3 left rising pipes (SoundRhythmObjectUpDownDokan) and 3 singing Piranha Plants (EnemySoundRunRunPackun) + # right by +2.0 blocks (X = 178, 180, 182 -> 180, 182, 184) to pull them away from the left screen edge and frame + # both the left singing group and the right Spike thrower (X = 199.0) simultaneously with 1.0 block margin. + ('Course290_Main', 14018291091925094241, 'SoundRhythmObjectUpDownDokan', 'Translate', + (178.0, 39.0, 0.0), (180.0, 39.0, 0.0)), + ('Course290_Main', 18409431755698402034, 'SoundRhythmObjectUpDownDokan', 'Translate', + (180.0, 39.0, 0.0), (182.0, 39.0, 0.0)), + ('Course290_Main', 4568669752595535956, 'SoundRhythmObjectUpDownDokan', 'Translate', + (182.0, 39.0, 0.0), (184.0, 39.0, 0.0)), + ('Course290_Main', 1451404568616177091, 'EnemySoundRunRunPackun', 'Translate', + (178.0, 47.0, 0.0), (180.0, 47.0, 0.0)), + ('Course290_Main', 16407013882060977642, 'EnemySoundRunRunPackun', 'Translate', + (180.0, 47.0, 0.0), (182.0, 47.0, 0.0)), + ('Course290_Main', 1044554605811720563, 'EnemySoundRunRunPackun', 'Translate', + (182.0, 47.0, 0.0), (184.0, 47.0, 0.0)), + # Course290_Main (Bowser's Rage Stage - Fist & fossil section smoke coverage): + # With G = 18.5 (view height 18.5, vertical range [18.00, 36.50]), expand the vertical coverage of the + # background smoke planes by shifting bottom smoke actors down by -1.5 in Y and top smoke actors up by +1.5 in Y + # so the smoke edges stay offscreen across both the opening fist and fossil sections. + ('Course290_Main', 15192233820085708065, 'DVCommonTorideKemuriB', 'Translate', + (5.3074798583984375, 19.16788673400879, -60.0), (5.3074798583984375, 17.66788673400879, -60.0)), + ('Course290_Main', 1591783371223145825, 'DVCommonTorideKemuriB', 'Translate', + (27.5, 18.5, -60.0), (27.5, 17.0, -60.0)), + ('Course290_Main', 5984094973414626142, 'DVCommonTorideKemuriA', 'Translate', + (-3.859537124633789, 36.74950408935547, -61.515625), (-3.859537124633789, 38.24950408935547, -61.515625)), + ('Course290_Main', 10892834247364923251, 'DVCommonTorideKemuriA', 'Translate', + (19.93733787536621, 36.85106658935547, -86.515625), (19.93733787536621, 38.35106658935547, -86.515625)), + ('Course290_Main', 13067625065345285749, 'DVCommonTorideKemuriA', 'Translate', + (56.0, 35.5, -60.0), (56.0, 37.0, -60.0)), + ('Course290_Main', 7396728262115999967, 'DVCommonTorideKemuriB', 'Translate', + (78.09263610839844, 20.79288673400879, -60.0), (78.09263610839844, 19.29288673400879, -60.0)), + ('Course290_Main', 10206074945194904884, 'DVCommonTorideKemuriA', 'Translate', + (99.5, 32.5, -60.0), (99.5, 34.0, -60.0)), # World001 (Pipe-Rock Plateau map), subregion 22 (underground area: sign, ? block, courses 9 and 10, KO arena): # the camera is fixed on WorldMapCameraLookAtTag obj479 at x 87.25 and never follows Mario. At that depth the # view is ~48 px per unit at ~1060 rows: 16:9 shows x ~67.6-106.9, 4:3 only ~72.5-102.0, so the hidden warp @@ -171,6 +288,13 @@ ('Course152_Sub4', 1, 1, 5, (50.0, -7.0, 0.0), (50.0, -10.0, 0.0)), ('Course152_Sub4', 1, 2, 0, (79.0, -7.0, 0.0), (79.0, -10.0, 0.0)), ('Course152_Sub4', 1, 2, 21, (92.0, -7.0, 0.0), (92.0, -10.0, 0.0)), + # Course290_Main (Bowser's Rage Stage - Post-statue rhythm pause pipe gap): + # Shift Wall 2 right boundary (pts 2-3) and Wall 5 left boundary (pts 0-1) right by +2.0 blocks in X so the gap + # beneath the rising rhythm pipes moves from X = [177, 183] to [179, 185]. + ('Course290_Main', 0, 2, 2, (177.0, 47.0, 0.0), (179.0, 47.0, 0.0)), + ('Course290_Main', 0, 2, 3, (177.0, 8.0, 0.0), (179.0, 8.0, 0.0)), + ('Course290_Main', 0, 5, 0, (183.0, 42.0, 0.0), (185.0, 42.0, 0.0)), + ('Course290_Main', 0, 5, 1, (183.0, 47.0, 0.0), (185.0, 47.0, 0.0)), ] # (course, rail_hash, point_idx, orig_xyz, new_xyz) # Course853_Main (Sunbaked Desert Special: Pole Block Allure - Autoscroll rail intermediate vertical centering): @@ -202,24 +326,78 @@ ('Course853_Main', 1776580222928036096, 2, (38.0, 25.5, 0.0), (38.0, 22.75, 0.0)), ('Course853_Main', 1776580222928036096, 3, (63.0, 41.0, 0.0), (63.0, 36.0, 0.0)), ('Course853_Main', 1776580222928036096, 12, (226.75, 147.0, 0.0), (231.335, 147.0, 0.0)), + # In Course290_Main, AutoScrollControlSignalFrame (4286093022) on Rail 185828596 passes rail_X + current_half_width + # to SetAutoScrollPos, left-aligning the 21.0-wide 4:3 view to rail_X and cutting 6.56 blocks off the right edge vs + # stock 16:9 (27.56): + # - Dragon & vertical shaft section (pts 8-11): pt 6 is kept at stock 92.0 to maintain the fossil relay timing. + # Shift pt 8 right to frame Wall 1 [113, 122] without pushing the player off Wall 0 (ends at X = 104), and shift + # pts 9-11 right by +3.28 so the 840-frame vertical shaft climb (CameraArea 3010860670, X = [124.75, 152.25]) + # is centered at X = 138.78. + # - Post-statue rhythm pause (pts 16-17): shift the rhythm pause plateau from 174.0 to 179.0 to frame + # X = [179.0, 200.0] in 4:3, fitting all 3 shifted singing plants/pipes ([179.0, 185.0]) and the Spike thrower + # (15920962010745316511 at X = 199.0) + right pipe (9780181108041827457 at X = 199.0) simultaneously with + # 1.0 block of margin from both actor centers (180.0 and 199.0) to the screen edges. + ('Course290_Main', 185828596, 8, (101.0, 35.0, 0.0), (102.0, 35.0, 0.0)), + ('Course290_Main', 185828596, 9, (112.0, 35.0, 0.0), (115.28, 35.0, 0.0)), + ('Course290_Main', 185828596, 10, (125.0, 35.0, 0.0), (128.28, 35.0, 0.0)), + ('Course290_Main', 185828596, 11, (125.0, 60.0, 0.0), (128.28, 60.0, 0.0)), + ('Course290_Main', 185828596, 16, (174.0, 60.0, 0.0), (179.0, 60.0, 0.0)), + ('Course290_Main', 185828596, 17, (174.0, 60.0, 0.0), (179.0, 60.0, 0.0)), ] +# (course, unit_idx, belt_idx, point_idx, orig_xyz, new_xyz) +# In Course290_Main, BgUnits[0] has matching conveyor belt collision rails (BeltRails) that define the top surface +# of Wall 2 and Wall 5. Both Walls and BeltRails must be shifted together to keep the visual geometry and collision aligned. +BELT_EDITS = [ + ('Course290_Main', 0, 2, 2, (177.0, 47.0, 0.0), (179.0, 47.0, 0.0)), + ('Course290_Main', 0, 2, 3, (177.0, 8.0, 0.0), (179.0, 8.0, 0.0)), + ('Course290_Main', 0, 5, 0, (183.0, 42.0, 0.0), (185.0, 42.0, 0.0)), + ('Course290_Main', 0, 5, 1, (183.0, 47.0, 0.0), (185.0, 47.0, 0.0)), +] + + + + +# (flow, event_name, param_name, byte_offset, orig_val, new_val) +# CourseDemo_PreFinalBattle (Course290 intro cutscene): +# Event50 is the final cutscene camera pose before gameplay handoff. +# Raise TargetYpos 27.5 -> 28.75 to match gameplay camera resting height (19.5 + 9.25 = 28.75) +# and hide Bowser Jr. parked at y ~19.5..20.1 behind the bottom letterbox bar (covers up to y 20.20). +EVENT_EDITS = [ + ('CourseDemo_PreFinalBattle', 'Event26', 'TargetYpos', 0x2A80, 27.5, 28.75), + ('CourseDemo_PreFinalBattle', 'Event50', 'TargetYpos', 0x2D90, 27.5, 28.75), +] + + +def bfevfl(romfs, flow): + return os.path.join(romfs, 'Event', 'EventFlow', f'{flow}.bfevfl.zs') + + def bcett(romfs, course): return os.path.join(romfs, 'BancMapUnit', f'{course}.bcett.byml.zs') +def edits_by_flow(): + out = {} + for e in EVENT_EDITS: + out.setdefault(e[0], []).append(e[1:]) + return out + + def edits_by_course(): out = {} for e in EDITS: - out.setdefault(e[0], {'actors': [], 'bg': [], 'gyaml': [], 'rails': []})['actors'].append(e) + out.setdefault(e[0], {'actors': [], 'bg': [], 'belts': [], 'gyaml': [], 'rails': []})['actors'].append(e) for b_edit in BG_EDITS: - out.setdefault(b_edit[0], {'actors': [], 'bg': [], 'gyaml': [], 'rails': []})['bg'].append(b_edit) + out.setdefault(b_edit[0], {'actors': [], 'bg': [], 'belts': [], 'gyaml': [], 'rails': []})['bg'].append(b_edit) + for belt_edit in BELT_EDITS: + out.setdefault(belt_edit[0], {'actors': [], 'bg': [], 'belts': [], 'gyaml': [], 'rails': []})['belts'].append(belt_edit) for g_edit in GYAML_EDITS: - out.setdefault(g_edit[0], {'actors': [], 'bg': [], 'gyaml': [], 'rails': []})['gyaml'].append(g_edit) + out.setdefault(g_edit[0], {'actors': [], 'bg': [], 'belts': [], 'gyaml': [], 'rails': []})['gyaml'].append(g_edit) for r_edit in RAIL_EDITS: - out.setdefault(r_edit[0], {'actors': [], 'bg': [], 'gyaml': [], 'rails': []})['rails'].append(r_edit) + out.setdefault(r_edit[0], {'actors': [], 'bg': [], 'belts': [], 'gyaml': [], 'rails': []})['rails'].append(r_edit) return out @@ -314,6 +492,30 @@ def apply(d, course_edits): for eslot, _ in b.vec3(p, 'Translate'): allowed.update(range(eslot, eslot + 4)) + for course, uidx, bidx, pidx, orig, new in course_edits.get('belts', []): + unit = b.hash_entries(slots[uidx][2]) + belts = b.array_slots(unit['BeltRails'][2]) + belt = b.hash_entries(belts[bidx][2]) + pts = b.array_slots(belt['Points'][2]) + p = b.hash_entries(pts[pidx][2]) + node = p['Translate'][2] + all_bpts = [] + for u in slots: + unit_dict = b.hash_entries(u[2]) + if 'BeltRails' in unit_dict: + for _, _, braw in b.array_slots(unit_dict['BeltRails'][2]): + belt_dict = b.hash_entries(braw) + if 'Points' in belt_dict: + for _, _, praw in b.array_slots(belt_dict['Points'][2]): + all_bpts.append(b.hash_entries(praw)) + sharers = [pt for pt in all_bpts if pt['Translate'][2] == node] + assert len(sharers) == 1, f'{course} Unit {uidx} BeltRail {bidx} Pt {pidx}: Translate shared by {len(sharers)} points' + cur = [v for _, v in b.vec3(p, 'Translate')] + assert cur == list(orig), f'{course} Unit {uidx} BeltRail {bidx} Pt {pidx}: {cur}, expected {orig}' + b.set_vec3(p, 'Translate', new) + for eslot, _ in b.vec3(p, 'Translate'): + allowed.update(range(eslot, eslot + 4)) + rails_slots = b.array_slots(root['Rails'][2]) if 'Rails' in root else [] all_rpts = [] for s in rails_slots: @@ -351,6 +553,18 @@ def build(orig_romfs, out_dir): assert bytes(d) != bytes(read(src)), f'{course}: no change' write(bcett(os.path.join(out_dir, 'romfs'), course), d) print('wrote', bcett(os.path.join(out_dir, 'romfs'), course)) + for flow, edits in edits_by_flow().items(): + dst_event_dir = os.path.join(out_dir, 'romfs', 'Event', 'EventFlow') + os.makedirs(dst_event_dir, exist_ok=True) + src = bfevfl(orig_romfs, flow) + d = read(src) + for ev_name, param, offset, orig_val, new_val in edits: + assert struct.unpack_from(' {new}' for ev, param, _, old, new in edits) + print(f'{flow}: {len(diff)} byte(s) differ, exactly {names}') for p in problems: print('PROBLEM:', p) print(f'{len(problems)} problem(s)') diff --git a/super-mario-bros-wonder/tools/gen_zoom_v2.py b/super-mario-bros-wonder/tools/gen_zoom_v2.py index 07159d9..973448d 100644 --- a/super-mario-bros-wonder/tools/gen_zoom_v2.py +++ b/super-mario-bros-wonder/tools/gen_zoom_v2.py @@ -142,6 +142,26 @@ def emit(base, seq): return base + 4 * len(seq) +def pre_labels(base, items, ldict): + pc = base + for it in items: + if isinstance(it, str): + ldict[it] = pc + else: + pc += 4 + + +def assemble(base, items, ldict=None): + """items: label strings or lambdas pc -> word (labels resolved through ldict, default glab).""" + if ldict is None: + ldict = glab + pre_labels(base, items, ldict) + seq = [it for it in items if not isinstance(it, str)] + return emit(base, seq) + + + + # ------------------------------------------------------------------ cave A A = 0x2138800 N_CODE = 56 @@ -187,7 +207,7 @@ def emit(base, seq): lambda pc: bcond(MI, pc, lab['small']), # 34 lambda pc: ldr_w_lit(15, pc, L_G17), # 35 large world area lambda pc: ldr_w_lit(17, pc, L_D17), # 36 - lambda pc: b_(pc, lab['store']), # 37 + lambda pc: b_(pc, ahlab['entry']), # 37 lambda pc: ldr_w_lit(15, pc, L_G155), # 38 SMALL room (or no area record) lambda pc: ldr_w_lit(17, pc, L_D155), # 39 lambda pc: adrp(16, pc, BSS), # 40 STORE @@ -207,6 +227,45 @@ def emit(base, seq): lambda pc: LDR_X15_POP, # 54 lambda pc: b_(pc, 0x6C66E0), # 55 ] +A_HELPER = 0x2138988 +A_HASH_290 = 2931365200 +G_FIST_290 = 18.5 +X0_FIST_290, X1_FIST_290 = 100.0, 112.0 +ahlab = {} +A_HELPER_ITEMS = [ + 'entry', + lambda pc: adrp(16, pc, BSS), + lambda pc: ldr_w(16, 16, 0xF04), # w16 = current area RootAreaHash + lambda pc: ldr_w_lit(15, pc, ahlab['hash']), # w15 = 2931365200 + lambda pc: cmp_w(16, 15), + lambda pc: ldr_w_lit(15, pc, L_G17), # restore w15 = f32(G_LARGE) (flags preserved) + lambda pc: bcond(NE, pc, lab['store']), # not Course290_Main -> store (15.75, 3.2778) + lambda pc: ldr_s(16, 20, 0x194), # s16 = fixed X (subject+0x194) + lambda pc: ldr_s_lit(31, pc, ahlab['x0']), # s31 = 100.0f + lambda pc: fsub_s(16, 16, 31), # s16 = fixed X - 100.0f + lambda pc: fmov_imm(31, 0x28), # s31 = 12.0f (112.0 - 100.0) + lambda pc: fcmp_s(16, 31), + lambda pc: bcond(GE, pc, lab['store']), # fixed X >= 112.0 -> store (15.75, 3.2778) + lambda pc: fmov_s_w(31, 31), # s31 = 0.0f (wzr) + lambda pc: fmax_s(16, 16, 31), # s16 = max(fixed X - 100.0f, 0.0f) + lambda pc: ldr_s_lit(31, pc, ahlab['slope_g']), # s31 = (15.75 - 18.5) / 12.0 + lambda pc: ldr_s_lit(30, pc, ahlab['g_fist']), # s30 = 18.5f + lambda pc: fmadd_s(16, 16, 31, 30), # s16 = G = 17.5 + slope * t + lambda pc: fmov_w_s(15, 16), # w15 = f32(G) + lambda pc: ldr_s_lit(31, pc, ahlab['neg_2_3']), # s31 = -2.0 / 3.0 + lambda pc: ldr_s_lit(30, pc, ahlab['half_16_9']), # s30 = 27.5556 / 2.0 + lambda pc: fmadd_s(16, 16, 31, 30), # s16 = delta = half_16_9 + neg_2_3 * G + lambda pc: fmov_w_s(17, 16), # w17 = f32(delta) + lambda pc: b_(pc, lab['store']), + 'hash', lambda pc: A_HASH_290, + 'x0', lambda pc: f32(X0_FIST_290), + 'slope_g', lambda pc: f32((G_LARGE - G_FIST_290) / (X1_FIST_290 - X0_FIST_290)), + 'g_fist', lambda pc: f32(G_FIST_290), + 'neg_2_3', lambda pc: f32(-2.0 / 3.0), + 'half_16_9', lambda pc: f32(27.5556 / 2.0), +] +pre_labels(A_HELPER, A_HELPER_ITEMS, ahlab) + assert len(seq_a) == N_CODE, len(seq_a) lab.update({'small': A + 4 * 38, 'loop': A + 4 * 23, 'found': A + 4 * 29, 'notab': A + 4 * 32, 'store': A + 4 * 40}) emit(A, seq_a) @@ -306,22 +365,6 @@ def follow(): # s0 = clamp(focus X - fixed X - delta, -d lambda pc: fneg_s(31, 31), lambda pc: fmax_s(0, 0, 31), lambda pc: fsub_s(0, 0, 31)] -def pre_labels(base, items, ldict): - pc = base - for it in items: - if isinstance(it, str): - ldict[it] = pc - else: - pc += 4 - - -def assemble(base, items, ldict=None): - """items: label strings or lambdas pc -> word (labels resolved through ldict, default glab).""" - if ldict is None: - ldict = glab - pre_labels(base, items, ldict) - seq = [it for it in items if not isinstance(it, str)] - return emit(base, seq) # Cave G helper (0x02138914..0x02138988): when hold counter expires, check autoscroll end stops table. @@ -418,7 +461,10 @@ def assemble(base, items, ldict=None): pre_labels(G_HELPER, G_HELPER_ITEMS, ghlab) pre_labels(G_CAVE, G_ITEMS, glab) G_HELPER_END = assemble(G_HELPER, G_HELPER_ITEMS, ghlab) -assert G_HELPER_END <= 0x2138A00, hex(G_HELPER_END) +assert G_HELPER_END <= A_HELPER, hex(G_HELPER_END) +A_HELPER_END = assemble(A_HELPER, A_HELPER_ITEMS, ahlab) +assert A_HELPER_END <= 0x2138A00, hex(A_HELPER_END) +A_HELPER_DATA = {ahlab['hash'], ahlab['x0'], ahlab['slope_g'], ahlab['g_fist'], ahlab['neg_2_3'], ahlab['half_16_9']} G_END = assemble(G_CAVE, G_ITEMS, glab) assert G_END <= 0x2138B00, hex(G_END) G_DATA = {glab['eps'], glab['stepv']} @@ -520,12 +566,12 @@ def assemble(base, items, ldict=None): seen.add(a) ENDS_DATA = {TABLE_ENDS + 4 * i for i in range(2 * (len(AUTOSCROLL_ENDS) + 1))} G_HELPER_DATA = {ghlab['thresh']} -data_addrs = {L_THR, L_G17, L_D17, L_G155, L_D155, F2 + 20} | {TABLE + 4 * i for i in range(3 * (len(BOSS) + 1))} | ENDS_DATA | G_HELPER_DATA | G_DATA | Y_DATA | K_DATA +data_addrs = {L_THR, L_G17, L_D17, L_G155, L_D155, F2 + 20} | {TABLE + 4 * i for i in range(3 * (len(BOSS) + 1))} | ENDS_DATA | G_HELPER_DATA | A_HELPER_DATA | G_DATA | Y_DATA | K_DATA if __name__ == '__main__': for a, w in allw: dis = list(md.disasm(struct.pack(' 1: - open(sys.argv[1], 'w').write('\n'.join(f"{a:08X} {struct.pack(' A_HELPER (Course290_Main opening fists zoom-out lerp) invariants + assert b_target(0x02138894, patch[0x02138894]) == 0x02138988, "Cave A large room does not branch to A_HELPER" + assert patch[0x021389E4] == 2931365200, f"A_HELPER hash != 2931365200: {patch[0x021389E4]}" + assert patch[0x021389F0] == 0x41940000, f"A_HELPER g_fist != 18.5f (0x41940000): {patch[0x021389F0]:08X}" + assert b_target(0x021389E0, patch[0x021389E0]) == 0x021388A0, "A_HELPER return != 0x021388A0 (Cave A store)" + print(f"\nverify_pchtxt: OK ({len(lines)} patch lines, {len(EXPECTED_HOOKS)} hooks, " f"all invariants verified, 0 errors)")