Match sub_8072B72 thanks to @jiangzhengwenjz and another func too

This commit is contained in:
Seth Barberee 2023-11-18 10:46:41 -08:00
parent c0cd5d0048
commit c466893134
5 changed files with 125 additions and 179 deletions

View File

@ -5,57 +5,6 @@
.text
thumb_func_start sub_8071D4C
sub_8071D4C:
push {lr}
ldr r3, [r1, 0x70]
ldrb r0, [r3, 0x9]
cmp r0, 0x64
beq _08071D94
adds r0, r3, 0
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x4A
beq _08071D64
cmp r0, 0x47
bne _08071D68
_08071D64:
movs r0, 0x1
b _08071D6A
_08071D68:
movs r0, 0
_08071D6A:
cmp r0, 0
bne _08071D94
ldr r1, [r3, 0x18]
adds r2, r1, r2
ldr r0, _08071D98
cmp r2, r0
ble _08071D7A
ldr r2, _08071D9C
_08071D7A:
subs r2, r1
cmp r2, 0
beq _08071D94
movs r0, 0xFE
lsls r0, 1
adds r1, r3, r0
ldr r0, [r1]
adds r0, r2
str r0, [r1]
ldr r0, _08071DA0
ldr r1, [r0]
movs r0, 0x1
strb r0, [r1, 0xD]
_08071D94:
pop {r0}
bx r0
.align 2, 0
_08071D98: .4byte 0x0098967e
_08071D9C: .4byte 0x0098967f
_08071DA0: .4byte gDungeon
thumb_func_end sub_8071D4C
thumb_func_start sub_8071DA4
sub_8071DA4:
push {r4-r7,lr}
@ -1850,130 +1799,4 @@ _08072B6C:
bx r0
thumb_func_end sub_8072B24
thumb_func_start sub_8072B78
sub_8072B78:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x20
mov r8, r0
adds r7, r1, 0
lsls r5, r2, 16
asrs r5, 16
ldr r6, [r7, 0x70]
ldr r4, _08072BFC
adds r0, r4, 0
adds r1, r6, 0
movs r2, 0
bl SetMessageArgument_2
adds r4, 0x50
adds r0, r4, 0
adds r1, r5, 0
bl CopyCyanMonsterNametoBuffer
adds r0, r5, 0
bl sub_80687D0
adds r4, r0, 0
lsls r0, r5, 16
lsrs r0, 16
strh r0, [r6, 0x4]
strh r0, [r6, 0x2]
ldrb r2, [r6, 0x9]
mov r0, sp
adds r1, r5, 0
bl GetPokemonLevelData
ldr r0, [sp]
str r0, [r6, 0x18]
str r4, [r7, 0x64]
adds r0, r6, 0
movs r1, 0
bl sub_806BFC0
adds r0, r7, 0
bl sub_8069E0C
adds r0, r7, 0
movs r1, 0x7
bl sub_806CCB4
ldr r0, _08072C00
ldr r2, [r0]
mov r0, r8
adds r1, r7, 0
bl sub_80522F4
adds r0, r7, 0
bl sub_8042A44
bl sub_8083D78
movs r0, 0x9E
lsls r0, 1
cmp r5, r0
bne _08072C74
movs r5, 0
ldr r4, _08072C04
b _08072C0C
.align 2, 0
_08072BFC: .4byte gAvailablePokemonNames
_08072C00: .4byte gUnknown_80FE2EC
_08072C04: .4byte gAdjacentTileOffsets
_08072C08:
adds r4, 0x4
adds r5, 0x1
_08072C0C:
cmp r5, 0x7
bgt _08072C36
movs r1, 0
ldrsh r0, [r4, r1]
movs r2, 0x4
ldrsh r1, [r7, r2]
adds r0, r1
movs r3, 0x2
ldrsh r1, [r4, r3]
movs r3, 0x6
ldrsh r2, [r7, r3]
adds r1, r2
bl GetTile
adds r1, r0, 0
ldr r0, _08072C80
bl sub_807034C
lsls r0, 24
cmp r0, 0
bne _08072C08
_08072C36:
ldr r0, _08072C80
mov r8, r0
bl sub_803D930
lsls r0, 24
cmp r0, 0
beq _08072C74
add r0, sp, 0xC
movs r3, 0
movs r4, 0
mov r1, r8
strh r1, [r0]
ldrb r1, [r6, 0x9]
strh r1, [r0, 0x8]
strb r3, [r0, 0x2]
ldr r1, _08072C84
lsls r2, r5, 2
adds r2, r1
ldrh r1, [r7, 0x4]
ldrh r5, [r2]
adds r1, r5
strh r1, [r0, 0xC]
ldrh r1, [r7, 0x6]
ldrh r2, [r2, 0x2]
adds r1, r2
strh r1, [r0, 0xE]
str r4, [r0, 0x4]
strb r3, [r0, 0x10]
movs r1, 0x1
bl sub_806B7F8
_08072C74:
add sp, 0x20
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08072C80: .4byte 0x0000013d
_08072C84: .4byte gAdjacentTileOffsets
thumb_func_end sub_8072B78
.align 2, 0

View File

@ -246,7 +246,7 @@ typedef struct EntityInfo
/* 0x1F6 */ bool8 notMoving;
u8 fill1F7[0x1FA - 0x1F7];
/* 0x1FA */ s16 mobileTurnTimer; // When a Pokémon can pass through walls in a hallway, this counts up to 200 before the Pokémon turns in a random direction.
/* 0x1FC */ u16 expGainedInTurn; // Used to accumulate experience when multiple enemies are defeated in one turn.
/* 0x1FC */ u32 expGainedInTurn; // Used to accumulate experience when multiple enemies are defeated in one turn.
/* 0x200 */ u32 statusIcons;
u8 unk204;
} EntityInfo;
@ -338,4 +338,4 @@ enum VisualFlag
VISUAL_FLAG_RUN_AWAY = 2
};
#endif
#endif

View File

@ -244,6 +244,7 @@ SECTIONS {
src/dungeon_pokemon_attributes.o(.text);
src/code_80718D8.o(.text);
asm/code_80718D8.o(.text);
src/code_8072B78.o(.text);
src/dungeon_ai_leader.o(.text);
asm/code_8072CF4.o(.text);
src/dungeon_ai_items.o(.text);

View File

@ -129,3 +129,40 @@ void sub_8071B48(void)
}
}
}
static inline bool8 sub_8071D4C_sub(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
{
return TRUE;
}
if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE)
{
return TRUE;
}
return FALSE;
}
void sub_8071D4C(Entity *pokemon, Entity *target, s32 exp)
{
s32 newExp;
s32 expDiff;
EntityInfo *info;
info = target->info;
if (info->level != 100) {
if (!sub_8071D4C_sub(info)) {
newExp = info->exp + exp;
if (9999998 < newExp) {
newExp = 9999999;
}
expDiff = newExp - info->exp;
if (expDiff != 0) {
info->expGainedInTurn += expDiff;
gDungeon->unkD = 1;
}
}
}
}

85
src/code_8072B78.c Normal file
View File

@ -0,0 +1,85 @@
#include "global.h"
#include "structs/dungeon_entity.h"
#include "structs/map.h"
#include "structs/str_pokemon.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "code_805D8C8.h"
extern u8 gAvailablePokemonNames[];
extern u8 gUnknown_202DFE8[];
extern Position gAdjacentTileOffsets[];
extern u8 *gUnknown_80FE2EC[];
struct unkStruct_806B7F8
{
u16 species;
u8 unk2;
u32 unk4;
u16 level;
u8 fillA[0xC - 0xA];
struct Position pos;
u8 unk10;
};
extern void sub_806B7F8(struct unkStruct_806B7F8 *, u32);
extern void sub_806BFC0(EntityInfo *, u32);
void sub_8069E0C(Entity *pokemon);
extern void sub_806CCB4(Entity *, u8);
void sub_80522F4(Entity *r0, Entity *r1, const char r2[]);
void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index);
extern void SetMessageArgument_2(u8 *, EntityInfo *, u32);
void GetPokemonLevelData(LevelData* a1, s16 _id, s32 level);
void sub_8042A44(Entity *r0);
void sub_8083D78(void);
extern bool8 sub_803D930(u32);
static inline void fu(EntityInfo *entityInfo, s16 id)
{
++id; --id;
entityInfo->apparentID = id;
entityInfo->id = id;
}
void sub_8072B78(Entity *pokemon, Entity *target, s16 id)
{
OpenedFile *file;
Tile *tile;
int index;
s32 id_s32;
EntityInfo *entityInfo;
LevelData levelData;
struct unkStruct_806B7F8 local_2c;
id_s32 = id;
entityInfo = target->info;
SetMessageArgument_2(gAvailablePokemonNames,entityInfo,0);
CopyCyanMonsterNametoBuffer(gAvailablePokemonNames + 0x50,id_s32);
file = sub_80687D0(id_s32);
fu(entityInfo, id_s32);
GetPokemonLevelData(&levelData,id_s32,entityInfo->level);
entityInfo->exp = levelData.expRequired;
target->sprite = file;
sub_806BFC0(entityInfo,0);
sub_8069E0C(target);
sub_806CCB4(target,7);
sub_80522F4(pokemon,target,*gUnknown_80FE2EC);
sub_8042A44(target);
sub_8083D78();
if (id_s32 == MONSTER_NINJASK) {
for (index = 0; index < 8; index++) {
tile = GetTile(gAdjacentTileOffsets[index].x + target->pos.x,gAdjacentTileOffsets[index].y + target->pos.y);
if (sub_807034C(MONSTER_SHEDINJA,tile) == 0) break;
}
if (sub_803D930(MONSTER_SHEDINJA)) {
local_2c.species = MONSTER_SHEDINJA;
local_2c.level = entityInfo->level;
local_2c.unk2 = 0;
local_2c.pos.x = gAdjacentTileOffsets[index].x + target->pos.x;
local_2c.pos.y = gAdjacentTileOffsets[index].y + target->pos.y;
local_2c.unk4 = 0;
local_2c.unk10 = 0;
sub_806B7F8(&local_2c,1);
}
}
}