Falsebound Archive
5 Bugs & quirks 5.6

A stale counter after every battle

When a battle ends, the game returns to the map, and the map’s start-up code runs again in a “back from battle” mode. In that mode it means to copy each of your units’ movement kind and speed class back into the map’s unit table, g_map_units[i][k].

Where
main.dol, map scene start (map_enter), return from battle
Wrong index used
Yes, a counter left at 39
Where the writes land
In the skill cards’ sound cue table, 0x3CF00 bytes past the start of the unit table
Visible
Only through one card’s sound, with six or more of your units on the map

For i it uses the counter of a loop a few lines earlier, which sets the size of the map’s models 0x14 to 0x26 and has stopped at 39 (0x27). The table has three rows of eight units, 0x1900 bytes a row, so row 39 lies far past its end: the two bytes per unit land 0x3CF00 bytes and more beyond the start of the table, inside the table of sound cues, the lists that say which sound a monster’s animation or a skill card’s effect plays at which frame.

For your first five units the stray bytes fall into unused parts of the cue lists, past their end markers, where nothing reads them. Your sixth unit’s two bytes land on the start of skill card 33’s list (Dian Keto the Cure Master): the first cue’s sound becomes 0x9000 plus the unit’s movement kind, one of the common menu sounds, instead of the card’s own sound 0x903F, and the second cue’s frame can move out of reach. The card cues are loaded once when the game starts and never again, so after the first battle on a map where you field six or more units, Dian Keto’s effect plays a different sound until the console is reset. The seventh and eighth units again hit unused cue entries.

The units’ real entries are not updated, so they keep the movement kind and speed class they had before the battle.

Evidence

The decompiled map start matches the original machine code exactly. The original computes the row address as i × 0x1900 from register r20 (mulli r0, r20, 0x1900), and the last value written to r20 before that point is the end of the model-scaling loop, 0x27. The unit table is at 0x80190DA8, so the writes start at 0x801CDCA8 + 0x1B, inside the sound cue table at 0x801C1060, one 0x100-byte list per monster and per skill card. The cue lists themselves were read from sd_intr/SECTL.MRG. The effect on Dian Keto’s sound is worked out from the code and data; it has not been checked by ear.