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
2026-10-21 17:34:54 -05:00
2026-10-21 02:49:35 -05:00

Tetris Battle Gaiden — reimplementation

A clean reimplementation of BPS's 1993 Super Famicom game Tetris Battle Gaiden in C++20 + SDL3 for Linux, reverse-engineered from the original ROM. The original game is reproduced rule-for-rule (piece cycle and timings, the contested shared queue, crystals and the power meter, all 43 powers, the original CPU opponent), and extended: 2–4 player battles, mod files for new characters, powers and rules, replays.

No game data is included :). The original graphics, music, sound effects and CPU AI are loaded at runtime from your own copy of the Japanese ROM (the music is played by the game's own sound driver on an emulated SPC700); without it the game runs silent, with flat-colour graphics and a simpler CPU.

Build

Needs CMake ≥ 3.25, Ninja, a C++20 compiler and SDL3 (sudo pacman -S --needed cmake ninja sdl3). cmake --install build --prefix ~/.local installs tbg plus the docs.

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/tbg_tests            # rule tests (TBG_ROM=path/to/rom also runs the original-CPU tests)
TBG_ROM=rom/tbg_jp.sfc ./build/tbg_audio_tests   # sound engine tests

Run

./build/tbg --rom ~/roms/tbg.sfc         # first run: point at your ROM (remembered afterwards)
./build/tbg                              # full game
./build/tbg Halloween Mirurun cpu2       # quick battle vs the CPU (difficulty 0-3)
./build/tbg Shaman Bit Ninja Queen cpu3  # quick 4-player battle (seats 2-4 CPU)
./build/tbg --replay FILE                # watch a recorded match
./build/tbg --assets DIR                 # art override folder (remembered; --assets "" clears it)
./build/tbg --menu-rom PATH              # English-patched ROM for the original menus (remembered)

--assets DIR takes PNGs from DIR (or DIR/gfx) before the ROM: the output of ./build/tbg_extract ROM DIR reproduces the ROM art exactly and works with no ROM at all; replacement art uses the same file names (list in src/gfx/asset_source.hpp). Menus, sound and the original CPU still need the ROM.

English menus: the original screens run from the English fan translation when it is found (--menu-rom, ./rom/tbg_en.sfc, or a file with "English" in its name next to the main ROM); everything else still comes from the Japanese ROM. Options > Menu language switches between the two.

The ROM is looked for at the remembered --rom path, ./rom/tbg_jp.sfc, then ~/.local/share/tbg/tbg/tbg_jp.sfc. It must be the unmodified Japanese release (Tetris Battle Gaiden (Japan).sfc, 1 MiB, SHA-1 e455607b32b0adf14bf4af917cbf6561eccd1d0d).

Modes

  • 1P Battle — Battle World: beat the other characters in order, then Dragon and the Queen. Losing offers a continue.
  • VS Battle — 2–4 players; each seat is a human or a CPU (Options). Seats 3–4 use gamepads 3–4. The VS setup also picks the ruleset: Classic (the original, exact) or Modern (Tetris Guideline handling: SRS rotation with wall kicks, ghost piece, hard drop on Up, 30-frame lock delay with 15 move resets, 7-bag, hold on R, cast on L). Hold and Garbage (TBG: 1 line = 1 row, or the Guideline attack table with T-spins, combos, back-to-back, perfect clears and cancelling) can be set for either ruleset; "Auto" follows the ruleset. DAS / ARR / soft-drop speed for Modern are in Options. Powers and characters work in both. CPU difficulty per seat: 0 Beginner, 1 Casual, 2 Strong, 3 Max (Classic seats use the original CPU at the ROM's levels 0–3; Modern seats use a guideline-aware CPU). 1P Battle World is always Classic. In Modern, a cast pressed while someone's lines are flashing goes off when the flash ends (the original ignores it). With the Mirrored queue (a queue per player) casting still uses up your own piece but leaves your opponents' falling pieces alone.
  • Menus: the game boots into its own menus; Esc swaps to the original game's menus and back (Options: "Boot original menus" starts there instead).
  • Original menus, VS: "2 PLAYER BATTLE" on the original title uses the original's own select. Dragon and the Queen are its hidden picks: hold L (Dragon) or R (Queen) after confirming until the battle starts (the page shows the boss while you hold it). With seats 3–4 set in VS setup (Esc from the original screens), the same menu opens a 3–4 player select drawn in the original's book instead, bosses included; VS setup's START uses it too.
  • Power casts (Options / VS setup): Compact (default) shows a small cut-in over the caster's own board, pauses play for only half a second and plays the power's animation over the running game on the boards involved; Original is the full-screen cut-in with the original's long pause.
  • Watch last replay — every battle is saved; see Files below.
  • Idle on the title for 30 seconds for a demo.

Controls

P1 keyboard P2 keyboard Gamepad (SNES layout) Classic Modern
move A / D ← / → D-pad move move (DAS/ARR)
soft drop S ↓ D-pad down soft drop soft drop (x20 gravity)
Up W ↑ D-pad up cast power hard drop
rotate (A / B) F / G . / , right / bottom face button rotate rotate (SRS kicks)
L Q [ left shoulder Select power: next piece cast power
R E ] right shoulder Select power: previous piece; hold (if on) hold
X / Y C / Z / / ; top / left face button only under Hanten/Roulette Select power
hard drop (extension, off by default in Classic) Space Right Ctrl — hard drop hard drop
pause P Start
fullscreen F11

Menus: move with the same keys, confirm with Enter / A, back with Esc / B. Keys can be rebound in the settings file.

How the battle works (the original rules)

  • Both players draw from one shared queue: whoever locks first takes the next piece.
  • Every 5th piece carries a crystal. Clearing a row with crystals fills your meter.
  • Press Up to cast the highest power level your meter affords (levels cost 1/2/3/4 crystals); the meter empties.
  • Each line you clear sends one garbage row to your opponent at the start of their next piece.
  • A round is lost when a piece locks without clearing and leaves a block in the top hidden row. Best of 3.

Mods

Mod files are TOML files: [rules] (rounds, crystal interval, power costs, queue and randomizer, 4-player targeting), [[power]] (retune any power or make new variants of the 43 effects), and [[character]] (powers, colour, boss flag, which original sprites/stage to borrow). Put them in mods/ next to where you run tbg, or pass --mod FILE. Format: data/README.md; example: data/mods/example.toml.

Files

Settings, key bindings and replays live in SDL's per-user data directory, normally ~/.local/share/tbg/tbg/: settings.txt (safe to edit) and replays/ (last.tbgr plus a timestamped copy of every battle).

Project layout

  • src/core/ — the game rules, no SDL/IO: board, pieces, queue, player, match, powers, characters/mods, 1P campaign, replays, the CPUs (rom_ai.* is a literal port of the original AI over a model of its memory).
  • src/gfx/ — ROM graphics decoder (decompressor, tiles, palettes, stage art, cut-in animations, portraits).
  • src/audio/ — the game's sound code run in a small 65816 interpreter, feeding blargg's snes_spc (external/snes_spc, LGPL-2.1, built as a separate shared library).
  • src/app/ — SDL3 front end: scenes, rendering (original art or flat), input, settings.
  • re/ — the reverse-engineering notes and tools this is built from (re/NOTES.md is the index).
  • tools/ — ai_validate (replays captured real-game AI decisions through the port), snd_validate (sound op lists vs the Python reference), gfx_dump.
S
Description
No description provided
Readme
2.6 MiB
Languages
Assembly 45.3%
C++ 37.9%
Python 11%
Lua 4.9%
Java 0.6%
Other 0.3%