Files
siegeandClaude Opus 5.5 1e0af589c3 Seesaw animates like the original: kids, seesaw launch and sliding rows on a timed run
Measured in Mesen (re/runs/anim/s0B, s0B_p2; notes in anim_battle.md): the victims' fields rise 2 at
rel 175 when kid B lands on the seesaw, kid A kicks the caster's bottom 2 rows off at 236, they slide
across 237-293, the caster's field drops at 277 and the rows fill the victims' gap at 293. Match runs
these steps (Match::seesaw / tick_seesaw, compact: from when play resumes), same end board as before
(test_seesaw_moves_over_time). ArtRenderer::draw_seesaw draws the original poses and paths, mirrored
for a victim on the left, with the white fades. The 0B effect sheet now covers all three uploads and
uses palette row 12. anim_cap.lua: TBG_CASTER=2 and per-frame boards.bin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 00:14:17 -05:00

18 KiB
Raw Permalink Blame History

TBG (J) — battle-screen animations (power effects, battle-wide effects)

Goal: let the C++ renderer reproduce the original's battle animations from the user's ROM. [C] = measured in Mesen captures (per-frame OAM/CGRAM/tilemaps/HDMA lines/PPU register writes), [I] = inferred / visual only. Frame numbers are relative to the Up press of the cast (rel), from the re/runs/battle_mid state (P1 Halloween casts, P2 = Mirurun COM; the caster is the left board, the victim the right one).

Tooling

file what
re/lua/anim_cap.lua from a savestate, P1 casts TBG_POWER (or none); every frame records OAM, CGRAM, BG1 + BG2 tilemaps (frames.bin), the per-scanline output of every enabled HDMA channel (hdma.bin), WRAM 7E:3000-3FFF (wram3.bin), game state + the PCs that wrote the OAM shadow (state.txt); logs VRAM/CGRAM DMAs, HDMA setups and PPU register writes (events.txt); screenshots every 4 frames, full VRAM at TBG_VRAMAT
re/lua/anim_probe.lua DMA/HDMA channel dump for a few frames (found the shadows below)
re/tools/anim_run.py parallel runner (--batch re/runs/anim/batch.txt = all 41 powers + base); outputs re/runs/anim/<name>/
re/tools/anim_analyze.py CAPDIR per-frame decode → phase timeline: windows (circle fit / rect / full), colour math, BG3, mosaic, effect sprites (OAM name table 2), BG1 playfield tiles > 6, changed CGRAM rows; VRAM uploads attributed to ROM
re/tools/anim_summary.py raw per-power differences vs the baseline (OAM-writer PCs, HDMA, registers)
re/tools/anim_extract.py ROM OUT ROM-only renders of every effect sheet + READY/GO letters, palettes located in ROM
re/tools/anim_validate.py checks the parametric models (Bomb circle/tint) against the captured per-line data
re/tools/anim_montage.py OUT 20-frame contact sheets of each power's active phase (re/runs/anim/montage/m00..m20.png)
outputs re/runs/anim/digest.txt (all timelines), summary.txt, montage/

Shadows [C]: OAM shadow 7E:29F1 (0x220 B, DMA ch0 at 81:97A6 every NMI), CGRAM shadow 7E:2C11 (0x200 B, DMA at 81:977B). PPU registers are copied from shadows in the NMI (81:C1CC..81:C250). HDMA is used only by effects: windows on ch6 ($2126/27, W1) and ch7 ($2128/29, W2), table 7E:3632 / 7E:3639 (indirect, mode 1 = L/R pairs); a few effects also HDMA BG3 scroll ($2111) and the fixed colour ($2132).

1. The common cast sequence (all powers) [C]

rel what
0 Up pressed; caster's piece removed (state 13)
42 name-box/meter strip refreshed (VRAM 78A2); 44: BG3 tilemap 6C00 cleared
55-57 cut-in sheet uploaded to OBJ name table 2 (words 1000/1600/1C00) — see graphics_cutins.md
59 OBSEL $2101 = $00 (8×8 / 16×16 sprites) for the whole cast; restored to $20 at the end
60 cut-in palette → CGRAM row 11
62-100 cut-in (per-character metasprite SEQ, base (48,64) over the caster's board)
≈101 effect sprite tiles uploaded to OBJ word 1000 (name table 2) from the battle-setup WRAM copies — 7F:0000+ = decompress(93:8000), 7F:8000+ = decompress(9A:C413) (see per-power table)
≈101 → end the effect (below); at its end OBSEL back to $20, windows/colour math off, the board strip refreshed (7B44)

Effect sprites always use OBJ name table 2, priority 3, mostly palette 3 (CGRAM row 11) = the effect's palette (loaded over the cut-in palette) or palette 4 (row 12). Sprite sizes 8×8 / 16×16 (OBSEL 0).

2. Rendering primitives (what a renderer needs)

Every effect is a combination of:

  1. Sprites — tiles from the effect sheet (ROM source per power), positions driven by per-effect code (tables in bank 86/81/82 + RNG). Capture frames.bin has every frame's OAM.
  2. Window shapes (HDMA, per scanline L/R) — e.g. Bomb's growing circle, rectangles = a board's field (x 32-111 / 144-223, y 23-198) or a whole board column. anim_analyze.py fits circles (centre, radius).
  3. Colour math — $2131 add/sub (± half) on selected layers, with either the fixed colour ($2132, a tint that is animated per frame: fades, flashes) or the sub-screen (BG3 overlay blended over BG1/BG2), limited by the window ($2125 colour window, $2130 region). Equivalent overlay: rgb = clamp(rgb ± tint) inside / outside the window shape; half = average.
  4. BG3 overlays — a code-built tilemap (WRAM 7F:E000) uploaded to BG3 map word 6800, BG3 enabled on main or sub screen ($212C/$212D bit 2), scrolled ($2111/$2112), often blended by colour math.
  5. Palette effects — CGRAM rows rewritten per frame (cells glow, petrify grey, fades of rows 0-7).
  6. Board tiles — BG1 playfield entries switched to animation tiles (break frames 07-0C, star impact 70-75, petrify 6B-6E…) before the game-state change.
  7. Mosaic ($2106) and brightness ($2100).

3. Per power (ids = PowerId; times = rel frames; "victim" = right board)

Suspension totals (cast → victim resumes) are in powers_detail.md. Uploads: 93: = decompress(93:8000)+off, 9A: = decompress(9A:C413)+off, both → OBJ word 1000.

id power effect animation [C unless noted]
00 Mirurun f103-226: pink cloud/flower sprites (20 × 16×16, tiles 00-06, pal 3, upload 93:0000 0x400) sweep along the caster's bottom rows as they are removed
01 Copy f159-270: a horizontal light bar (sprites 0C-0E/1C-1E, upload 93:0800) scans down the victim field, field tinted (W1 = victim column, fixed-colour add (2,9,2)); f271-426: caster field window, BG3 overlay (map from 7F:E000, BG3 scroll HDMA) shows the victim's stack as grey/black copy dropping in, sub-screen blend; caster field becomes the copy
02 Medusa f152-196: Medusa head sprite (20 sprites, pal 4, upload 9A:1600 0x600) + screen white flash (fixed add 31→9 on BG1); f240-388: victim field window, half-add sub-screen (BG3 scroll HDMA), victim cells turn to petrify tiles 6B→6E (f353-384) then stone; f389-420 white fade back
03 Bomb f140 tiles 9A:1C00 (0x800); f145-209: circle window centred (184,64) on the victim, radius 16 → full screen (+8 px / 3 frames), colour math add (fixed (1,1,0) → (21,5,0) orange) on all layers inside it, other CGRAM rows darkened; f229-364: explosions = 32×32 (2×2 of 16×16, tiles 00/02/20/22… pal 3) at RNG positions on the victim field, flickering between (21,5,0) and (18,11,0); cells break 07→0C (f267-342); f365-388 tint fades to 0
04 Mayakashi mosaic on BG1 from size 15 to 1 in steps of 1 every 2 frames (f102-131, `$2106 = size<<4
05 Pentris f103-345: a small pink critter (5 sprites, pal 4, upload 93:0400 0x800) pushes 5 garbage rows in under the victim at x 112-136 (centre column), half-add sub-screen f283-345
06 Dainashi a spider web is drawn over the victim field for the whole power (BG3/sprites [I: web from BG3 map])
07 Fly caster's bottom 3 rows glow (CGRAM fade to white, cells become flash tiles), the rest of the screen dims, then everything fades back (f≈105-239)
08 Noroi whole screen darkens; victim field becomes a purple patterned BG3 overlay with a reaper/scythe sprite swooping (f≈110-300); then the victim field stays dark for the power's duration
09 Vampire screen tinted lilac with a BG3 fog overlay; bats (blue sprites) fly from the caster's meter to the victim and back (f≈150-470)
0A Clear the caster's cells fly up as sprites; the screen fades to white (fixed colour add → 31) and back (f≈110-528)
0B Seesaw kid A kicks the caster's bottom 2 rows across to the victim; kid B jumps on a seesaw that lifts the victim field 2 (f105-341, exact timeline below)
0E Cut scissors sprite flies across the caster's stack top; the cut rows break apart (f≈110-248)
0F Moses screen tinted dark blue; caster cells glow cyan (palette) and part to the sides (f≈110-265)
10 Mambo a dancing sombrero character in the centre column; victim cells shake (f≈110-753)
11 Stardust f101 tiles 93:6E00 (0x200); f109 BG3 starfield (map 7F:E000) on main + sub, colour math add sub-screen; f113-495 star sprites (tile 0A, pal 4) fall onto the caster's columns; each impact shows BG1 tiles 70-75 on the struck row before it is deleted
12 Reverse victim cells recoloured lilac (CGRAM row 2) for the power's duration
13 Mahi victim cells recoloured grey/lilac (row 2) for the duration; rotation attempts shake the piece
14 Kaiten victim cells drawn with a swirl pattern (tiles) for the duration
15 Yose screen tinted green; caster cells glow cyan and slide left (f≈110-303)
16 Gang gangsters (sprites) walk across the victim's bottom picking the crystal cells (f≈110-559)
17 Doton caster cells brightened (palette) for the duration
18 Press two green press hands come down onto the caster's field (f≈110-323)
19 Sol crosshair sprite targets the caster's columns 4-6, then a light beam column (colour math add in a rect window) burns them (f≈110-524)
1A Suritote full-screen BG3 space overlay with flying colourful sprites; victim cells switch to dotted tiles while they invert (f≈110-360)
1B Fax caster field goes black, then a grey BG3 "paper" scans the stack out; then the same printed into the victim field (f≈110-557)
1C Shield caster field tinted blue (window + colour math) with lightning sprites crossing it; persistent tint while active
1D Mirror nothing (silent)
1E Heavy nothing visible beyond the cut-in (unused power)
1F Select caster cells pale (palette) with small arrow sprites while active
20 Nu a gnu sprite in the centre column while active
21 Remocon a giant SNES pad sprite descends on the victim field (purple-tinted BG2), stays while active
22 Hanten the battle frame is decorated (BG1 border tiles + banner "大回転中" sprite); victim and caster cells change tiles
23 Nakayoshi both boards' blocks drop as coloured columns (BG3 bars) and the boards are cleared/refilled (f≈110-900)
24 Inori prayer animation on the caster's field (psychedelic BG3 overlay), then the rolled power's own animation
25 Roulette roulette overlay (BG3) on the victim field showing the shuffled buttons
26 Fever victim (or both) field gets a bright BG3 pattern (pink/cyan) for the duration; palette cycling
27 Change the two fields are drawn black, a spotlight cone sprite moves over them as they swap
28 Doubles caster bottom rows glow; persistent mark while active
29 Dark victim field blacked out (window + colour math sub to black) except a light cone sprite under the piece
2A HyperFly like Fly with 4 rows and a stronger glow

(Rows marked f≈ are from the contact sheets only; the exact per-frame data is in re/runs/anim/<pXX>/ and digest.txt — run anim_analyze.py on the capture for the timeline.)

Seesaw (0B) in detail [C]

Captures re/runs/anim/s0B (P1 casts; distinctive 220-byte boards caster.bin / victim.bin in that folder) and re/runs/anim/s0B_p2 (P2 casts: TBG_CASTER=2 TBG_POKE=DE=0, same timeline 26 frames later), with anim_cap.lua (now also writes boards.bin, both logic playfields per frame); older re/runs/anim/p0B, re/runs/pw2_all_0B agree. Sprites (OBJ name table 2, palette 4 = CGRAM row 12, 32x32): VRAM 1000/1400/1800 <- 93:8000+1400/+1C00/+2400 (uploads rel 101-103), i.e. one 128x96 sheet from +1400: row 0 = kid A (pink hat, 4 poses at x 0/32/64/96), row 1 = kid B (green hat), row 2 = seesaw (x 0 tilted, low end left; x 32 flat). The sliding rows are 20 8x8 OBJ (name table 0 cell tiles, palette 3 = the caster's cells) in OAM 0-19.

Positions in original px relative to the field's top-left (field = 80x176 at screen y 24; screen y = OAM y + 1); P1 casting = victim on the right. P2 casting mirrors everything about x 128 (all sprites h-flipped, x' = 224 - x).

sprite where (victim right)
kid A caster field x -26, y 149 (overlaps the field's outer edge by 6 px; bottom 5 px below the field)
kid B victim field x +80, y 149; after the launch y 144
seesaw victim field x +72, y 157 (tilted, low end towards the field); flat pose y 165
rows caster's bottom 2 rows (y 160/168) sliding right 2 px/frame to the victim's bottom
rel kid A (caster) kid B / seesaw (victim) board (logic; screen 1 frame later)
105-136 pose 0 pose 0, seesaw tilted kids fade in from white: OBJ colour add, fixed colour 31 -> 0, 1/frame (palettes 4-7 only)
149 pose 1
166-167 pose 2 (crouch)
167-177 jump, pose 1: y offset 0,-4,...,-20 (172),...,0 (4 px/frame)
175 victims' fields rise 2 (2 empty rows at the bottom)
176-177 seesaw flat (y +8), kid lands on it
178- pose 3 on the raised end (y -5), seesaw tilted the other way (h-flip)
199 / 209 / 225 pose 2 / 1 / 2 (wind-up)
230-236 pose 3 (kick)
236 pose 0 again from 237 caster's bottom 2 rows emptied in place (sprites take them from 237)
237-293 rows slide x 32 -> 144 (2 px/frame)
277 caster's field drops 2
293 rows written into the victims' empty bottom 2 (sprites stay over them until 341)
310-341 kids fade out to white (fixed colour 0 -> 31)
342 all Seesaw sprites gone caster's state machine resumes (P1 0F at 342); the victim's at 369

Note: powers_detail.md's suspension 269 is counted from rel 100 (both players' states go 00 there): cast -> victim resumes is 369 here, as for every power checked (Copy 486 -> 586, Stardust 407 -> 507). Our PowerDef::suspend uses the 269, so in original cast mode play resumes before 277/293 (Match::tick_seesaw keeps running then, like the timed Stardust).

4. Battle-wide animations

  • Line clear [C, M2]: full rows show the break tiles 12→7 (BG1) while flashing (states 0B/0E, 14 frames).
  • Queue animation (states 01-04) [C, capture garb]: during 01 the three preview minis (16×8, name table 1, palette 0, x 120/128) scroll up 3 px/frame (y 30→15 …); then the dealt piece's mini slides 1 px/frame for 16 frames into the entry window (P1 x 80→64, P2 x 160→176, y 9), then the piece spawns.
  • Garbage [C, capture garb, P1 stock poked to 3]: the attack stock is the centre column of orb sprites (tile A8, palette 2, priority 3, x 129, y 116 + 8k). At the victim's state 00 each pending row costs one orb: 0F for 7 frames (rise), 10 for 1 (row inserted, 81:D48E), 0E, 00 — no flying sprite; the orb just vanishes.
  • K.O. / round end [C, capture ko: P1 tops out at rel 748]: the loser's board freezes (state 0A); the winner's round-win mark (character head icon) pops out of the winner's board top and flies into the centre column (win counter $484 +1 at ≈+9 frames); both boards hold; the winner shows FE for 2 frames, the boards and queue box are cleared, then both players run state 03 for 213 frames:
    • READY (rel +2 … +150): five 16×16 letters (each 2×2 OBJ tiles, name table 1: R=D0/D1/E0/E1, E=D2, A=D4, D=D6, Y=D8; palette 7 = CGRAM row 15, priority 3) start stacked at (120,49), spread to x 88/104/120/136/152 (≈ +35 frames), do one vertical wave (±14 px, ≈ +50), then hold;
    • GO (≈ +150 … +205): two letters at x 112 / 136, y 49 (tiles DA, DD + the row below);
    • then the queue box comes back and the first pieces deal (04 → 05). In this capture the loser stayed in 0A for 779 frames (rel 749-1528), longer than the 181 in timing.md (that figure was measured with a human-style loss; here the COM winner kept playing its piece out) [I].
  • Big clear, danger, round-win mark, pause-screen moods, stock orbs, preview minis: see anim_battle_extra.md (the K.O. bullet's "head icon" is a smiley ball that lands in the centre column; orb tile A8 = empty slot, A0 = lit).

5. Validation [C]

  • re/tools/anim_extract.py ROM OUT renders every effect sheet from ROM data alone with its palette found in the ROM (all effect palettes are raw rows in bank $85, 85:D227-85:D627, 32 B each; 85:D627 = the caster's cut-in palette, so those effects draw with row 12) and the READY/GO letters (OBJ 9F:8000, palette 85:EC27 row 15): re/runs/anim/extract/ + assets.txt (per-power ROM addresses).
  • re/tools/anim_validate.py: Bomb W1 = circle (184,64), r = 16 + 8·⌊(rel−146)/3⌋ matches the captured HDMA lines within 1-2 px on 14/22 frames; the other 8 are the frames where the game is rebuilding the table (every third frame shows a half-written table — a renderer should use the model). Tint: R 1→21 over rel 145-201, G 1→5 over 145-159, B 0.
  • Visual: contact sheets re/runs/anim/montage/ (all powers), re/runs/anim/ko/sheet.png (round end + READY/GO).

Open questions

  • Exact per-sprite motion code for each effect (positions are in the captures frame by frame; the generating routines are the per-power OAM writers listed by anim_summary.py, e.g. Bomb 86:B88C-86:B9F7, explosion metasprite table 86:BA38 (8 bytes per frame: 4 tile/attr words for the 2×2), lifetime table 86:B9F8).
  • (big clear, danger, moods, win mark: done in anim_battle_extra.md) The BG3 overlay tilemaps are built in WRAM 7F:E000 by code (capture v*.vram dumps hold the result; the builders are not mapped).

6. C++ loader spec (minimal)

  1. Effect sheet: decompress(93:8000) and decompress(9A:C413) once per battle; per power take the slice in the table above (4bpp, 32 B/tile, name = index within the slice, uploaded at name-table-2 tile 0).
  2. Palettes: row 11 / row 12 contents at effect time (search the ROM for the 32-byte row: they are raw BGR555).
  3. Drive frames from rel = frames since the cast with the timelines above; implement primitives §2 as overlays: circle/rect windows → masks; colour math → additive/subtractive tint inside/outside the mask; BG3 overlays → textured quad blended over the field; mosaic → pixelate the board layer.