Skip to content

Battle records

Two overlays share work tables in fixed RAM. emi/battle/battle/03 (0x801D0C00) holds the mode machines, the damage rules and the effect scheduler; emi/battle/battle/15 (0x80096800) holds the entrance, the panels and the drawing. This page maps the work rows, the state words and the handler tables. Static enemy, encounter and ability tables are in game records; the order of a battle is in battle flow. Terms are in the glossary.

A bare func_XXXXXXXX in an evidence cell lives in emi/battle/battle/03 at 0x801D0C00 or above, in emi/battle/battle/15 in 0x80096800-0x800BFFFF, and in emi/etc/game/00 for 0x801C6AEC and 0x801C6BB4.

One mode byte selects a mode machine. Each mode owns a step table, and a step advances itself and may call the sub-step dispatcher. Effects run on a second track: a queued action slot’s mode selects a stage, and its handler index selects the function. Every mode and entrance row is a function pointer with no arguments and no result (dispatch tables).

Addresses are fixed RAM. The mode, step and sub-step are three adjacent bytes.

Object Address Size Count Readers
mode byte 0x801462E0 1 1 Battle_DispatchMode (emi/battle/battle/03@0x801D112C)
main step 0x801462E1 1 1 the mode’s step tables
sub-step 0x801462E2 1 1 Battle_DispatchEntrance (emi/battle/battle/03@0x801D17C4)
state word g_BattleState 0x801462E8 2 1 both overlays, boss and bmagic handlers
acting battler 0x80146374 1 1 both overlays
command state 0x80146375 1 1 func_801DD448, func_801E020C
target selector 0x80146384 1 1 both hit endings (func_800A9820 takes it as an argument)
result byte 0x80146328 1 1 func_801D43EC, boss endings
battle outcome 0x80146324 64 1 Battle_RollEnemyDrops, Battle_DefeatEnemy
candidate entries 0x801463DC 12 8 emi/etc/game/00, emi/battle/battle/15
player work rows 0x80145E90 320 3 both overlays
enemy work rows 0x801EB630 280 8 both overlays
queued action slots 0x801EC330 120 48 Battle_UpdateEffects (emi/battle/battle/03@0x801E5824)
panel tasks 0x80148330 36 22 func_801E9074, func_801EA1E0, func_801DA69C
event slots 0x801EB4F0 12 - Battle_UpdateEvents (emi/battle/battle/03@0x801DE43C)

Player slots are 0 to 2 and enemy slots are 3 to 10, so a battle has 11 battlers at most. An enemy work row stores its slot at +0x05 as slot + 3 (Battle_InitEnemy (emi/battle/battle/15@0x800ABCE0)). Code addresses enemy rows from the virtual base 0x801EB2E8, which is 0x801EB630 minus three enemy strides of 280 bytes, so one base serves both sides: slot 3 is 0x801EB2E8 + 3 * 280 = 0x801EB630. A pointer to “battler n” resolves by side first, then by slot.

Three rows of 320 bytes at 0x80145E90. A field has a role only when the evidence cell names the function that shows it.

Offset Type Meaning Evidence
0x000 u8 flags: bit 0 row occupied, bit 6 handler busy Battle_SlotIsBlocked (emi/battle/battle/03@0x801DB524); func_801E8D04 clears bit 6
0x001 u8 header.mode, the mode inside the current action machine func_801E020C
0x002 u8 header.step, the action-machine step; 4 with mode 6 on a knockout, 0 with mode 2 after an action func_801E020C
0x005 u8 battler slot 0-10 Battle_CalcDamage (emi/battle/battle/03@0x801DC044) takes it as an argument
0x00C s32 vx, added to x each physics step func_800A8B40
0x010 s32 vy, added to y each physics step func_800A8B40
0x014 s32 vz, added to the height half at +0x3E each step; the word at +0x20 is added to it; at -0x40 the step advances func_800A8B40
0x018 s32 unk_18, added to the whole word at +0x3C each step func_800A8B40
0x020 s32 gravity, added to the word at +0x14 each step func_800A8B40
0x032 u16 depth, the halfword handed to the primitive builder func_800AB910
0x034 s32 (16.16) pos.x; read as one word and as two halfwords func_800A8B40
0x038 s32 (16.16) pos.y; read as one word and as two halfwords func_800A8B40
0x03C s32 pos.z, 16.16; the physics code reads the height in the high half +0x3E; the two overlays read that halfword with opposite signs, and func_800AF764 projects it negated func_800A8B40; copied whole by func_801E72F4 and func_801DDAF0; written by func_801DEF0C and func_801E352C
0x074 Character chr, a copy of the character record (layout); reprisal_chance is at stats + 0x35 (+0xA9), critical_chance at stats + 0x36 (+0xAA) func_801DD08C copies 164 bytes here
0x118 BattleCommandSlot u.turn.command: target, type and id none found
0x11C s16 u.turn.hp_change, signed HP change that the hit shows; seeded from the current HP in the stats copy func_801D527C seeds it; func_801DFCB4 tests its sign
0x11E s16 u.turn.ap_change, signed AP change func_801DFCB4
0x120 u8 u.turn.target_flags none found
0x121 u8 u.turn.counter; cleared while a reprisal is pending func_801E1DD4
0x122 u8 u.turn.choice, the menu choice stored with the command none found
0x123 u8 u.turn.unk_0B none found
0x124 BattlerFlags u.turn.damage_flags (bits in State word bits) hit and popup readers
0x128 BattlerFlags u.turn.action_flags (bits in State word bits) action gate and turn order
0x12C u8[8] status.unk_12C; battle clears all eight cells when the battler falls Battle_DefeatEnemy
0x136 u8 counter_136 none found
0x137 u8 counter_137 none found
0x138 u8 focus_counter, 0 to 2 Battle_CalcDamage spends it as a power bonus
0x13C u8 character_index, the Character slot this battler was built from none found
typedef struct PartyMember {
/* 0x000 */ TaskHeader header;
/* 0x003 */ u8 unk_03, unk_04;
/* 0x005 */ u8 slot, pad_06, unk_07;
/* 0x008 */ u8 facing, unk_09, timer;
/* 0x00B */ BattlerParam param;
/* 0x00C */ s32 unk_0C, unk_10, unk_14;
/* 0x018 */ s32 unk_18, unk_1C, unk_20;
/* 0x024 */ u8 unk_24, unk_25, unk_26, unk_27, unk_28;
/* 0x029 */ s8 unk_29, unk_2A, unk_2B;
/* 0x02C */ BattleScreenCoord unk_2C, unk_2E, unk_30;
/* 0x032 */ u16 depth;
/* 0x034 */ WorldPos pos;
/* 0x040 */ SpriteScale scale;
/* 0x048 */ u8 unk_48, unk_49, unk_4A, unk_4B;
/* 0x04C */ struct PartyMember* unk_4C;
/* 0x050 */ s32 unk_50, unk_54;
/* 0x058 */ u16 unk_58, unk_5A;
/* 0x05C */ u8 unk_5C, unk_5D, unk_5E, unk_5F;
/* 0x060 */ s32 unk_60, unk_64;
/* 0x068 */ u8 pad_68[8];
/* 0x070 */ u8 unk_70, pad_71[3];
/* 0x074 */ Character chr;
/* 0x118 */ union { BattleTurn turn; FieldModeWork field; } u;
/* 0x12C */ union { u8 unk_12C[8]; FieldEntryWork field; } status;
/* 0x134 */ u16 unk_134;
/* 0x136 */ u8 counter_136, counter_137, focus_counter, unk_139,
unk_13A[2], character_index, unk_13D, pad_13E[2];
} PartyMember; /* 0x140 bytes */

Source: include/battle/records.h

Other cells are read but have no known role. 0x29-0x2B are signed bytes and 0x2C a halfword, read by both overlays. 0x2E and 0x30 are halfwords that emi/battle/battle/03 reads unsigned and emi/battle/battle/15 signed, because the panels slide to negative screen positions. 0x40, 0x44 and 0x4C are words, 0x1C a word and 0x48 a byte, read only by emi/battle/battle/03. [unknown] for the rest: 0x24-0x28, 0x4B, 0x50, 0x54, 0x58, 0x5A, 0x5C-0x5F, 0x134, 0x139-0x13B and 0x13D-0x13F. A trace of which routine writes each cell would settle them.

Eight rows of 280 bytes at 0x801EB630. Battle_InitEnemy and Battle_AddEnemy (emi/battle/battle/15@0x800AC01C) arm a slot and clear +0x06 to +0x5F first. Widths follow the accesses.

Offset Type Meaning Evidence
0x000 u8 header.flags: bit 0 row occupied Battle_SlotIsBlocked (emi/battle/battle/03@0x801DB524)
0x001 u8 header.mode none found
0x002 u8 header.step none found
0x005 u8 slot, stored as slot + 3 Battle_InitEnemy
0x008 u8 unk_08, the battle index with its low bit flipped the slot setup (Battle_InitEnemy, Battle_AddEnemy)
0x029 u8 unk_29, set to 4 when the slot is armed the slot setup
0x034 s32 pos.x none found
0x038 s32 pos.y none found
0x03C s32 pos.z; high half +0x3E is the vertical span at the enemy’s position, from Area_SampleHeight of x and y; written when the slot is armed func_800AE82C copies the whole word into the local work row’s +0x3C
0x04B u8 unk_4B, set to 0xFF when the slot is armed the slot setup
0x074 u8[8] name, drawn as text Battle_DrawEnemyNamePanel
0x07C EnemyIdCode enemy_id, the enemy-record index none found
0x07E u8 choice_ai none found
0x080 u16 event_flags; bit 2 makes the enemy eligible to counter an attack func_801E4368
0x082 u16 status; 0x4000 is knockout func_801E496C
0x084 u16 zenny, added to the battle reward Battle_DefeatEnemy
0x086 u16 exp, added to the battle reward Battle_DefeatEnemy
0x088 u16 level, the turn-order ranking and base damage the turn-order ranking reader
0x08A u16 unk_8A, set from the area scene record when the slot is armed none found
0x08C u8[8] skills; the event packet’s tail is copied here Battle_ApplyEnemyEvent
0x094 u16 hp func_801E496C
0x096 u16 ap read by emi/battle/battle/03
0x098 EnemyDrop[2] drops (layout in Drops) Battle_RollEnemyDrops
0x0A0 Stats stats: max_hp at 0x0A0, max_ap at 0x0A2, then power, defense, agility, intellect; resistances at 0x0AF func_801E496C, func_800AFC98
0x0C0 Stats base, the stats before buffs none found
0x0E0 u8 kind, selects the event handlers func_801E8DD8
0x0E1 u8 triggered_events, one bit per event packet already applied none found
0x0E2 s8 panel_offset_x, added to the panel’s screen x none found
0x0E3 s8 panel_offset_y, added to the panel’s screen y none found
0x0E4 ModeFunc unk_E4, the per-enemy hook: mode 0 chooses, mode 1 is hit, mode 2 runs every frame func_801E25E0, func_801E3C14
0x0E8 u16* unk_E8, pointer to u16 cells none found
0x0EC u8* script, pointer to a u8 script none found
0x0F0 u8 unk_F0, unk_F1 and pad_F2[2] none found
0x0F4 BattleCommandSlot turn.command none found
0x0F8 s16 turn.hp_change, damage dealt this hit; negative heals func_801E496C
0x0FA s16 turn.ap_change none found
0x0FC u8 turn.target_flags, side and slot mask func_800A9820
0x0FD u8 turn.counter none found
0x0FE u8 turn.choice none found
0x0FF u8 turn.unk_0B none found
0x100 BattlerFlags turn.damage_flags (bits in State word bits) both overlays
0x104 BattlerFlags turn.action_flags (bits in State word bits) both overlays
0x108 s8[8] stat_multipliers; the first four modify power, defense, agility and intellect none found
0x110 u8 pad_110[2], unk_112 to unk_115 and pad_116[2] none found
typedef struct EnemyBattler {
/* 0x000 */ TaskHeader header;
/* 0x003 */ u8 unk_03, unk_04, slot, unk_06, unk_07, unk_08, pad_09[3];
/* 0x00C */ s32 unk_0C, unk_10, unk_14, unk_18, unk_1C, unk_20;
/* 0x024 */ u8 unk_24, pad_25[4], unk_29, pad_2A[1], unk_2B, pad_2C[2];
/* 0x02E */ s16 unk_2E, unk_30, unk_32;
/* 0x034 */ WorldPos pos;
/* 0x040 */ u8 pad_40[8], unk_48, pad_49[2], unk_4B, pad_4C[0xC];
/* 0x058 */ u16 unk_58, unk_5A;
/* 0x05C */ u8 unk_5C, unk_5D, unk_5E, unk_5F, pad_60[0x14];
/* 0x074 */ u8 name[8];
/* 0x07C */ EnemyIdCode enemy_id;
/* 0x07E */ u8 choice_ai, unk_7F;
/* 0x080 */ u16 event_flags, status;
/* 0x084 */ u16 zenny, exp, level, unk_8A;
/* 0x08C */ u8 skills[ENEMY_SKILL_COUNT];
/* 0x094 */ u16 hp, ap;
/* 0x098 */ EnemyDrop drops[2];
/* 0x0A0 */ Stats stats;
/* 0x0C0 */ Stats base;
/* 0x0E0 */ u8 kind, triggered_events;
/* 0x0E2 */ s8 panel_offset_x, panel_offset_y;
/* 0x0E4 */ ModeFunc unk_E4;
/* 0x0E8 */ u16* unk_E8;
/* 0x0EC */ u8* script;
/* 0x0F0 */ u8 unk_F0, unk_F1, pad_F2[2];
/* 0x0F4 */ BattleTurn turn;
/* 0x108 */ s8 stat_multipliers[ENEMY_STAT_MULTIPLIER_COUNT];
/* 0x110 */ u8 pad_110[2], unk_112, unk_113, unk_114, unk_115, pad_116[2];
} EnemyBattler; /* 0x118 bytes */

Source: include/battle/records.h

Cells with no known role ([unknown]): 0x06, 0x07, 0x0C-0x24, 0x2B, 0x2E, 0x30, 0x32, 0x48, 0x5C-0x5F, 0x7D, 0x7E, 0x7F, 0xA6, 0xAA, 0xE1-0xE3, 0xF0, 0xF5, 0xFA, 0xFD, 0x112, 0x114 and 0x115. emi/battle/battle/03 reads 0x7E as a byte, and emi/battle/battle/15 reads 0xA6 and 0xAA as halfwords.

A defeated enemy drops up to two items. The drop rows at enemy +0x98 and +0x9C are the two item rows of the area’s enemy record, copied unchanged by Battle_LoadEnemyBattler (emi/battle/battle/15@0x800AC218) when Battle_AddEnemy runs. The rate index selects a chance from the table in drops, which also gives the roll.

Offset Type Meaning
0x00 u16 item id that the spoils gain when the roll passes: the record’s item index (low byte) and item type (high byte)
0x02 u8 index into the 8-byte drop chance table at 0x801D0CB8: the low byte of the record’s u16 rate
0x03 u8 flags; battle sets bit 0 once an ability has raised the rate
typedef struct EnemyDrop {
/* 0x00 */ u16 item;
/* 0x02 */ u8 rate;
/* 0x03 */ u8 flags;
} EnemyDrop;

Source: include/battle/records.h

The battle outcome record collects what a battle yields. It sits at 0x80146324, is 64 bytes long, and Battle_RollEnemyDrops (emi/battle/battle/03@0x801E531C) walks its BattleDrops at +0x10. g_BattleDrops at 0x80146326 is an alias for its attempts and drop-count bytes.

Offset Type Meaning
0x00 u8 surprise flags
0x01 u8 battle option flags
0x02 u8 escape attempts; emi/battle/battle/15 reads this byte
0x03 u8 count of listed drops, capped at 15
0x04 u8 battle result flags
0x05 u8 flags of the battle events that fired
0x08 u32 experience gained
0x0C s32 zenny gained
0x10 BattleDrops the dropped item ids and their counts
typedef struct BattleOutcome {
/* 0x00 */ u8 surprise, options, attempts, drop_count, result, event_flags;
/* 0x06 */ u8 pad_06[2];
/* 0x08 */ u32 reward_exp;
/* 0x0C */ s32 reward_zenny;
/* 0x10 */ BattleDrops drops;
} BattleOutcome; /* 0x40 bytes */
typedef struct BattleDrops {
/* 0x00 */ u16 items[16];
/* 0x20 */ u8 item_counts[16];
} BattleDrops; /* 0x30 bytes */

Source: include/battle/records.h

Before a wild encounter, the field overlay fills eight 12-byte candidate entries at 0x801463DC. func_800ABC30 (emi/battle/battle/15@0x800ABC30) reads the id, x and y of each live entry and hands them to Battle_InitEnemy.

Offset Type Meaning
0x00 u8 live flag; set by Area_RollEncounterEnemies (emi/etc/game/00@0x801C6AEC), cleared when the candidate is out of reach
0x01 u8 index of one 136-byte enemy record (&D_800E405E + id * 136); 0xFF means none
0x04 s32 (16.16) pos.x; written by Area_PlaceEncounterEnemies (emi/etc/game/00@0x801C6BB4)
0x08 s32 (16.16) pos.y; written by Area_PlaceEncounterEnemies
typedef struct EncounterEnemy {
/* 0x00 */ u8 active, id, pad_02[2];
/* 0x04 */ Point2DL pos;
} EncounterEnemy;

Source: include/battle/records.h

Enemy record bytes +0x82 and +0x83 (block +0xCA, +0xCB) are the reach and height that Area_BuildEncounter and func_801E8DD8 read; game records owns their meaning.

A panel task draws one window of the battle interface: 22 slots of 36 bytes at 0x80148330, ending at 0x80148648, which is a pointer cell that func_800B0410 loads and reads through. emi/battle/battle/15 reads only the first 12 bytes of a task and reads x and y signed.

Offset Type Meaning
0x03 u8 short-menu state word
0x04 u16 panel x
0x06 u16 panel y
0x0A u8 selected battler slot in emi/battle/battle/03 (row index is slot - 3); slide mode in emi/battle/battle/15 (0 moves the panel right)
0x0B u8 ratio: enemy value times 0x37 over a divisor, floored at 1
0x0D u8 cursor; cleared on panel entry
0x12 u16 first row of the panel list (func_800B1728 (emi/battle/battle/15@0x800B1728))
0x14 u16 HP bar numerator, copied from the enemy row’s current HP
0x1C u16 HP bar divisor, copied from the enemy row’s maximum HP
typedef struct BattlePanelTask {
/* 0x00 */ u8 unk_00[3], state;
/* 0x04 */ BattleScreenCoord x;
/* 0x06 */ BattleScreenCoord y;
/* 0x08 */ u8 unk_08, unk_09;
/* 0x0A */ BattlePanelCell0A cell_0A;
/* 0x0B */ u8 ratio, unk_0C, cursor;
/* 0x0E */ u8 pad_0E[4];
/* 0x12 */ u16 row_base;
/* 0x14 */ u16 hp;
/* 0x16 */ u8 pad_16[6];
/* 0x1C */ u16 max_hp;
} BattlePanelTask; /* 0x1E bytes */

Source: include/battle/records.h

func_800B1728 and func_800B0F9C (emi/battle/battle/15@0x800B0F9C) also read the cells at +0x12 and +0x14 as bytes. +0x12 is the box drawer’s scale and +0x14 is the number of rows it draws.

A queued action slot is one of 48 rows of 120 bytes at 0x801EC330; emi/battle/battle/03 names the head fields and emi/battle/battle/15 the tail.

Offset Type Meaning
0x05 u8 handler index into the mode’s handler table; stored by Battle_AllocEffect (emi/battle/battle/03@0x801E590C)
0x06 u8 slot mode; selects the stage table
0x29 u8 action step; stored by func_801DE1D4
0x34 s32 x (16.16)
0x38 s32 y (16.16)
0x4B u8 panel cell index stored by emi/battle/battle/15
0x5C u8[4] cleared by func_801DE1D4 as a byte row
0x60 s32 action target index, stored by func_800AAEBC; the low halfword is the capture count that func_801E5CA4 draws
0x74 u32 address of the work record that the slot points at
typedef struct BattleEffect {
/* 0x000 */ TaskHeader header;
/* 0x003 */ u8 unk_03, unk_04, handler_index, unk_06, unk_07, unk_08;
/* 0x009 */ BattleEffectArg arg;
/* 0x00A */ u8 unk_0A, unk_0B;
/* 0x00C */ s32 unk_0C, unk_10;
/* 0x014 */ u8 pad_14[4];
/* 0x018 */ s32 unk_18, unk_1C;
/* 0x020 */ u8 pad_20[7], unk_27, unk_28, unk_29;
/* 0x02A */ u8 pad_2A[4];
/* 0x02E */ s16 unk_2E, unk_30;
/* 0x032 */ u16 unk_32;
/* 0x034 */ WorldPos pos;
/* 0x040 */ u8 pad_40[8], unk_48;
/* 0x049 */ u8 pad_49[2], unk_4B;
/* 0x04C */ u8 pad_4C[0x10];
/* 0x05C */ u8 unk_5C, unk_5D, unk_5E, unk_5F;
/* 0x060 */ BattleTargetIndex word_60;
/* 0x064 */ u8 pad_64[0x10];
/* 0x074 */ BattleEffectTarget target;
} BattleEffect; /* 0x78 bytes */

Source: include/battle/records.h

Three more tables belong to the panels.

  • The owner table is the panel task array shifted by 3, so its records start at 0x80148333. Byte +0x07 of record i is the kind that func_801DA69C walks (0x8014833A, stride 36).
  • The panel-owner table at 0x801ED9B0 has 4-byte entries: the owner index (u8 at 0x00), a second byte (0x01) and the panel id (u16 at 0x02).
  • The selection-type table at 0x801CA71C has 20-byte rows. A u16 mask is at 0x00, and emi/battle/battle/15 reads the rest byte by byte.
typedef struct BattleOwnerKind {
/* 0x00 */ u8 kind_00;
/* 0x01 */ u8 pad_01[0x23];
} BattleOwnerKind; /* 0x24 bytes */
typedef struct PanelOwner {
/* 0x00 */ u8 owner_index, unk_01;
/* 0x02 */ u16 panel_id;
} PanelOwner; /* 4 bytes */
typedef struct BattleSelectionType {
/* 0x00 */ u16 mask;
/* 0x02 */ u8 unk_02[0x12];
} BattleSelectionType; /* 0x14 bytes */

Source: include/battle/records.h

g_BattleState (0x801462E8) is the latch both overlays poll.

Bit Name Set by Read as
0x0002 window busy boss windows Battle_Update tests it
0x0004 effect playing the hit endings and every effect module the closing step waits for the effect
0x0010 command armed command menu menu steps
0x0040 reprisal pending a won reprisal roll the turn’s closing step
0x0080 critical critical-hit roll damage and popup readers
0x0400 effect loading the effect stream request action steps wait until EMI_IsReady (exe/slus_004_22@0x80162D00)
0x0800 AP paid AP spend action gate
0x1000 reprisal done the answer’s own hit ending the next closing step clears it
0x2000 damage applied damage application popup and end-of-hit steps
0x4000 over battle end both overlays
0x8000 reload party the reload path the reload path clears it

The effect loading bit stays set from the action’s effect stream request until the loader is ready (Battle_FinishEffectLoad). Bit 0x0008 is also used. func_801D277C and func_8009B828 set it and func_801D656C clears it, but no reader is known, so it has no name.

The damage word (enemy +0x100, player +0x124) and the action word (enemy +0x104, player +0x128) carry their own flags.

Word Bit Effect
damage 6 marks a damage target
damage 7 runs the popup and countdown
damage 8 makes the hit lethal and queues the reaction cue
damage 9 marks a damage row
damage 12 skips the action gate
damage 15 reprisal rating
damage 16 zeroes the damage and the HP bar numerator
action 3 marks an installed mode-handler action
action 4 keeps the row available during suppression
action 6 applies the queued power boost
action 9 halves damage
action 11, 13 zero the holy and fire resistance
action 14 charges the action
action 15 marks a preemptive turn

The target selector byte at 0x80146384 holds one battler slot (0-10) in its low values. Bit 6 (0x40) selects the enemy side, bit 7 (0x80) the party side, and 0xC0 both sides.

The result byte at 0x80146328 uses bit 0 for defeat, bit 1 for victory and bit 3 for no background music (the field music replay after the battle is skipped). Any set bit forces the end state.

A reprisal is the struck battler’s immediate physical answer. The hit’s ending step decides it, the closing step hands over the turn, and the answer is marked so it cannot be answered again. Pending is g_BattleState bit 0x0040; done is bit 0x1000.

Step Function Rule
Hit ending of the struck battler func_801E020C, func_801E414C The target was knocked out: clear pending and go to step 6, sub-step 4. Else pending was set: clear pending and set done. Else, when the action targets one battler rather than a side: a physical action sets pending when the reprisal roll passes; an ability whose kind mask has 0x800 and whose kind flag 0x10 is clear sets pending when the roll passes.
Closing step of the turn func_801D43EC Clear done. When pending is set, swap the 16 action-state bytes of the acting battler and the target, set the command state to physical, and restart the acting battler at step 0, sub-step 1.

The party roll is reprisal_chance (character record offset 0x35) out of 100 (func_801DD448 (emi/battle/battle/03@0x801DD448)). Damage-word bit 15 forces it, and ability 0xA1 never lets a party member answer. The enemy roll passes when the event flags bit 2 is set and either damage-word bit 15 is set or a flat 70 percent roll passes (func_801E4368 (emi/battle/battle/03@0x801E4368)).

The battle code copies a table to the stack and indexes it. Names follow the selector, not the row count.

Table Address Rows Index selects Reader
g_BattlePhases 0x801D0C04 6 battle mode 0x801462E0 Battle_DispatchMode (emi/battle/battle/03@0x801D112C)
g_BattleEntrances 0x801D0C1C 4 sub-step 0x801462E2 Battle_DispatchEntrance (emi/battle/battle/03@0x801D17C4)
g_BattleEvents 0x801D0C84 5 event slot’s kind bit Battle_UpdateEvents (emi/battle/battle/03@0x801DE43C)
g_BattleEffectStages 0x801D0CC0 4 queued slot mode +0x06 Battle_UpdateEffects (emi/battle/battle/03@0x801E5824)
g_BattleEffectStage0Funcs 0x801D0CD0 19 queued slot handler index +0x05, mode 0 func_801E5AF4
g_BattleEffectStage1Funcs 0x801D0D1C 110 queued slot handler index +0x05, mode 1 func_801E5B8C
g_BattleEffectStage3Funcs 0x801D0ED4 8 queued slot handler index +0x05, mode 3 func_801E5C1C
g_BattlePanelFuncs 0x801D0F80 8 panel task kind +0x02 func_801E9074
g_BattlePanelTaskForwarders 0x801D0FEC 3 caller’s selector byte func_801EA1E0
g_BattleRecallAbilities 0x801EAC58 32 rand() & 0x1F; the row is an ability id Battle_PickTarget (emi/battle/battle/03@0x801D3844)
g_BattleMagicShuffleAbilities 0x801EAC78 32 rand() & 0x1F; the row is an ability id Battle_PickTarget (emi/battle/battle/03@0x801D3844)

The two recall tables hold pick weights, not padding. Ability 0x76 (Burn) fills 16 rows of the first and 8 rows of the second, so it is the likeliest pick. The panel forwarders take seven arguments and a selector. A four-entry result-ring icon table of function pointers sits at 0x801D1004, and the battle effects read the same shape from their own module head. The boss-battle event hook takes a mode (0-6 from emi/battle/battle/03) and returns a byte. func_801D656C treats 0xFF as pending.

An ability’s effect module is found through three tables. g_BattleActionSelection (emi/battle/battle/03, 0x800B6510, 232 bytes) maps the ability index, the low byte of g_BattleActionId, to a row of g_BattleSelections (0x800B65F8, 8-byte rows). The row’s id is an EMI slot id; g_EmiSlotLbas[slot] gives its start sector, which names the BIN/BMAGIC/MAGICnnn.EMI file. Battle_LoadSelectionEffect (emi/battle/battle/15@0x800AE1F8) runs this chain.

The table lists every ability with an effect module, grouped by shared module. The selection table is zero in SLUS_004.22 and is filled from the battle overlay at runtime, so the rows come from emi/battle/battle/15. Four ability indices (0x7F, 0x80, 0x8B, 0xD9) use the empty row 0xFFFF.

Selection row EMI slot Effect module Abilities
1 0x125 MAGIC001 0x01 Nue Stomp
42 0x12B MAGIC008 0x02 Gambit, 0x07 Mind Flay, 0x08 Blind, 0x1C Devour, 0x3D Target, 0x8E Syphon, 0xA4 Feign Swing, 0xA5 Backhand, 0xAA Risky Blow
3 0x127 MAGIC003 0x03 Super Combo
88 0x128 MAGIC004 0x04 ThundrStrike
98 0x129 MAGIC005 0x05 Flame Strike, 0x9B Pyrokinesis
109 0x12A MAGIC006 0x06 Mind Sword
51 0x12C MAGIC009 0x09 Chlorine
9 0x12D MAGIC010 0x0A Unmotivate, 0x17 Bad back, 0x18 Watch Enemy, 0x19 Noting
68 0x133 MAGIC018 0x0B Multistrike, 0x8D Triple Blow
71 0x12E MAGIC012 0x0C Blitz
50 0x12F MAGIC013 0x0D Snap
55 0x130 MAGIC015 0x0E Flying Kick
4 0x130 MAGIC015 0x0F Charge
58 0x131 MAGIC016 0x10 Air Raid
43 0x132 MAGIC017 0x11 Astral Warp, 0xAB Shadowwalk
5 0x133 MAGIC018 0x12 Giant Growth
6 0x134 MAGIC019 0x13 Aura
8 0x135 MAGIC020 0x14 Disembowel
33 0x136 MAGIC021 0x15 Bonebreak
53 0x133 MAGIC018 0x16 Spirit Blast
81 0x13C MAGIC042 0x1A Counter, 0x2A MindŽs Eye
25 0x178 MAGIC108 0x1B Hypnotize, 0x6C Confuse, 0xD2 Confuse
100 0x137 MAGIC029 0x1D Wind Strike
29 0x166 MAGIC088 0x1E Molasses, 0x1F Tarbaby, 0x58 Slow, 0x59 Blunt, 0x5A Weaken, 0xBE Slow, 0xBF Blunt, 0xC0 Weaken
44 0x156 MAGIC070 0x20 Absorb, 0x46 Heal, 0xAE Heal
45 0x157 MAGIC071 0x21 Healing Herb, 0x47 Rejuvenate, 0xAF Rejuvenate
32 0x162 MAGIC082 0x22 Steroids, 0x23 Magic Belt, 0x52 Protect, 0x54 Speed, 0x55 Might, 0xB8 Protect, 0xBA Speed, 0xBB Might
27 0x160 MAGIC080 0x24 Recall, 0x25 MagicShuffle, 0x50 Noting, 0x6F Noting, 0x70 Noting, 0x8C Trump, 0x93 Noting, 0x94 Noting, 0xD6 Noting
121 0x138 MAGIC038 0x26 War Shout
78 0x139 MAGIC039 0x27 Focus, 0xA3 Meditation
79 0x13A MAGIC040 0x28 Enlighten
80 0x13B MAGIC041 0x29 Berserk
110 0x13D MAGIC043 0x2B WardOfLight, 0x99 Resist
96 0x13E MAGIC044 0x2C Evil Eye
61 0x13F MAGIC045 0x2D Bone Dart
62 0x140 MAGIC046 0x2E Firebreath
63 0x141 MAGIC047 0x2F Icebreath
41 0x142 MAGIC048 0x30 Dream Breath
99 0x143 MAGIC049 0x31 Frost Strike
31 0x144 MAGIC050 0x32 Pollen, 0x33 Venom Breath
107 0x145 MAGIC052 0x34 Ovum
134 0x146 MAGIC053 0x35 Lavaburst
56 0x147 MAGIC054 0x36 Howling
65 0x148 MAGIC055 0x37 Ebonfire
112 0x149 MAGIC056 0x38 Sacrifice
84 0x14A MAGIC057 0x39 Bone Dance
82 0x14B MAGIC058 0x3A Sanctuary
83 0x14C MAGIC059 0x3B Tornado
39 0x14D MAGIC060 0x3C Identify
95 0x14E MAGIC062 0x3E Celerity
143 0x14F MAGIC063 0x3F SuddenDeath
77 0x150 MAGIC064 0x40 Weretiger
70 0x151 MAGIC065 0x41 Pilfer
17 0x152 MAGIC066 0x42 Tsunami
18 0x153 MAGIC067 0x43 Chill
40 0x154 MAGIC068 0x44 Foretell
75 0x155 MAGIC069 0x45 Influence
113 0x158 MAGIC072 0x48 Restore, 0xB0 Restore
47 0x159 MAGIC073 0x49 Vitalize, 0xB1 Vitalize
114 0x15A MAGIC074 0x4A Vigor, 0xB2 Vigor
46 0x15B MAGIC075 0x4B Purify, 0xB3 Purify
30 0x15D MAGIC077 0x4C Raise Dead, 0x4D Resurrect, 0xB4 Raise Dead, 0xB5 Resurrect
15 0x15E MAGIC078 0x4E Leech Power, 0xB6 Leech Power
52 0x15F MAGIC079 0x4F Drain, 0xB7 Drain
85 0x161 MAGIC081 0x51 RottenBreath
94 0x163 MAGIC083 0x53 Shield, 0xB9 Shield
28 0x164 MAGIC086 0x56 Barrier, 0xBC Barrier
48 0x165 MAGIC087 0x57 Silence, 0xBD Silence
21 0x167 MAGIC091 0x5B Flare, 0xC1 Flare
49 0x168 MAGIC092 0x5C Fireblast, 0xC2 Fireblast
103 0x169 MAGIC093 0x5D Inferno, 0xC3 Inferno
20 0x16A MAGIC094 0x5E Frost, 0xC4 Frost
22 0x16B MAGIC095 0x5F Iceblast, 0xC5 Iceblast
102 0x16C MAGIC096 0x60 Blizzard, 0xC6 Blizzard
19 0x16D MAGIC097 0x61 Jolt, 0xC7 Jolt
37 0x16E MAGIC098 0x62 Lightning, 0xC8 Lightning
36 0x16F MAGIC099 0x63 Myollnir, 0xC9 Myollnir
13 0x170 MAGIC100 0x64 Cyclone, 0xCA Cyclone
26 0x171 MAGIC101 0x65 Typhoon, 0xCB Typhoon
69 0x172 MAGIC102 0x66 Quake, 0xCC Quake
57 0x173 MAGIC103 0x67 Simoon, 0xCD Simoon
14 0x174 MAGIC104 0x68 Sirocco, 0xCE Sirocco
64 0x175 MAGIC105 0x69 Kyrie, 0xCF Kyrie
104 0x176 MAGIC106 0x6A Death, 0xD0 Death
24 0x177 MAGIC107 0x6B Sleep, 0xD1 Sleep
12 0x179 MAGIC109 0x6D Depress, 0xD3 Depress
38 0x17A MAGIC110 0x6E Ragnarok, 0xD4 Ragnarok
10 0x17D MAGIC113 0x71 Noting
11 0x17E MAGIC114 0x72 Fire Whip
115 0x17F MAGIC115 0x73 Remedy, 0xD7 Remedy
59 0x180 MAGIC116 0x74 UtmostAttack
73 0x181 MAGIC117 0x75 Rest, 0x98 Snooze
60 0x182 MAGIC118 0x76 Burn
54 0x133 MAGIC018 0x77 Double Blow
16 0x183 MAGIC120 0x78 Whelp Breath
122 0x184 MAGIC121 0x79 DragonBreath
74 0x185 MAGIC122 0x7A Flame Breath
76 0x186 MAGIC123 0x7B Frost Breath
124 0x187 MAGIC124 0x7C ThundrBreath
125 0x188 MAGIC125 0x7D DivineBreath
127 0x189 MAGIC126 0x7E ShadowBreath
145 0x18A MAGIC129 0x81 Holocaust
141 0x18B MAGIC130 0x82 Venom
144 0x18C MAGIC131 0x83 KaiserBreath
139 0x18D MAGIC132 0x84 Doom Breath
129 0x18E MAGIC133 0x85 Flame Claw
130 0x18F MAGIC134 0x86 Frost Claw
131 0x190 MAGIC135 0x87 Thunder Claw
132 0x191 MAGIC136 0x88 Shining Claw
101 0x192 MAGIC137 0x89 Corona
118 0x193 MAGIC138 0x8A Main Cannon
66 0x194 MAGIC143 0x8F Thunder Clap
67 0x195 MAGIC144 0x90 Wall of Fire
149 0x196 MAGIC145 0x91 Noting
150 0x197 MAGIC146 0x92 Noting
106 0x181 MAGIC117 0x95 Douse
72 0x198 MAGIC150 0x96 Eye Beam
86 0x199 MAGIC151 0x97 Accession
35 0x19A MAGIC154 0x9A Mighty Chop
92 0x19B MAGIC156 0x9C Holy Strike
93 0x19C MAGIC157 0x9D Demonbane
89 0x19D MAGIC158 0x9E Charm
120 0x19E MAGIC159 0x9F Gloom
105 0x125 MAGIC001 0xA0 Jump
111 0x19F MAGIC161 0xA1 Timed Blow
116 0x1A0 MAGIC162 0xA2 Transfer
90 0x1A1 MAGIC166 0xA6 Monopolize
91 0x1A2 MAGIC167 0xA7 Last Resort
117 0x1A3 MAGIC168 0xA8 Cure
97 0x1A4 MAGIC169 0xA9 Benediction
23 0x1A5 MAGIC172 0xAC Magic Ball
34 0x1A6 MAGIC173 0xAD Intimidate
148 0x1A7 MAGIC213 0xD5 Noting
87 0x1A8 MAGIC216 0xD8 Steal
142 0x1A9 MAGIC218 0xDA Aura Breath
138 0x1AA MAGIC219 0xDB Magma Breath
136 0x1AB MAGIC220 0xDC Geo Breath
146 0x1AC MAGIC221 0xDD GaeaŽsBreath
133 0x1AD MAGIC222 0xDE Combustion
137 0x1AE MAGIC223 0xDF Tempest, 0xE0 Hurricane
140 0x1AF MAGIC225 0xE1 Temptation
135 0x1B0 MAGIC226 0xE2 MeteorStrike
147 0x1B1 MAGIC227 0xE3 MeteorStrike
Value Source Meaning
escape thresholds 0x800B44F0, six bytes 0x20-0x34 steps of 4, starting at 32
difficulty thresholds 0x800B50DC, eight bytes 1,2,4,8,12,16,24,48 indexed by the ability high nibble +0x0D
palette stage row 0x80035600, 64-byte rows one per battler slot (index << 6); GFX_LoadPalette copies 32 halfwords
accessory effect table 0x80149EC8, four-byte pointers indexed by accessory_id - 1, bound 0x17 (23 entries)

Overlays loaded at 0x80096800 (emi/battle/battle/15 and the boss archives) carry their own copy of the byte tables, each indexed directly by the record id. These are the ability call table at 0x800B44F8, the item call table at 0x800B45E0 and the item animation table at 0x800B6AC0.

  • [unknown] The role of the unnamed cells listed under each work row. A write trace per cell would settle them.
  • [unknown] Readers of state bit 0x0008. A trace of reads of g_BattleState would settle it.
  • [inferred] The community RAM map confirms the row addresses but not the field roles (sources).
  • Confidence: medium. The row addresses, sizes and the dispatch tables are established, but many cells have no known role and several fields have no reader.
  • Evidence: the functions of the two battle overlays and of emi/etc/game/00 named in the evidence cells. Community cheat lists confirm addresses only (sources).
  • Battle flow: how a battle starts, runs and ends.
  • Game records: the static enemy, ability and character tables that feed these rows.
  • Field and party records: the actor rows and party state that the battle reads before and after a fight.
  • Memory map: the overlay windows that these two overlays load into.