decompile more pokemon functions

This commit is contained in:
YamaArashi 2017-05-07 21:10:44 -07:00
parent 02c44d7f38
commit 9c75355d71
11 changed files with 98 additions and 240 deletions

View File

@ -11669,7 +11669,7 @@ sub_801B928: @ 801B928
adds r2, r5, 0
adds r2, 0x3C
adds r1, r2
bl sub_8040AD0
bl IsOtherTrainer
lsls r0, 24
cmp r0, 0
beq _0801B9DA

View File

@ -8832,7 +8832,7 @@ _080203B8:
muls r0, r1
ldr r1, _08020400 @ =gPlayerParty
adds r0, r1
bl sub_8040AA4
bl IsTradedMon
lsls r0, 24
cmp r0, 0
beq _08020404
@ -15948,7 +15948,7 @@ _08023CC8:
lsls r0, 16
lsrs r4, r0, 16
adds r0, r4, 0
bl sub_8040A00
bl IsHMMove2
cmp r0, 0
beq _08023D20
ldr r0, _08023D14 @ =0x0000013f

View File

@ -170,7 +170,7 @@ _0804144A:
movs r2, 0x50
bl memcpy
adds r0, r4, 0
bl pokemon_restore_pp
bl BoxMonRestorePP
movs r0, 0x88
lsls r0, 1
add r0, r8

View File

@ -73,7 +73,7 @@ AddHatchedMonToParty: @ 80429EC
movs r1, 0x23
bl SetMonData
adds r0, r5, 0
bl sub_8040B1C
bl MonRestorePP
adds r0, r5, 0
bl CalculateMonStats
add sp, 0x14

View File

@ -2408,7 +2408,7 @@ _08112DCC:
lsls r0, 16
lsrs r4, r0, 16
adds r0, r4, 0
bl sub_8040A00
bl IsHMMove2
cmp r0, 0
beq _08112E24
ldr r0, _08112E10 @ =gUnknown_08400F8C
@ -3701,7 +3701,7 @@ _08113910:
lsls r0, 16
lsrs r4, r0, 16
adds r0, r4, 0
bl sub_8040A00
bl IsHMMove2
cmp r0, 0
beq _08113970
ldr r0, _0811395C @ =gUnknown_08400F8C

View File

@ -6,227 +6,6 @@
.text
thumb_func_start sub_8040A00
sub_8040A00: @ 8040A00
push {r4,lr}
lsls r0, 16
lsrs r3, r0, 16
ldr r2, _08040A24 @ =gUnknown_0820831A
ldrh r0, [r2]
ldr r1, _08040A28 @ =0x0000ffff
cmp r0, r1
beq _08040A32
adds r4, r1, 0
adds r1, r2, 0
_08040A14:
ldrh r0, [r2]
adds r1, 0x2
adds r2, 0x2
cmp r0, r3
bne _08040A2C
movs r0, 0x1
b _08040A34
.align 2, 0
_08040A24: .4byte gUnknown_0820831A
_08040A28: .4byte 0x0000ffff
_08040A2C:
ldrh r0, [r1]
cmp r0, r4
bne _08040A14
_08040A32:
movs r0, 0
_08040A34:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8040A00
thumb_func_start sub_8040A3C
sub_8040A3C: @ 8040A3C
lsls r0, 16
lsrs r0, 16
ldr r2, _08040A50 @ =gBaseStats
lsls r1, r0, 3
subs r1, r0
lsls r1, 2
adds r1, r2
ldrb r0, [r1, 0x19]
lsrs r0, 7
bx lr
.align 2, 0
_08040A50: .4byte gBaseStats
thumb_func_end sub_8040A3C
thumb_func_start sub_8040A54
sub_8040A54: @ 8040A54
push {r4,lr}
lsls r4, r1, 24
lsrs r4, 24
bl GetNature
lsls r0, 24
lsrs r0, 24
ldr r2, _08040A78 @ =gUnknown_083F7E28
lsls r1, r0, 2
adds r1, r0
adds r1, r4
adds r1, r2
movs r0, 0
ldrsb r0, [r1, r0]
pop {r4}
pop {r1}
bx r1
.align 2, 0
_08040A78: .4byte gUnknown_083F7E28
thumb_func_end sub_8040A54
thumb_func_start sub_8040A7C
sub_8040A7C: @ 8040A7C
push {r4,lr}
lsls r4, r1, 24
lsrs r4, 24
bl GetNatureFromPersonality
lsls r0, 24
lsrs r0, 24
ldr r2, _08040AA0 @ =gUnknown_083F7E28
lsls r1, r0, 2
adds r1, r0
adds r1, r4
adds r1, r2
movs r0, 0
ldrsb r0, [r1, r0]
pop {r4}
pop {r1}
bx r1
.align 2, 0
_08040AA0: .4byte gUnknown_083F7E28
thumb_func_end sub_8040A7C
thumb_func_start sub_8040AA4
sub_8040AA4: @ 8040AA4
push {r4,lr}
sub sp, 0x8
adds r4, r0, 0
movs r1, 0x7
mov r2, sp
bl GetMonData
adds r0, r4, 0
movs r1, 0x1
movs r2, 0
bl GetMonData
mov r1, sp
bl sub_8040AD0
lsls r0, 24
lsrs r0, 24
add sp, 0x8
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8040AA4
thumb_func_start sub_8040AD0
sub_8040AD0: @ 8040AD0
push {r4,r5,lr}
adds r5, r1, 0
ldr r3, _08040B10 @ =gSaveBlock2
ldrb r2, [r3, 0xA]
ldrb r1, [r3, 0xB]
lsls r1, 8
orrs r2, r1
ldrb r1, [r3, 0xC]
lsls r1, 16
orrs r2, r1
ldrb r1, [r3, 0xD]
lsls r1, 24
orrs r2, r1
cmp r0, r2
bne _08040B14
movs r4, 0
ldrb r0, [r5]
cmp r0, 0xFF
beq _08040B0C
adds r2, r5, 0
_08040AF8:
adds r1, r4, r3
ldrb r0, [r2]
ldrb r1, [r1]
cmp r0, r1
bne _08040B14
adds r2, 0x1
adds r4, 0x1
ldrb r0, [r2]
cmp r0, 0xFF
bne _08040AF8
_08040B0C:
movs r0, 0
b _08040B16
.align 2, 0
_08040B10: .4byte gSaveBlock2
_08040B14:
movs r0, 0x1
_08040B16:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8040AD0
thumb_func_start sub_8040B1C
sub_8040B1C: @ 8040B1C
push {lr}
bl pokemon_restore_pp
pop {r0}
bx r0
thumb_func_end sub_8040B1C
thumb_func_start pokemon_restore_pp
pokemon_restore_pp: @ 8040B28
push {r4-r6,lr}
sub sp, 0x4
adds r5, r0, 0
movs r6, 0
_08040B30:
adds r4, r6, 0
adds r4, 0xD
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
bl GetBoxMonData
cmp r0, 0
beq _08040B7C
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
bl GetBoxMonData
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
adds r0, r5, 0
movs r1, 0x15
movs r2, 0
bl GetBoxMonData
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r2, r6, 24
lsrs r2, 24
adds r0, r4, 0
bl CalculatePPWithBonus
mov r1, sp
strb r0, [r1]
adds r1, r6, 0
adds r1, 0x11
adds r0, r5, 0
mov r2, sp
bl SetBoxMonData
_08040B7C:
adds r6, 0x1
cmp r6, 0x3
ble _08040B30
add sp, 0x4
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end pokemon_restore_pp
thumb_func_start sub_8040B8C
sub_8040B8C: @ 8040B8C
push {r4,r5,lr}

View File

@ -11660,7 +11660,7 @@ _0809B508:
ldr r0, _0809B540 @ =0x000025b4
adds r4, r0
adds r0, r4, 0
bl pokemon_restore_pp
bl BoxMonRestorePP
ldr r3, _0809B544 @ =gPokemonStorage
lsls r0, r5, 2
adds r0, r5

View File

@ -115,15 +115,15 @@ gUnknown_082082FE:: @ 82082FE
.byte -5, -5, -10
.align 1
gUnknown_0820831A:: @ 820831A
.2byte 0xF
.2byte 0x13
.2byte 0x39
.2byte 0x46
.2byte 0x94
.2byte 0xF9
.2byte 0x7F
.2byte 0x123
gHMMoves:: @ 820831A
.2byte MOVE_CUT
.2byte MOVE_FLY
.2byte MOVE_SURF
.2byte MOVE_STRENGTH
.2byte MOVE_FLASH
.2byte MOVE_ROCK_SMASH
.2byte MOVE_WATERFALL
.2byte MOVE_DIVE
.2byte 0xFFFF
@ "Nidoran♂" Japanese name

View File

@ -457,7 +457,7 @@ u8 GetNatureFromPersonality(u32 personality);
u16 nature_stat_mod(u8 nature, u16 n, u8 statIndex);
void sub_8040B1C(void *);
void MonRestorePP(struct Pokemon *);
u8 *sub_803F378(u16 itemId);

View File

@ -1079,7 +1079,7 @@ u8 SendMonToPC(struct Pokemon *mon)
{
if (GetBoxMonData(&gPokemonStorage.boxes[i][j], MON_DATA_SPECIES, NULL) == SPECIES_NONE)
{
sub_8040B1C(mon);
MonRestorePP(mon);
CopyMon(&gPokemonStorage.boxes[i][j], &mon->box, sizeof(mon->box));
return 1;
}

View File

@ -92,6 +92,8 @@ extern u8 gBattleMonForms[];
extern const u8 BattleText_Wally[];
extern const struct SpritePalette gMonPaletteTable[];
extern const struct SpritePalette gMonShinyPaletteTable[];
extern const u16 gHMMoves[];
extern s8 gUnknown_083F7E28[];
extern u8 gUnknown_082082F8[];
extern u8 gUnknown_083FFDB3[];
@ -1241,3 +1243,80 @@ const struct SpritePalette *sub_80409C8(u16 species, u32 otId , u32 personality)
else
return &gMonPaletteTable[species];
}
bool8 IsHMMove2(u16 move)
{
int i = 0;
while (gHMMoves[i] != 0xFFFF)
{
if (gHMMoves[i++] == move)
return TRUE;
}
return FALSE;
}
bool8 sub_8040A3C(u16 species)
{
return gBaseStats[species].bodyColor >> 7; // XXX: should this be a bitfield instead?
}
s8 sub_8040A54(struct Pokemon *mon, u8 a2)
{
u8 nature = GetNature(mon);
return gUnknown_083F7E28[nature * 5 + a2];
}
s8 sub_8040A7C(u32 personality, u8 a2)
{
u8 nature = GetNatureFromPersonality(personality);
return gUnknown_083F7E28[nature * 5 + a2];
}
bool8 IsOtherTrainer(u32, u8 *);
bool8 IsTradedMon(struct Pokemon *mon)
{
u8 otName[8];
u32 otId;
GetMonData(mon, MON_DATA_OT_NAME, otName);
otId = GetMonData(mon, MON_DATA_OT_ID, 0);
return IsOtherTrainer(otId, otName);
}
bool8 IsOtherTrainer(u32 otId, u8 *otName)
{
if (otId == (gSaveBlock2.playerTrainerId[0] | (gSaveBlock2.playerTrainerId[1] << 8) | (gSaveBlock2.playerTrainerId[2] << 16) | (gSaveBlock2.playerTrainerId[3] << 24)))
{
int i;
for (i = 0; otName[i] != EOS; i++)
if (otName[i] != gSaveBlock2.playerName[i])
return TRUE;
return FALSE;
}
return TRUE;
}
void BoxMonRestorePP(struct BoxPokemon *);
void MonRestorePP(struct Pokemon *mon)
{
BoxMonRestorePP(&mon->box);
}
void BoxMonRestorePP(struct BoxPokemon *boxMon)
{
int i;
for (i = 0; i < 4; i++)
{
if (GetBoxMonData(boxMon, MON_DATA_MOVE1 + i, 0))
{
u16 move = GetBoxMonData(boxMon, MON_DATA_MOVE1 + i, 0);
u16 bonus = GetBoxMonData(boxMon, MON_DATA_PP_BONUSES, 0);
u8 pp = CalculatePPWithBonus(move, bonus, i);
SetBoxMonData(boxMon, MON_DATA_PP1 + i, &pp);
}
}
}