At the start, r0 is a pointer to the attacker’s battle data, and r1 the defender. Note they switch when calculating the other side’s round of battle.
Also note that the unit data automatically calculates the stats with boosts(from equipped item and such) so when I say str, I really mean boosted str.
080289B0 B530 push {r4,r5,r14}
080289B2 1C04 mov r4,r0
080289B4 1C0D mov r5,r1
No comment here. just backing up the pointers to use later.
080289B6 F000F86F bl #0x8028A98
- Loads weapon ability 1.
- check it for the bit in 0x40(magic damage)
- if so, loads battle defense in the attacker’s battle data and defender’s resistance
- if not, checks for weapon ability 1 against #0x2(Magic)
- if so, do the same thing as above
- if not, loads battle defense in the attacker’s battle data and defender’s defense stat
- Adds the appropriate def or res to whatever was already in the defense slot(likely from terrain or something?)
- Stores defense.
-tl;dr Calculates defense from stats
080289BA 1C20 mov r0,r4
080289BC 1C29 mov r1,r5
080289BE F000F8A7 bl #0x8028B10
- Loads weapon of the attacker
- Loads power of the weapon
- adds that to weapon triangle effect byte and stores it into the power byte of the attacker
- Loads the weapon(again)
- [Checks for the effectiveness of the weapon][1] and [applies it if there is one][2]
[1]: [[FE7] Designating Weapon Effectiveness - #3 by Crazycolorz5]
[2]: Changing FE7's weapon effectiveness factor - [Loads strength of the attacker and adds it to the power][3]
[3]: [FE7] Changing Damage/Might To Be Based Off Of A Different Stat(such a Skl, or a custom one, such as (true)Mag) - Stores power back.
-tl;dr Calculates power based on (precalculated) weapon triangle, effectiveness, and strength.
080289C2 1C20 mov r0,r4
080289C4 F000F8D0 bl #0x8028B68
- Loads equipped weapon’s weight
- Loads attacker’s con
- Subtracts them, compares to 0.
- if weight is less than or equal to con, then load speed and subtract 0 from it
- if weight is greater than con, then load speed and subtract the difference from it
- Load the AS halfword from the attacker data and store it there.
- If what we just stored is less than 0, then store 0 instead.
-tl;dr Calculates attack speed
080289C8 1C20 mov r0,r4
080289CA F000F8E9 bl #0x8028BA0
- Loads the weapon’s hit%
- Loads attacker’s skill
- Multiplies the skill by 2 (left shifts by 1, more technically)
- Adds them
- Loads attacker’s luk
- Gets the sign bit of the luk(lsign byte; luk is signed) and adds it to the luk.
- This is for proper rounding/flooring for when luk is negative, but this isn’t necessary, I think.
- Divides by two.
- Adds that to what we had before
- Loads the weapon triangle hit bonus and adds that on
- Stores the hit into the hit word in battle data memory.
- Loads 0x202BBF8 (Is this tactician data?)
- Loads its 0x2B byte(I think this is the tactician stars)
- Presumably does some more checks? It checks for not being an enemy/other unit, and it checks for something else(maybe prevent bonuses in the link arena?) and then the affinities matching. I think the branch at 080BFC88 loads the number of tactician stars(Since there’s a check for >0xA stars right below it)
- Add on the tactician bonus and stores it back into the hit slot in battle data.
- Interesting, the bl #0x8028194 in the subroutine seems to do an inventory scan and has a HARD CODED CHECK for item number 8A – the emblem seal. Gives 10 hit if it finds it, obviously, but it’s interesting that it’s a hard coded check for that item.
-tl;dr Calculates hit based on base hit, skl and luk, and tactician stars and emblem seal.
080289CE 1C20 mov r0,r4
080289D0 F000F93E bl #0x8028C50
- The single mov hints to me that this is going to be based on the attacker only.
- Loads the AS
- Multiplies it by two
- Loads the byte 7 before AS(which is undocumented)(Terrain avoid bonus, or support?)(Seeing how terrain was calculated already in the defense part, I think that’s done somewhere else.)
- Adds it to what the AS*2
- Loads and adds on luk
- Stores it in avoid
- Gets tactician star bonus(I think?) and adds it on if applicable.
- Gets Emblem seal bonus like from above.
- If negative, store 0 as avoid.
-tl;dr Calculates avoid based on as, luk, support bonus, tactician stars, and emblem seal.
080289D4 1C20 mov r0,r4
080289D6 F000F993 bl #0x8028D00
- Gets the equipped weapon’s base critical.
- Gets the attacker’s skill and does a signed divide by two
- Adds them
- Stores it into the critical slot of the unit data
- Loads the character and class of the unit, and loads character abilities.
- Checks character ability 1 against 0x40, i.e. “Critical +15”
- Gives 0xF bonus if it is, and stores the cit back.
- All in all, a rather efficiently written routine.
-tl;dr Calculates crit based on base crit, skl, and ability 1 being Crit+15.
080289DA 1C20 mov r0,r4
080289DC F000F9AE bl #0x8028D3C
- Literally the shortest routine ever.
- Loads luk and stores it in as dodge(crit avoid).
-tl;dr Go read it it’s like two lines long. Calculates dodge based on Luk.
080289E0 1C20 mov r0,r4
080289E2 1C29 mov r1,r5
080289E4 F000F81E bl #0x8028A24
-
Loads halfword at 0x203A3D8 (It seems to tell what condition’s we’re calling under… 0x04 = status screen, 0x02 = battle preview, 0x01 = in battle) (Using a Vulnerary, Heal staves = 0x80)(In a no-animation battle = 0x81) (I think the 0x80 bit represents having a map animation… the 0x01 bit is battle)
-
ANDs it with 0x20 (I… don’t know what circumstances this would be called?)
-
If the result is nonzero, then load byte at 0x202BC0D(actually loads 0x202BBF8+0x15, but same thing)(Something in the tactician data? Seems to be 0?
-
I’ll finish that line of thought some other time since I don’t know when it applies.
-
It the result from before is zero(usually, I think)
-
This is a pain to track down, but one of its branch calls retrieves the supports data pointer, so I assume it calculates bonuses from supports.
-tl;dr I’m not sure, but I think this just calculates support bonuses.
080289E8 1C20 mov r0,r4
080289EA F000FA45 bl #0x8028E78
- Get equipped item’s weapon type (e.g. sword, spear, … item, dragon stone, etc)
- If it’s 0x7 and below(i.e. the 4 melee types and 4 spell types) then leads the weapon rank and checks if you’re S-rank
- If so, loads and adds 5 onto hit and crit.
-tl;dr S Rank bonus
080289EE 1C20 mov r0,r4
080289F0 F000FA60 bl #0x8028EB4
-
Loads the unit’s status effect.
-
Checks for and applies one of Ninis’s Grace, Fila’s Might, etc.
-
Gets the appropriate stat, adds 0xA and stores it back and returns.
080289F4 BC30 pop {r4,r5}
080289F6 BC01 pop {r0}
080289F8 4700 bx r0 -
Returns to caller. We’re done!