[FE8] Is this dead-unused code? [ASM engine]

Been tinkering with various things and saw this:

Green Box is the vanilla RES/DEF calculations based on weapon type (0x40) (0x2) (none)
Then there’s the red box that calculates DEF again for… no reason and does nothing?
By putting “Break” on the section on the de-bugger seems to not be used anywhere?

Even deleted it and nothing seems to be affected. Not even detailed set forecast.

I’d like to use that space if empty so I’m wondering if anyone has insight of that red marked section and if it’s safe to delete and use for other…stuff.

I think it is being used.

0802AAA4 1C01   mov r1 ,r0   //LoadRawDefense
0802AAA6 3156   add r1, #0x56
0802AAA8 7809   ldrb r1, [r1, #0x0]
0802AAAA 0609   lsl r1 ,r1 ,#0x18
0802AAAC 1609   asr r1 ,r1 ,#0x18
0802AAAE 2217   mov r2, #0x17
0802AAB0 5682   ldsb r2, [r0, r2]
0802AAB2 1889   add r1 ,r1, r2
0802AAB4 305C   add r0, #0x5c
0802AAB6 8001   strh r1, [r0, #0x0]
0802AAB8 4770   bx lr

This routine is called from the following function.

0802CB24 B5F0   push {r4,r5,r6,r7,lr}   //SetupBattleStructForStaffUser
0802CBC8 B510   push {r4,lr}   //SetupBattleStructForStaffTarget
2 Likes

This is a different function that is used for item effects and other such non-fight things. Off the top of my head like that I’m not sure why it needs to compute defense for those (but I’m sure there’s a reason) yet it does.

1 Like

Oh I see now. Thanks both of you.