The effect modules as a family
Nothing in the game’s main program knows what an attack looks like. Every attack, spell and hit flash is a small program of its own, an effect module, loaded from the disc when a battle needs it. Decompiling all 233 of them showed how they were made: from one shared library of effect parts, by copying.
- Where
- effect/B_MODULE.MRG (183 slots) and effect/Z_MODULE.MRG (50 modules in 311 slots)
- Functions in all modules
- 3,997 (4.17 MB of code)
- Different function bodies
- About 1,530; the rest are copies
- Code shared between modules
- None; every module carries its own copies
- Which module plays
- Basic attack b
for monster n; special attacks and skill cards name a z module - Start argument
- Only two modules use it, and only to choose colours
Which module plays
- For basic attacks,
B_MODULE.MRGhas one slot per monster number up to 182: monster n always plays moduleb<n>. The game has no table for this; the number is the link. Three of those slots belong to monsters that never fight and are used by the God summon cut-scenes instead (the God summon effects). - For special attacks and skill cards, each monster and skill-card record names a module in
Z_MODULE.MRG(a 12-bit slot number, or “none”). 67 of the 187 monster records and 42 of the 61 skill cards name one. All 50 modules on the disc are used; one card, Electro-Whip, names slot 306, which holds no module. Many modules are shared:z261, a support aura, serves 9 monsters and 13 cards;z270covers binding and status spells;z273healing and revival. - While an effect module runs, the battle does not advance; it continues once the module reports that it is done.
The start argument
Each record that names a z module also carries a small number, the start argument, passed to the module when it starts. Only two modules are ever given anything but 0, and in both it only picks colours; size, timing and shape stay the same:
| Module | Argument | Colour |
|---|---|---|
z261, support aura |
0 | orange-red |
| 1 | yellow (Moisture Creature, Mirror Force, Super Rejuvenation and others) | |
| 2 | green (Tao the Chanter) | |
| 3 | violet (Pumpking, Dark Energy, Violet Crystal, Chaos Blaze) | |
z273, healing aura |
0 | blue (Fairy’s Gift, Blue Medicine, Dian Keto and others) |
| 1 | yellow (Magician of Faith, Monster Reborn) | |
| 2 | red (Dragon Piper, Red Medicine, Goblin’s Secret Remedy) |
z261 also has a slip in this choice: Tao the Chanter’s green aura gets the violet sparkles (slips in the attack effects).
Built from a library, by copying
The modules do not call each other, and the only code they share at run time is the main program’s: about 120 of its functions (drawing, maths, camera, random numbers). Everything else is inside each module, so a part that appears in fifty effects exists fifty times on the disc.
Comparing every function of every module, with addresses ignored, leaves about 1,530 different bodies among the 3,997 functions. They fall into families: a funnel shared by Blue-Eyes White Dragon’s attack and its relatives, a swirl, rings of motes, bursts, ribbons, lightning bolts and many more, each a set of start, step and draw functions that modules include with small changes of size, count or colour.
The data shows how the source files were put together:
- 157 modules begin their constant data with the same block, and 75 others with a second one; both blocks belong to library functions that the linker removed. The 157 modules of the first family also share a colour and two vectors that no code reads, just before the constants of their entry function: three initialised local variables at the top of that function that the code never uses. The compiler keeps their starting values even so.
- Many modules contain constants of a “start” function that is not in the module: the library’s default version of a part, compiled and then removed by the linker because the module defines its own tuned version after its entry points. The project’s source keeps small stand-ins for these leftovers so the data comes out the same.
- Some mistakes spread from module to module with the copied code, and some copies were not fully adapted to their new pools; see slips in the attack effects.
Evidence
Each module was sliced from its slot and rebuilt with the same compiler; a module counts as matched only when the rebuilt file is identical to the one on the disc. The families were found by grouping identical function bodies across modules, and the start-argument colours by reading the two auras’ start functions and every monster and card record that names them.