[FE7] Delving into the EXP Routine

Just docs as I throw together another tech demo~

@0802964C checks allegiance for exp gain – write 5 nops to get rid of
@0809FD44 some hardcoded check for character number above 45???


probably returns whether EXP is to be gained or not
called by 08029F10
returns boolean
r0 = 0203A3F0 (attacker data)
r1 = 0203A470 (defender data)

looks like a division routine

int 08029E74
int calcEXP();
returns EXP to be gained, I think?
hopefully this is the actual calculation?

push {regs}				@ yeah
mov r7, r0				@ r7 = *player
mov r5, r1				@ r5 = *enemy
mov r0, #0x13			@ index of current HP
ldsb r0, [r5, r0]		@ load enemy's current HP
cmp r0, #0x0			@ if enemy's dead
beq ENEMY_DEAD			@
mov r0, #0x0			@ probably bonus EXP gained from killing?
b	RETURN				@

mov r6, #0x14 @ 20?
ldr r1, =0x0202BBF8 @
ldrb r0, [r1, #0x1B] @ mode
cmp r0, #0x1 @ lyn mode?
beq label1 @
mov r0, #0x40 @ bit flag
ldrb r1, [r1, #0x14] @ presumably hard mode
and r0, r1 @
cmp r0, #0x0 @ if it’s 0 (ie not hard mode)
beq SKIP @
08029DCC(*defender) @
r6 = r0 + 0x14
08029DCC(*attacker) @
sub r6, r0 @ i have no clue
b label2
08029DCC(*defender) @ yep
mov r4, r0 @
08029DCC(*attacker) @ zzz
cmp r4, r0 @ if defender’s level is lower than attacker’s???
bgt label3 @ i’m not sure
08029DCC(*defender) @ again?
mov r4, r0 @ shouldn’t have changed?
08029DCC(*attacker) @ again!
lsr r1, r0, #0x1F @ take only the last bit?
add r0, r0, r1 @ i… see?
asr r0, r0, #0x1 @ ???
b label4
08029DCC(*defender) @ right
mov r4, r0 @ this is the same as before
08029DCC(*attacker) @ IS r u srs
r4 -= r0 @ relative level difference
r6 += r4 @ add 20? Still super confused.
08029E08(*attacker, *defender)
add r6, r0 @ adding bonus EXP
08029E30(*attacker, *defender)
cmp r6, #0x0 @ checking if exp is 0
mov r0, r6
pop {r4-r7}
pop {r1}
bx r1 @ yeah

int 08029DCC(*unitdata)
called by 08029E74

relativeLv = unit.class.classPwr * unit.level;
if (unit.isPromoted) {
	relativeLv += 20 * unit.class.preCls.classPwr;
return relativeLv;

ptr getClassPtr(int id);
called by 08029DCC

int 08029E08(*attacker, *defender)
int getKillExp(*attacker, *defender)
called by 08029E74

int 08029E30(*attacker, *defender)
called by 08029E74
int getEXPFactor(*attacker, *defender);[/code]

i had more in that folder but idw text wall super hard when it’s already in the doc

Yeah I basically looked through and figured all of that out. What I need to track down now is what decides which EXp bar/level up screen it draws.

If at all possible, could you explain how I would add experience gains to a different affiliation? I’m fairly new to assembly and hex editing.

Just to give you an idea of what I’m attempting, I want to do a co-op type hack and give the NPC’s the capability of gaining experience. If you can, explain it to me like I’m 5. I would appreciate any helpful input.

Welcome to FEU! I see you’ve found an old thread. In the future if you only have a question, you should just start a new thread in the Questions category. These old documentation threads are left open just in case someone wants to add new info they’ve figured out about it. Not to worry, though!

Regarding your question, I don’t know how for fe7, but Shuusuke has a small hack for it for fe8.

This section in particular:

0802BA0E, the default value there is 0xC0, meaning only blue units can gain exp. To make it so all units can gain EXP, change it to 0x0 like in the image. Change to 0x40 to allow only NPCs to gain EXP, or 0x80 to allow only enemies to gain EXP
Also important is to not forget to set the units you want to gain EXP to 0 (or just a value of not 255, since that is the comparison)

If you are hacking fe7 to make a reskin, I don’t have an answer for you (this thread says fe7), but fe8 is the standard to hack in general.

Hope this helps! Good luck with the hacking.

1 Like