[FE8] Event Code Documentation

So, since I haven’t done so before, here’s information all basically all the FE8 event codes I know of. Better that nobody has to repeat my work, after all.

Event code format:
Event codes are composed of two bytes, split up into three pieces of information: first is the command ID byte, which is used to determine which ASM routine is loaded; the next byte tells the game how much space (in halfwords) the event command uses for parameters and how to interpret the command within its ASM routine.

For example, let’s look at the command _0x06 2 0. The 0x06 is the command’s ID. The 2 denotes that this command uses up 2 halfwords - 4 bytes - of space. The final zero here is basically an internal parameter; depending on its value, the routine for this command will do different things. For example, _0x620 adds the values of two memory slots, while _0x622 multiplies them.

Not all commands use this nibble; for these cases, it is always zero as it isn’t used.

Event Code Routines:

$0800CEC8 - base code that executes all event commands; loads pointer to the command’s ASM routine. The pointer table is located at $8591B28 for commands with an ID of 0x7E or less, or $8591C98 for commands of ID 0x7F-0xFF. The command id is multiplied by four and then added to the appropriate base offset to obtain the pointer to its asm routine.

$800FB84 - Code for the LOADX commands
$0800D794 - 0x062X commands - parameter of two bytes/three digits, representing three memory slots
    Splits up the three digits of the parameter:
            lowest to r3 (Call it C)
            middle to r5 (Call it B)
            highest to r6 (call it A)
        620 - for param ABC, adds values at memory slots A and B and stores to slot C
        621 - for param ABC, subtracts value at A from value at B and stores to slot C
        622 - for param ABC, multiplies values at memory slots A and B and stores to slot C
        623 - for param ABC, divides B’s value by A’s value and stores to slot C
        624 - for param ABC, something weird with A slot and B slot. Stores result to C…routine at $080D1B4C
        625 - for param 0ABC, ANDs values at memory slots A and B and stores to slot C
        626 - for param 0ABC, ORRs values at memory slots A and B and stores to slot C
        627 - for param 0ABC, XORs values at memory slots A and B and stores to slot C
        628 - for param 0ABC, bitshifts left value at memory slot B by value at by A and stores to slot C
        629 - for param 0ABC, bitshifts right value at memory slot B by value at by A and stores to slot C

$0800D670 - 0x022X commands, one parameter
    Some other shit to do with halfword after current event code ptr

$0800D6E4 - 0x032X commands, one parameter
    Either 0320 or 0321
    If parameter is zero, loads halfword from mem.slot 2
    320 lsl #x10/asr 0x10’s r2, loads halfword-after-epointer, asr’s halfword by r2, ANDS with #0x1
        -If result is zero, stores zero into mem.slot 0xC. Stores 0x1 if result is 0x1.
    321 does a whole lotta weirdness

$0800DA78 - _0x0C4X commands, three parameters: the _SETCONDITION codes
    1st parameter is the conditional ID; if the check fails, the game will skip to the ENIF code with the same ID
    2nd parameter is the first memory slot to load from, usually slot 0xC.
    3rd paramter is the second memory slot to load from; 0x0 always loads the number zero.

The game compares the value in the first memory slot with the value in the second, and passes if:

0xC40 - the two values aren’t equal (skip to the ENIF if they are)
    0xC41 - the two values are equal
    0xC42 - the first value is less than the second
    0xC43 - the first value is less than or equal to the second
    0xC44 - the first value is greater than the second
    0xC45 - the first value is greater than or equal to the second

$0800DBE0 - _0x0F2X commands, one parameter
    Clears all but lowest three bits of lower param
    F20 stores value from $03000568 to memory slot 0xC
    F21, strange operands but seems to store top byte of param in $03000568; lsls param by 4*lower param
    F22 adds 1 to value at $03000568; same param interaction
    F23 subtracts value at $03000568 by 1 (value automatically truncated to one digit)
        also has same interaction with lower param - lsr’s loaded param, then lsl’s subtracted param
    All others can be used to lsl value stored by lower param (or lsr, if lower param is negative?)

$0800DC98 - _0x1020 command, one parameter
    takes value of halfword directly past “current event code” pointer, and
    param 0x1: ORRs with 0x70 (10,20,40)

$0800DD58 - _0x1120 command, one parameter (halfword)
    1120 takes param and branches to $08001440, stores param at $03000010
    all other variations do nothing

$0800E071 - Code for _0x192X commands, no parameters
    1920 checks $0202BD0B
    1921 checks something to do with current events/movement/coords…'s strange
    1922 checks for Hard mode (byte @ $0202BD04)
    1923 takes current turn number, and stores to slot 0xC
    1924 branches to $08019034; counts number of enemies; stores count in slot 0xC
    1925 branches to $08019074; counts number of NPCs alive; stores count in slot
    1926 branches to $080BD068; loads byte at $0202BCFE, $0202BD0B…
    1927 checks value at $0202BD32: tutorials enabled! During hard mode, value is 0x22. If tuts disabled, store 0x0 to mem.slot 0xC
    1928 Loads your cash into slot 0xC
    1929 Branches to $80845E4; compares two words loaded by different means; if equal, store 0 to slot 0xC
    192A Loads Hard mode byte, ANDs with 0x20. Stores 0x1 in slot 0xC if nonzero produced, 0x0 otherwise. May be postgame check…?

$0800FBC2 - Checks for r5, units pointer, greater than zero; if lesser (eg FFFFFFFF), loads from
        the value stored in memory slot 1.

$0800FD28 - _0x2E2X commands, one param?
    2E20 loads pointers in memory based on the param - if nonzero, loads player character memory pointer from 59A5D0 region
    2E21 loads up character pointer of ‘active’ character (for village visiting, etc), stores their char ID in memory slot 0xC

$0800F50C - Counts up the number of units to load; Char ID 00 siginifies end of unit list

    -Lots of possibilities here - FFFF,FFFD,FFFE…
    -Loads active character: $03004E50 has pointer to active character’s memory position (for visiting villages, etc)

$8591B28 - pointer table for event codes
$8591C40 - $591C97: Strange space in between two halves of event code pointer table. Must investigate.

$89EE274 - load reinforcements event - uses memory slot 0x2
$89EE29C - load reinforcements (Hard Mode)

1 Like

This is getting a little long, so here are some other posts I have written on other event codes:

The _SETVAL command; this important command is used in conjunction with many of the codes above

http://serenesforest.net/forums/index.php?showtopic=32759&p=3138849 - The MOVE commands
http://serenesforest.net/forums/index.php?showtopic=32759&p=3146650 - AI changing commands