Jump to content

FE12 Growth Rate Cipher Documentation


Recommended Posts

Hi there. 

A few weeks back, I documented the growth rate cipher for Fire Emblem Awakening. Apparently, FE12's growth rate cipher was also undocumented. Let's fix that :)

As an example, I will be using Marth's growth rates.

Note: Much of this is copy/pasted from my awakening growth document, but this was documented by loading FE12 in No$GBA's debugger.

 

Also note: decrypt_class_growth(classdata_ptr, enciphered_growth_rate, growth_rate_index) is at 0x2049418 when FE12 is in RAM. decrypt_unit_growth(unitdata_ptr, enciphered_growth_rate, growth_rate_index) is at 0x2049280 when FE12 is in RAM. 

 

Unit Growth Rates

Growth rate data is stored, enciphered, as a sequence of 8 bytes, in the usual stat ordering (HP, Str, Mag, Skl, Spd, Lck, Def, Res).

Marth's growth rates for example, are the highly inscrutable `D1 E3 6C E1 F6 2E 15 49 98`.

 

The conversion process is both simple, and fairly complex. To lookup the growth rate for the stat at index N (zero-indexing), we perform the calculation

INDEX = (ENCIPHERED[N]- (0x57 * ((CHARACTER_ID ^ 0x3E) - 3 * N) ^ 0xF5)) & 0xFF;

GROWTH_RATE = LOOKUP_TABLE[INDEX];

Where LOOKUP_TABLE is the following lookup table, found at 0xF408 in FE12Data.bin:

3C 7F 83 81 80 78 6A 08 BC D8 75 89 2C 41 BD C6 4A C7 AE A0 19 72 28 03 40 99 43 42 07 A5 74 B4 DB D0 50 18 A4 F9 91 88 CB 5F 55 DD 82 3A 93 0A D4 26 1A D1 29 85 AB EF 5A 12 B0 EA 7C 6B 4F 9D 06 27 E2 64 4C E4 BB EE 6F 8B 2F 30 51 61 65 A7 77 FA 5D E1 CE FD 5C F8 8F 8C C3 A1 CA DE CF F5 B2 69 D5 B5 23 C8 0B 31 3F 60 20 C2 3B AF 1C 05 92 6D 8E 71 36 96 22 2B 1B 3D FF 73 59 BE 35 BA B1 45 15 CC 4B 1D 7A 9C 0E 84 49 67 AD F0 0F 2E 5E 16 7B F7 52 BF EB 9B C5 E3 DC 02 8D 04 F6 21 C0 38 3E 4D 11 E9 1F FB A6 AC 94 62 2A D9 A8 C4 F3 00 C1 CD D3 9F A3 9E EC D7 FC E8 0D 47 48 90 E5 58 DA A9 56 FE D6 34 6E AA 0C 8A 95 17 01 68 09 B7 E7 37 25 79 E6 63 98 B9 33 B6 87 86 24 A2 70 76 5B F2 44 13 E0 46 53 B8 32 2D 10 1E C9 7D 14 F1 9A D2 57 4E F4 ED 97 B3 DF 39 54 66 6C 7E

Okay, there's basically no chance that was clear. So let's do the calculations, to make it a bit clearer.

Suppose we want the HP growth rate. That's stat 0. Enciphered[0] is 0xD1, and Marth's character ID is 0, so we calculate INDEX = (0xD1 - (0x57 * ((0 ^ 0x3E) - 3 * 0) ^ 0xF5)) & 0xFF = 0xEA. The value in the lookup table at index 0xEA is 0x32, or 50 -- Marth's base HP growth rate.

Suppose we want the Lck growth rate. That's stat 5. Enciphered[5] is 0x2E, and Marth's character ID is 0, so we calculate INDEX = (0x2E - (0x57 * ((0 ^ 0x3E) - 3 * 5) ^ 0xF5)) & 0xFF = 0x22. The value in the lookup table at index 0x22 is 0x50, or 80 -- Marth's base Lck growth rate.

 

Class Growth Rates

As with unit growth rate data, class growth rate data is stored, again enciphered as a sequence of 8 bytes in the usual ordering.

Marth's base class is Lord, which has enciphered growth rate `32 C7 C4 B3 D8 46 21 06`.

 

The conversion process for class growth rates proceeds much like the unit growth rate -- the formula is just different. We perform the calculation:

INDEX = (ENCIPHERED[N]- (0xB3 * ((CLASS_ID ^ 0x9D) - 7 * N) ^ 0xDB)) & 0xFF;

GROWTH_RATE = LOOKUP_TABLE[INDEX];

Where LOOKUP_TABLE is the same as it was for unit growth rates.

 

Again, walking through the calculations for Lord:

Suppose we want the HP growth rate. That's stat 0. Enciphered[0] is 0x32, and Lord's class ID is 0, so we calculate INDEX = (0x32 - (0xB3 * ((0 ^ 0x9D) - 7 * 0) ^ 0xDB)) & 0xFF = 0x16. The value in the lookup table at index 0x16 is 0x28, or 40 -- Lord's base HP growth rate.

Suppose we want the Lck growth rate. That's stat 5. Enciphered[5] is 0x46, and Lord's class ID is 0, so we calculate INDEX = (0x46 - (0xB3 * ((0 ^ 0x9D) - 7 * 5) ^ 0xDB)) & 0xFF = 0xB1. The value in the lookup table at index 0xB1 is 0x00, or 0 -- Lord's base Lck growth rate.

 

Hope this is clear, feel free to ask any clarifying questions, and have fun playing around with growth rates!

Edited by SciresM
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...