dwgx@blog:~$dwgx
> cd ../posts

eclmap: Mnemonic Maps for Digging Into Touhou Danmaku Scripts

// created

eclmap is a set of mnemonic symbol maps for the thtk (Touhou Toolkit) toolchain. It’s forked from someone else’s repo, not my own work. I pulled it down to dig into Touhou STG danmaku scripts and poke around a bit along the way.

In Touhou, how enemies move and how bullets get fired is all written in ECL scripts, while the sprite animation side lives in ANM. thtk’s thecl and thanm are the tools that compile/decompile these two formats. The problem is that decompilation spits out a pile of raw instructions, and just staring at instruction numbers tells you nothing about what each one does. What eclmap does is attach readable mnemonic names to those instructions, so the decompiled output comes with semantics baked in, which cuts the editing effort down a lot.

Usage is the same as every other thtk program: pass -m mapfile when compiling or decompiling, where mapfile is the filename of the corresponding table. Note that the ECL maps use the new format, which older thecl versions don’t recognize. The repo currently only has ECL and ANM, since only thecl and thanm actually support this, and neither can be grabbed from a release and used directly: thecl has to be built yourself from a newer branch, and thanm is more of a hassle, requiring a build from the thanm-new-spec-format branch. thecl’s maps go in the eclmap directory, thanm’s in the anmmap directory.

Not every game has ECL: TH08 uses th08.eclm, TH10-TH11 use th11.eclm, the TH12 line uses th12.eclm, and TH13 through TH17 each have their own .eclm. alcostg is untested, but borrowing th11.eclm basically works; TH06-TH07 and TH09 are still empty. The ANM side is very early, the author marked it WIP, and the instruction names can change on a whim, so don’t count on stability: TH06 uses v0.anmm, TH07-TH09 use v2.anmm, TH09.5 through TH12.8 use v4.anmm, and TH13-TH17 use v8.anmm.

I’m keeping it mainly as a lookup table and a base for tinkering. When reverse engineering old game scripts like these, the most draining part was never the tools themselves, it’s translating raw data back into human terms, and a solid mnemonic map takes most of that grunt work off your plate. I’ll fill in the missing games as I run into them.