# 坦克大战 / Battle City browser revival

Based on https://github.com/vgrichina/battlecity (retrieved 2026-10-27).
The upstream README explicitly licenses the reverse-engineering notes, tools and browser reimplementation under MIT.
Upstream authorship: vgrichina/battlecity contributors. Original game, sprites and ROM belong to Namco/Bandai Namco Entertainment. No ROM is included here.

Preserved upstream files: game.js, levels.js, sound.js, chr_all.png, UPSTREAM-README.md, REVERSE.md, dead_ends.md.
Adapted engine is engine.js; additional controls/editor are enhancements.js; build.py embeds everything into ../battle-city.html.

Upstream file blob hashes:
- web/game.js: d27b69e69d7c0e846b817d6bfb505cf98175126b
- web/levels.js: e9c1197a3fb0100e893f3988144c0b2a827d1279
- web/sound.js: 86152d98ed1ee56c49423261aa6bf9f22f3d0f97
- web/tiles/chr_all.png: 55c660c5936c312b2e52d8438e96a6f70abfa029

Verified locally: 48 focused engine checks, including all 35 maps and 1200 deterministic ticks per map; browser start/stage select/pause/2P/editor/load/import/export/custom play.
Not established: frame-for-frame equivalence with an original cartridge; all 35 stages completed by a human; real-device multi-touch/audio and WeChat compatibility. This is an unofficial adaptation of an existing implementation, not a from-scratch claim or a perfect emulator.

2026-10-28: Fixed weapon upgrade loss on campaign stage advancement. Only living players carry star levels across transitions; death respawns and new sessions reset them. Eight regression checks cover one/two/three-star projectile behavior, cooperative levels, death, new sessions, temporary effects, and all 34 transitions.

2026-10-28: Added solid tank-body collision for movement and safe turning, including ice. Enemy spawn sites and player respawns wait for free space. Heavy tanks now have four persistent durability palettes plus hit feedback. Power-up icons render above forest with a pulsing frame, without hiding the icon. Eighteen targeted checks plus visual QA of all four armor palettes and a power-up on dense forest passed.

2026-10-30: Added responsive landscape controls, sliding four-way input, independent multi-contact fire with hold-to-repeat, safe contact release on cancellation, pause, orientation and background changes. Added a self-contained mobile/browser entry at index.html with viewport and safe-area handling plus optional fullscreen. Seventeen input/layout checks and the existing 48 engine checks passed. Layout math covers 568x320 through tablet dimensions. Browser local-file preview was blocked by URL policy; no iOS/Android hardware or real mobile-browser validation has been performed.

2026-10-30: Fixed oversized steel destruction. Armor-piercing bullets now clear only impacted 8x8 quadrants, not the entire 16x16 metatile. Shared steel masks drive projectile collision, tank collision, sprite rendering, shovel fortification, level resets and both keyboard/pointer editor painting. Added 13 regression checks, including four directions at six seam offsets, half-steel variants and rendering/collision agreement. All 61 engine checks and 17 mobile input/layout checks pass. Both ../battle-city.html and index.html rebuilt.

2026-10-30: Fixed immediate tally after killing the final red/power-up tank. Outstanding pickups now grant up to 1200 active 60Hz simulation frames (20 seconds) of playable collection time; collection ends the wait immediately. No outstanding pickup adds no delay. Pause/background pauses the simulation and countdown. Base destruction or exhausted player lives retain game-over precedence. Status shows remaining pickup seconds; new stages reset the timer. Reproduced the old failure before patching. All 70 engine checks and 20 touch/layout checks pass, including collecting a final star then carrying its upgrade into the next stage. Both outputs rebuilt.

2026-10-30: Fixed missing player death audio by triggering the existing explosion/noise sequences on the player branch of killEntity. Shield interception uses impact audio, cooperative friendly-fire stun uses armor-impact audio. Muting, repeated-death protection and silent respawn are preserved. Nine new regression checks include both players, the final life and nonzero noise-channel sequencer output alongside engine sound. All 79 engine checks and 20 mobile checks pass; this verifies audio event/sequence logic, not hardware listening. Both browser outputs rebuilt.

2026-10-30: Fixed custom-map Space cycling. Physical Space/X/B now dispatch edge-triggered editor commands, so even taps between simulation frames work. Space cycles forward and paints the current cell; X/B cycles backwards; Z places without cycling. A shared placement path updates brick/steel masks, mirrored cells, undo history, save/export data and brush UI. Map pointer input releases lingering form focus. Added next-terrain button and immediate one-cycle touch actions. Thirteen new editor regression checks pass; existing 79 engine checks and all 33 touch/editor/layout checks pass. Both outputs rebuilt.

2026-10-30: Fixed red-carrier pickup replacement. The first player-bullet hit releases a freshly rolled pickup even if another is present, including nonfatal armored hits. The carrier flag is consumed immediately to avoid duplicate drops on later hits or destruction. Direct destruction retains the same replacement behavior. Reproduced the outstanding-pickup failure before fixing it. Seven new regression checks cover replacement, armored first-hit timing, consecutive carriers and both players, normal enemies, empty fields, grenade destruction, appearance audio and refreshed rendering. All 86 engine checks, 33 mobile/editor/layout checks and bundle syntax validation pass. Both outputs rebuilt.
