more decomp and documentation

This commit is contained in:
Seth Barberee
2023-06-23 10:04:49 -07:00
parent 039955d796
commit 40772e3a2f
9 changed files with 208 additions and 444 deletions

View File

@@ -269,201 +269,4 @@ _0808546E:
_0808547C: .4byte gUnknown_80F4598
thumb_func_end sub_8085374
thumb_func_start xxx_call_GetLeader
xxx_call_GetLeader:
push {lr}
bl GetLeader
pop {r1}
bx r1
thumb_func_end xxx_call_GetLeader
thumb_func_start GetPartnerEntity
GetPartnerEntity:
push {r4,r5,lr}
movs r5, 0
_08085490:
ldr r0, _080854B8
ldr r0, [r0]
lsls r1, r5, 2
ldr r2, _080854BC
adds r0, r2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080854C0
ldr r0, [r4, 0x70]
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x41
bne _080854C0
adds r0, r4, 0
b _080854CC
.align 2, 0
_080854B8: .4byte gDungeon
_080854BC: .4byte 0x0001357c
_080854C0:
adds r5, 0x1
cmp r5, 0x3
ble _08085490
movs r0, 0x2
bl GetEntityFromClientType
_080854CC:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end GetPartnerEntity
thumb_func_start sub_80854D4
sub_80854D4:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x20
movs r6, 0
movs r5, 0
add r0, sp, 0x10
mov r8, r0
mov r7, sp
_080854E6:
ldr r0, _080855D8
ldr r0, [r0]
lsls r1, r5, 2
ldr r2, _080855DC
adds r0, r2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _08085504
stm r7!, {r4}
adds r6, 0x1
_08085504:
adds r5, 0x1
cmp r5, 0x3
ble _080854E6
cmp r6, 0x3
bgt _0808551C
movs r1, 0
lsls r0, r6, 2
add r0, sp
_08085514:
stm r0!, {r1}
adds r6, 0x1
cmp r6, 0x3
ble _08085514
_0808551C:
movs r6, 0
movs r4, 0
mov r2, sp
mov r3, r8
movs r5, 0x3
_08085526:
ldr r1, [r2]
cmp r1, 0
beq _0808553A
ldr r0, [r1, 0x70]
ldrb r0, [r0, 0x7]
cmp r0, 0
beq _0808553A
str r4, [r2]
stm r3!, {r1}
adds r6, 0x1
_0808553A:
adds r2, 0x4
subs r5, 0x1
cmp r5, 0
bge _08085526
movs r4, 0
mov r2, sp
lsls r0, r6, 2
mov r1, r8
adds r3, r0, r1
movs r5, 0x3
_0808554E:
ldr r1, [r2]
cmp r1, 0
beq _08085564
ldr r0, [r1, 0x70]
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x41
bne _08085564
str r4, [r2]
stm r3!, {r1}
adds r6, 0x1
_08085564:
adds r2, 0x4
subs r5, 0x1
cmp r5, 0
bge _0808554E
movs r3, 0
mov r2, sp
lsls r0, r6, 2
add r0, r8
movs r5, 0x3
_08085576:
ldr r1, [r2]
cmp r1, 0
beq _08085582
str r3, [r2]
stm r0!, {r1}
adds r6, 0x1
_08085582:
adds r2, 0x4
subs r5, 0x1
cmp r5, 0
bge _08085576
cmp r6, 0x3
bgt _0808559C
movs r1, 0
lsls r0, r6, 2
add r0, r8
_08085594:
stm r0!, {r1}
adds r6, 0x1
cmp r6, 0x3
ble _08085594
_0808559C:
movs r5, 0
mov r4, r8
_080855A0:
lsls r1, r5, 2
ldr r3, [r4]
cmp r3, 0
beq _080855C4
ldr r0, _080855D8
ldr r0, [r0]
adds r0, r1
ldr r2, _080855E0
adds r1, r0, r2
movs r6, 0
ldrsh r1, [r1, r6]
adds r2, 0x2
adds r0, r2
movs r6, 0
ldrsh r2, [r0, r6]
adds r0, r3, 0
bl sub_80856C8
_080855C4:
adds r4, 0x4
adds r5, 0x1
cmp r5, 0x3
ble _080855A0
add sp, 0x20
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080855D8: .4byte gDungeon
_080855DC: .4byte 0x0001357c
_080855E0: .4byte 0x0000e220
thumb_func_end sub_80854D4
.align 2, 0

View File

@@ -346,6 +346,7 @@ enum ClientType
{
CLIENT_TYPE_NONE = 0,
CLIENT_TYPE_CLIENT = 1, // Used for mission clients that need rescuing.
CLIENT_TYPE_PARTNER,
CLIENT_TYPE_DONT_MOVE = 4 // Used for Diglett in the Skarmory boss fight.
};

View File

@@ -136,9 +136,11 @@ struct Dungeon
u8 fill3A10[0x3A14 - 0x3A12];
/* 0x3A14 */ s16 bossBattleIndex;
/* 0x3A18 */ struct Tile tiles[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fillE218[0xE23C - 0xE218];
s16 unkE23C;
s16 unkE23E;
u8 fillE218[0xE220 - 0xE218];
struct Position unkE220[4];
u8 unkE230[0xE23C - 0xE230];
s16 unkE23C; // x coord of some kind
s16 unkE23E; // y coord of some kind
u8 fillE240[0xE264 - 0xE240];
/* 0xE264 */ u8 weather; // Uses the weather constants in weather.h.
u8 unkE265; // Uses the weather constants in weather.h

View File

@@ -3,6 +3,9 @@
#include "dungeon_entity.h"
struct Entity *xxx_call_GetLeader(void);
struct Entity *GetPartnerEntity(void);
void sub_80854D4(void);
struct Entity *GetEntityFromClientType(u8 entityType);
void sub_80856C8(struct Entity * pokemon, s32 x, s32 y);
void sub_80856E0(struct Entity * pokemon, s32 direction);

View File

@@ -417,7 +417,7 @@ extern void sub_8086838(u32, u32, u32);
extern void sub_80426C8(u32, u32);
extern void sub_807EAA0(u32, u32);
extern void sub_808BCE4(void);
extern void CreateJirachiWishWarpTile(void);
extern u8 sub_8098100(u32);
extern void sub_8086794();
@@ -447,7 +447,6 @@ extern u8 sub_8086AE4(u32);
extern void sub_8072008(struct Entity *, struct Entity *, s16, u32, u32);
extern struct Entity *GetPartnerEntity();
extern void sub_80869E4(struct Entity *, u32, u32, u32);
extern void sub_806CDD4(struct Entity *, u32, u32);
extern void sub_8085374();
@@ -486,7 +485,7 @@ void ZapdosScreenFlash(int param_1);
extern s32 sub_8052C68(u32, u8 *, u32 *, u32);
extern void sub_80861A8(void);
extern void sub_8045C28(struct Item *, u8 , u8 *);
extern void sub_808BD38(void);
extern void EnableJirachiWishWarpTile(void);
extern void sub_808BB3C(struct Position *);
extern void sub_8046860(struct Entity *, struct Position *, struct Item *, u32);
extern u32 sub_803D73C(u32);
@@ -641,9 +640,9 @@ void sub_8087848(void)
CopyMonsterNametoBuffer(gUnknown_202E038,MONSTER_MOLTRES);
}
void sub_80878F4(char param_1, s32 param_2)
void sub_80878F4(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xF6000000U) >> 0x18 < 3) && (param_1 == 0x9)) {
if ((param_2 == 0xA || param_2 == 0xB || param_2 == 0xC) && (param_1 == 0x9)) {
sub_8097FA8(0x7);
gDungeon->unk2 = 1;
}
@@ -1058,11 +1057,9 @@ void sub_8087FF8(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_ARTICUNO);
}
void sub_8088088(char param_1, s32 param_2)
void sub_8088088(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xF3000000U) >> 0x18 < 3) && (param_1 == 0xD)) {
if ((param_2 == 0xD || param_2 == 0xE || param_2 == 0xF) && (param_1 == 0xD)) {
sub_8097FA8(0x9);
gDungeon->unk2 = 1;
}
@@ -1372,9 +1369,9 @@ void sub_808875C(void)
CopyMonsterNametoBuffer(gUnknown_202E038 + 0x50, MONSTER_ALAKAZAM);
}
void sub_8088818(char param_1, s32 param_2)
void sub_8088818(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xEE000000U) >> 0x18 < 3) && (param_1 == 0xE)) {
if ((param_2 == 0x12 || param_2 == 0x13 || param_2 == 0x14) && (param_1 == 0xE)) {
sub_8097FA8(0xC);
gDungeon->unk2 = 1;
}
@@ -1920,9 +1917,9 @@ void sub_8089328(void)
CopyMonsterNametoBuffer(gUnknown_202E038,MONSTER_RAYQUAZA);
}
void sub_80893B4(char param_1, s32 param_2)
void sub_80893B4(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xE9000000U) >> 0x18 < 3) && (param_1 == 0xF)) {
if ((param_2 == 0x17 || param_2 == 0x18 || param_2 == 0x19) && (param_1 == 0xF)) {
sub_8097FA8(0xF);
gDungeon->unk2 = 1;
}
@@ -2094,19 +2091,19 @@ void sub_808974C(void)
sub_8085860(LeaderEntity->pos.x,LeaderEntity->pos.y + -3);
}
void sub_8089788(struct Entity *param_1, u8 param_2, s32 param_3)
void sub_8089788(struct Entity *entity, u8 param_2, u8 param_3)
{
struct Entity *iVar2;
struct Entity *monEntity;
s32 index;
u32 unk1;
unk1 = 0;
if ((((param_3 * 0x1000000) + 0xe6000000U) >> 0x18) < 2) {
if (param_3 == 0x1A || param_3 == 0x1B) {
for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++)
{
iVar2 = gDungeon->wildPokemon[index];
if ((EntityExists(iVar2) != '\0') && (iVar2 != param_1) && (iVar2->info->clientType == param_2)) {
monEntity = gDungeon->wildPokemon[index];
if ((EntityExists(monEntity)) && (monEntity != entity) && (monEntity->info->clientType == param_2)) {
return;
}
}
@@ -2231,9 +2228,9 @@ void sub_8089978(void)
CopyMonsterNametoBuffer(gUnknown_202E038,MONSTER_MEWTWO);
}
void sub_8089A00(char param_1, s32 param_2)
void sub_8089A00(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xE3000000U) >> 0x18 < 3) && (param_1 == 0x11)) {
if ((param_2 == 0x1d || param_2 == 0x1e || param_2 == 0x1f) && (param_1 == 0x11)) {
sub_8097FA8(0x13);
gDungeon->unk2 = 1;
}
@@ -2377,16 +2374,14 @@ void sub_8089C90(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_ENTEI);
}
void sub_8089CFC(char param_1,int param_2)
void sub_8089CFC(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xE0000000U) >> 0x18 < 3) && (param_1 == 0x12)) {
if ((param_2 == 0x20 || param_2 == 0x21 || param_2 == 0x22) && (param_1 == 0x12)) {
sub_8097FA8(0x15);
gDungeon->unk2 = 1;
}
}
void EnteiPreFightDialogue(void)
{
struct Entity * LeaderEntity;
@@ -2524,15 +2519,14 @@ void sub_8089F8C(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_RAIKOU);
}
void sub_8089FF0(char param_1,int param_2)
void sub_8089FF0(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xdD000000U) >> 0x18 < 3) && (param_1 == 0x13)) {
if ((param_2 == 0x23 || param_2 == 0x24 || param_2 == 0x25) && (param_1 == 0x13)) {
sub_8097FA8(0x17);
gDungeon->unk2 = 1;
}
}
void RaikouPreFightDialogue(void)
{
struct Entity * LeaderEntity;
@@ -2680,9 +2674,9 @@ void sub_808A308(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_SUICUNE);
}
void sub_808A36C(char param_1,int param_2)
void sub_808A36C(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xda000000U) >> 0x18 < 3) && (param_1 == 0x14)) {
if ((param_2 == 0x26 || param_2 == 0x27 || param_2 == 0x28) && (param_1 == 0x14)) {
sub_8097FA8(0x19);
gDungeon->unk2 = 1;
}
@@ -2844,15 +2838,14 @@ void sub_808A668(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_HO_OH);
}
void sub_808A6E8(char param_1, s32 param_2)
void sub_808A6E8(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xd7000000U) >> 0x18 < 2) && (param_1 == 0x15)) {
if ((param_2 == 0x29 || param_2 == 0x2A) && (param_1 == 0x15)) {
sub_8097FA8(0x1A);
gDungeon->unk2 = 1;
}
}
void sub_808A718(void)
{
sub_8086854();
@@ -3030,10 +3023,10 @@ void sub_808AA94(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_LATIOS);
}
void sub_808AAF0(char param_1, s32 param_2)
void sub_808AAF0(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xd5000000U) >> 0x18 < 3) && (param_1 == 0x16)) {
sub_8097FA8(0x1c);
if ((param_2 == 0x2B || param_2 == 0x2C || param_2 == 0x2D) && (param_1 == 0x16)) {
sub_8097FA8(0x1C);
gDungeon->unk2 = 1;
}
}
@@ -3501,7 +3494,7 @@ void sub_808B2F4(void)
LeaderEntity = xxx_call_GetLeader();
JirachiEntity = GetEntityFromClientType(0x1a);
DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST);
sub_808BCE4();
CreateJirachiWishWarpTile();
sub_8049ED4();
sub_80854D4();
sub_8085930(DIRECTION_NORTH);
@@ -3529,7 +3522,7 @@ void sub_808B35C(void)
else {
SetFacingDirection(JirachiEntity, DIRECTION_SOUTH);
sub_8086A3C(JirachiEntity);
sub_808BCE4();
CreateJirachiWishWarpTile();
sub_8049ED4();
}
@@ -3537,94 +3530,30 @@ void sub_808B35C(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_JIRACHI);
}
#ifdef NONMATCHING
void sub_808B3E4(u8 param_1,u8 param_2,u8 param_3)
void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3)
{
u8 uVar1;
// TODO R1 and R2 shifts are switched ordering but matches
if (((((param_2 * 0x1000000) + 0xcf000000U) >> 0x18) < 2) && (param_1 == 0x1A)){
sub_8097FA8(0x1e);
if (param_3 != 0) {
gDungeon->unk2 = 1;
if ((param_2 == 0x31 || param_2 == 0x32) && (param_1 == 0x1A)) {
sub_8097FA8(0x1E);
if(param_3 != 0)
{
gDungeon->unk2 = 1;
}
else {
uVar1 = gDungeon->unk1356C;
if (sub_80860A8(0x36) != 0) {
JirachiWish();
}
else {
sub_808B50C();
}
gDungeon->unk1356C = uVar1;
sub_8040A84();
uVar1 = gDungeon->unk1356C;
if(sub_80860A8(0x36) != 0)
{
JirachiWish();
}
else
{
sub_808B50C();
}
gDungeon->unk1356C = uVar1;
sub_8040A84();
}
}
}
#else
NAKED
void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3)
{
asm_unified(
"\tpush {r4,lr}\n"
"\tlsls r0, 24\n"
"\tlsrs r0, 24\n"
"\tlsls r1, 24\n"
"\tlsls r2, 24\n"
"\tlsrs r4, r2, 24\n"
"\tmovs r2, 0xCF\n"
"\tlsls r2, 24\n"
"\tadds r1, r2\n"
"\tlsrs r1, 24\n"
"\tcmp r1, 0x1\n"
"\tbhi _0808B44E\n"
"\tcmp r0, 0x1A\n"
"\tbne _0808B44E\n"
"\tmovs r0, 0x1E\n"
"\tbl sub_8097FA8\n"
"\tcmp r4, 0\n"
"\tbeq _0808B418\n"
"\tldr r0, _0808B414\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0x1\n"
"\tstrb r0, [r1, 0x2]\n"
"\tb _0808B44E\n"
"\t.align 2, 0\n"
"_0808B414: .4byte gDungeon\n"
"_0808B418:\n"
"\tldr r0, _0808B434\n"
"\tldr r0, [r0]\n"
"\tldr r1, _0808B438\n"
"\tadds r0, r1\n"
"\tldrb r4, [r0]\n"
"\tmovs r0, 0x36\n"
"\tbl sub_80860A8\n"
"\tlsls r0, 24\n"
"\tcmp r0, 0\n"
"\tbeq _0808B43C\n"
"\tbl JirachiWish\n"
"\tb _0808B440\n"
"\t.align 2, 0\n"
"_0808B434: .4byte gDungeon\n"
"_0808B438: .4byte 0x0001356c\n"
"_0808B43C:\n"
"\tbl sub_808B50C\n"
"_0808B440:\n"
"\tldr r0, _0808B454\n"
"\tldr r0, [r0]\n"
"\tldr r2, _0808B458\n"
"\tadds r0, r2\n"
"\tstrb r4, [r0]\n"
"\tbl sub_8040A84\n"
"_0808B44E:\n"
"\tpop {r4}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_0808B454: .4byte gDungeon\n"
"_0808B458: .4byte 0x0001356c");
}
#endif
void JirachiPreFightDialogue(void)
{
@@ -3749,7 +3678,7 @@ void JirachiWish(void)
r8 = counter + 1;
for(index = 0; index < 9; index++)
{
sub_8045C28(&auStack152[index], 0x69, 0);
sub_8045C28(&auStack152[index], ITEM_POKE, 0);
}
pos1.x = (JirachiEntity->pos.x + DungeonRandInt(3) - 1);
pos1.y = (JirachiEntity->pos.y + DungeonRandInt(3) + -1);
@@ -3867,7 +3796,7 @@ void JirachiWish(void)
sub_803E708(10,0x46);
DisplayDungeonDialogue(&gUnknown_810593C);
sub_803E708(10,0x46);
sub_808BD38();
EnableJirachiWishWarpTile();
}
void JirachiReFightDialogue(void)
@@ -3999,30 +3928,31 @@ void JirachiWishGrantDialogue(struct Entity *jirachiEntity)
JirachiWishGrantFlash();
}
void sub_808BCE4(void)
// Warp Tile is created but not enabled until the Wish is done with EnableJirachiWishWarpTile
void CreateJirachiWishWarpTile(void)
{
struct Tile *puVar1;
struct Tile *tile;
puVar1 = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E);
puVar1->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
puVar1->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
puVar1->terrainType &= ~TERRAIN_TYPE_STAIRS;
tile = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E);
tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL;
tile->terrainType &= ~TERRAIN_TYPE_STAIRS;
sub_8049884();
sub_8049B8C();
sub_8049ED4();
sub_8040A84();
}
void sub_808BD38(void)
void EnableJirachiWishWarpTile(void)
{
struct Tile *puVar1;
struct Tile *tile;
puVar1 = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E);
puVar1->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
puVar1->terrainType |= TERRAIN_TYPE_NORMAL;
puVar1->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL;
puVar1->terrainType |= TERRAIN_TYPE_STAIRS;
puVar1->unk8 = 1;
tile = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E);
tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
tile->terrainType |= TERRAIN_TYPE_NORMAL;
tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL;
tile->terrainType |= TERRAIN_TYPE_STAIRS;
tile->unk8 = 1;
sub_8049884();
sub_8049B8C();
sub_8049ED4();
@@ -4444,8 +4374,7 @@ void sub_808C5C0(void)
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_CELEBI);
}
// Dummy Celebi Fight Dialogue??
void nullsub_100(u32 r0, u32 r1, u32 r2)
void nullsub_100(u8 r0, u8 r1, u32 r2)
{
}
@@ -4878,17 +4807,17 @@ void sub_808C938(void)
sub_80855E4(sub_808C9B0);
}
void sub_808C948(struct Entity *param_1, u8 param_2)
void sub_808C948(struct Entity *entity, u8 param_2)
{
bool8 flag;
s32 index;
struct Entity *iVar2;
struct Entity *pokeEntity;
if (param_2 == 0x37) {
flag = FALSE;
for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++){
iVar2 = gDungeon->wildPokemon[index];
if ((iVar2 != param_1) && (EntityExists(iVar2) != 0)) {
pokeEntity = gDungeon->wildPokemon[index];
if ((pokeEntity != entity) && (EntityExists(pokeEntity))) {
flag = TRUE;
break;
}

View File

@@ -357,7 +357,6 @@ void sub_80848F0(void)
void DisplayPreFightDialogue(void)
{
switch(gDungeon->unk3A0D) {
case 0:
break;
@@ -545,10 +544,9 @@ void DisplayPreFightDialogue(void)
sub_8097FF8();
}
void sub_8084E00(struct Entity *param_1,char param_2,char param_3)
void sub_8084E00(struct Entity *entity, u8 param_2, u8 param_3)
{
if (param_2 != '\0') {
if (param_2 != 0) {
switch(gDungeon->unk3A0D) {
case 0:
break;
@@ -587,7 +585,7 @@ void sub_8084E00(struct Entity *param_1,char param_2,char param_3)
break;
case 0x1a:
case 0x1b:
sub_8089788(param_1,param_2,gDungeon->unk3A0D);
sub_8089788(entity,param_2,gDungeon->unk3A0D);
break;
case 0x1d:
case 0x1e:
@@ -619,13 +617,13 @@ void sub_8084E00(struct Entity *param_1,char param_2,char param_3)
sub_808AAF0(param_2,gDungeon->unk3A0D);
break;
case 0x2e:
sub_808AE54(param_2,gDungeon->unk3A0D,&param_1->pos.x);
sub_808AE54(param_2,gDungeon->unk3A0D,&entity->pos.x);
break;
case 0x2f:
sub_808AEC8(param_2,gDungeon->unk3A0D,&param_1->pos.x);
sub_808AEC8(param_2,gDungeon->unk3A0D,&entity->pos.x);
break;
case 0x30:
sub_808AF3C(param_2,gDungeon->unk3A0D,&param_1->pos.x);
sub_808AF3C(param_2,gDungeon->unk3A0D,&entity->pos.x);
break;
case 0x31:
case 0x32:
@@ -644,7 +642,7 @@ void sub_8084E00(struct Entity *param_1,char param_2,char param_3)
nullsub_100(param_2,gDungeon->unk3A0D,param_3);
break;
case 0x37:
sub_808C948(param_1,gDungeon->unk3A0D);
sub_808C948(entity,gDungeon->unk3A0D);
break;
case 0x38:
case 0x39:
@@ -653,7 +651,7 @@ void sub_8084E00(struct Entity *param_1,char param_2,char param_3)
case 0x3C:
break;
}
if ((param_3 == '\0') && (gDungeon->unk2 != '\0')) {
if ((param_3 == 0) && (gDungeon->unk2 != 0)) {
DungeonStartNewBGM(999);
}
}

View File

@@ -1,8 +1,9 @@
#include "global.h"
#include "constants/direction.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_util_1.h"
#include "random.h"
#include "constants/direction.h"
struct unkStruct_202F3D0
{
@@ -19,12 +20,10 @@ EWRAM_DATA struct unkStruct_202F3D0 gUnknown_202F3D0;
s8 sub_8002984(s8, u8);
void sub_803E708(u32, u32);
void sub_80869E4(struct Entity *entity, u32, u8, s8);
extern void sub_80859F0(u32);
extern void sub_803E46C(u32);
extern void sub_803E9D0(void);
extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32);
extern void PlaySoundEffect(u32);
extern struct Entity *xxx_call_GetLeader(void);
void SpriteLookAroundEffect(struct Entity *entity);
extern void DisplayDungeonDialogue(u32);
void sub_8086494();
@@ -40,7 +39,6 @@ extern s32 GetCameraXPos(void);
extern s32 GetCameraYPos(void);
extern void sub_803F878(u32, u32);
extern void sub_8086384(struct Entity *entity);
extern void sub_8085930(u32);
extern void IncreaseEntityPixelPos(struct Entity *, u32, u32);
extern void sub_806CE68(struct Entity *, u32);
extern void sub_806CDD4(struct Entity *, u8, u32);
@@ -60,7 +58,7 @@ void sub_80862DC(struct Entity *entity)
{
struct Position32 pos;
pos.x = entity->pixelPos.x;
pos.y = entity->pixelPos.y + (0xE0 << 6);
pos.y = entity->pixelPos.y + 0x3800;
sub_804535C(entity, &pos);
sub_806CDD4(entity, 0, DIRECTION_NORTH);
@@ -71,7 +69,7 @@ void sub_8086310(struct Entity *entity)
{
struct Position32 pos;
pos.x = entity->pixelPos.x;
pos.y = entity->pixelPos.y + (0x90 << 8);
pos.y = entity->pixelPos.y + 0x9000;
sub_804535C(entity, &pos);
sub_806CE68(entity, DIRECTION_SOUTH);
@@ -82,8 +80,8 @@ void sub_8086310(struct Entity *entity)
void sub_8086348(struct Entity *entity)
{
struct Position32 pos;
pos.x = entity->pixelPos.x + (0xF0 << 7);
pos.y = entity->pixelPos.y + 0xffffe000;
pos.x = entity->pixelPos.x + 0x7800;
pos.y = entity->pixelPos.y - 0x2000;
sub_804535C(entity, &pos);
sub_806CDD4(entity, 0, DIRECTION_WEST);
@@ -93,7 +91,7 @@ void sub_8086348(struct Entity *entity)
void sub_8086384(struct Entity *entity)
{
struct Position32 pos;
pos.x = entity->pixelPos.x + (0xF0 << 7);
pos.x = entity->pixelPos.x + 0x7800;
pos.y = entity->pixelPos.y;
sub_804535C(entity, &pos);
@@ -133,17 +131,17 @@ void sub_8086404(struct Entity *entity)
void sub_8086410(struct Entity *entity)
{
IncreaseEntityPixelPos(entity, 0, 0xffffff00);
IncreaseEntityPixelPos(entity, 0, -0x100);
}
void sub_8086424(struct Entity *entity)
{
IncreaseEntityPixelPos(entity, 0, 0x80 << 1);
IncreaseEntityPixelPos(entity, 0, 0x100);
}
void sub_8086434(struct Entity *entity)
{
IncreaseEntityPixelPos(entity, 0xffffff00, 0);
IncreaseEntityPixelPos(entity, -0x100, 0);
}
void sub_8086448(void)
@@ -306,12 +304,12 @@ void sub_8086690(void)
}
void sub_80866C4(u32 entity)
void sub_80866C4(u32 dialogue)
{
SpriteLookAroundEffect(xxx_call_GetLeader());
sub_803E708(0xA, 0x46);
DisplayDungeonDialogue(entity);
DisplayDungeonDialogue(dialogue);
sub_803E708(0xA, 0x46);
sub_8086494();
gDungeon->unk2 = 1;

View File

@@ -10,15 +10,12 @@
#include "dungeon_util_1.h"
#include "dungeon_util.h"
extern struct Entity *GetPartnerEntity();
extern struct Entity *xxx_call_GetLeader(void);
extern void SetDefaultIQSkills(u8 *param_1, u8 param_2);
extern void sub_8097FF8(void);
extern u8 sub_8044B28(void);
extern u8 HasRecruitedMon(u32);
extern u8 gUnknown_202E038[];
extern void sub_8085374();
extern void sub_80854D4();
extern void sub_80855E4(void *);
extern void sub_8068FE0(struct Entity *, u32, u32);
extern void sub_8097FA8(u32);
@@ -306,90 +303,35 @@ void sub_8086F00(void)
CopyMonsterNametoBuffer(gUnknown_202E038 + 0xA0, MONSTER_CATERPIE);
}
// https://decomp.me/scratch/bLnx3 (94.46 %)
#ifdef NONMATCHING
void sub_8086F54(u8 param_1, s32 param_2)
// From @jiangzhengwenjz:
// Matches this way for -O2 but can match w/o this hack on -O1
// https://decomp.me/scratch/BTqWo
void sub_8086F54(u8 param_1, u8 param_2)
{
struct Entity *entity;
s32 index;
u32 unk1;
register u32 param_1_u8 asm("r6") = param_1;
unk1 = 0;
u32 unk1 = 0;
if ((((param_2 * 0x1000000) + 0xfc000000U) >> 0x18) < 2) {
if (param_2 == 4 || param_2 == 5) {
void *labels[2];
labels[0] = labels[1] = &&label;
for(index = 0; index < 0x10; index++)
{
entity = gDungeon->wildPokemon[index];
if ((EntityExists(entity)) && (entity->info->clientType != param_1_u8)) {
if ((EntityExists(entity)) && (entity->info->clientType != param_1)) {
return;
}
}
if(!unk1)
{
sub_8097FA8(3);
gDungeon->unk2 = 1;
sub_8097FA8(3);
label:
gDungeon->unk2 = 1;
}
}
}
#else
NAKED
void sub_8086F54(u8 param_1, s32 param_2)
{
asm_unified(
"\tpush {r4-r6,lr}\n"
"\tlsls r0, 24\n"
"\tlsrs r6, r0, 24\n"
"\tlsls r1, 24\n"
"\tmovs r0, 0xFC\n"
"\tlsls r0, 24\n"
"\tadds r1, r0\n"
"\tlsrs r1, 24\n"
"\tcmp r1, 0x1\n"
"\tbhi _08086FA8\n"
"\tmovs r5, 0\n"
"_08086F6A:\n"
"\tldr r0, _08086FB0\n"
"\tldr r0, [r0]\n"
"\tlsls r1, r5, 2\n"
"\tldr r2, _08086FB4\n"
"\tadds r0, r2\n"
"\tadds r0, r1\n"
"\tldr r4, [r0]\n"
"\tadds r0, r4, 0\n"
"\tbl EntityExists\n"
"\tlsls r0, 24\n"
"\tcmp r0, 0\n"
"\tbeq _08086F8E\n"
"\tldr r0, [r4, 0x70]\n"
"\tadds r0, 0xA4\n"
"\tldrb r0, [r0]\n"
"\tcmp r0, r6\n"
"\tbne _08086FA8\n"
"_08086F8E:\n"
"\tadds r5, 0x1\n"
"\tcmp r5, 0xF\n"
"\tble _08086F6A\n"
"\tmovs r0, 0\n"
"\tcmp r0, 0\n"
"\tbne _08086FA8\n"
"\tmovs r0, 0x3\n"
"\tbl sub_8097FA8\n"
"\tldr r0, _08086FB0\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0x1\n"
"\tstrb r0, [r1, 0x2]\n"
"_08086FA8:\n"
"\tpop {r4-r6}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_08086FB0: .4byte gDungeon\n"
"_08086FB4: .4byte 0x0001358c");
}
#endif
void TeamMeaniesPreFightDialogue(void)
{
@@ -536,11 +478,10 @@ void sub_808729C(void)
CopyMonsterNametoBuffer(gUnknown_202E038 + 0x50, MONSTER_ZAPDOS);
}
void sub_8087334(char param_1, s32 param_2)
void sub_8087334(u8 param_1, u8 param_2)
{
if ((((param_2 * 0x1000000) + 0xF9000000U) >> 0x18 < 3) && (param_1 == 8)) {
if ((param_2 == 7 || param_2 == 8 || param_2 == 9) && (param_1 == 8)) {
sub_8097FA8(5);
gDungeon->unk2 = 1;
}
}

View File

@@ -2,7 +2,9 @@
#include "dungeon_util_1.h"
#include "constants/direction.h"
#include "constants/dungeon.h"
#include "dungeon_global_data.h"
#include "dungeon_leader.h"
#include "dungeon_util.h"
#include "random.h"
@@ -21,10 +23,97 @@ extern void sub_8068FE0(struct Entity *, u32, u8 *);
extern void sub_80457DC(u8 *);
extern void sub_80861D4(struct Entity *, u32, s32 direction);
extern void sub_80694C0(struct Entity *, s32, s32, u32);
extern struct Entity *GetPartnerEntity();
typedef void (*DungeonCallback)(struct Entity *);
struct Entity *xxx_call_GetLeader(void)
{
return GetLeader();
}
struct Entity *GetPartnerEntity(void)
{
s32 counter;
struct Entity *entity;
for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++)
{
entity = gDungeon->teamPokemon[counter];
if(EntityExists(entity) && entity->info->joinedAt == DUNGEON_JOIN_LOCATION_PARTNER)
{
return entity;
}
}
return GetEntityFromClientType(CLIENT_TYPE_PARTNER);
}
void sub_80854D4(void)
{
struct Entity *stack1[MAX_TEAM_MEMBERS];
struct Entity *stack2[MAX_TEAM_MEMBERS];
s32 counter = 0;
s32 index;
struct Entity *entity;
struct Entity *entity2;
struct Entity *entity3;
struct Entity *entity4;
struct Entity *entity5;
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity = gDungeon->teamPokemon[index];
if(EntityExists(entity))
{
stack1[counter] = entity;
counter++;
}
}
for(; counter < MAX_TEAM_MEMBERS; counter++)
{
stack1[counter] = NULL;
}
counter = 0;
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity2 = stack1[index];
if(entity2 != NULL && entity2->info->isTeamLeader)
{
stack1[index] = NULL;
stack2[counter] = entity2;
counter++;
}
}
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity3 = stack1[index];
if(entity3 != NULL && entity3->info->joinedAt == DUNGEON_JOIN_LOCATION_PARTNER)
{
stack1[index] = NULL;
stack2[counter] = entity3;
counter++;
}
}
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity4 = stack1[index];
if(entity4 != NULL)
{
stack1[index] = NULL;
stack2[counter] = entity4;
counter++;
}
}
for(; counter < MAX_TEAM_MEMBERS; counter++)
{
stack2[counter] = NULL;
}
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity5 = stack2[index];
if(entity5 != NULL)
sub_80856C8(entity5, gDungeon->unkE220[index].x, gDungeon->unkE220[index].y);
}
}
void sub_80855E4(DungeonCallback func)
{
bool8 flag;
@@ -37,7 +126,7 @@ void sub_80855E4(DungeonCallback func)
{
entity = gDungeon->teamPokemon[index];
if (EntityExists(entity)) {
if (entity->info->joinedAt == 0x41) {
if (entity->info->joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) {
flag = TRUE;
}
func(entity);
@@ -116,7 +205,7 @@ void sub_8085764(void)
for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++)
{
entity = gDungeon->wildPokemon[index];
if ((EntityExists(entity)) && (entity->info->clientType == 2)) {
if ((EntityExists(entity)) && (entity->info->clientType == CLIENT_TYPE_PARTNER)) {
sub_8068FE0(entity,0x207,auStack128);
}
}
@@ -215,7 +304,7 @@ void sub_8085930(s32 direction)
entity = gDungeon->wildPokemon[index];
if(EntityExists(entity))
{
if(entity->info->clientType == 2)
if(entity->info->clientType == CLIENT_TYPE_PARTNER)
{
if(direction >= NUM_DIRECTIONS)
{
@@ -291,7 +380,7 @@ bool8 IsMovingClient(struct Entity *pokemon)
case 0x24:
return TRUE;
case CLIENT_TYPE_NONE:
case 0x2:
case CLIENT_TYPE_PARTNER:
case CLIENT_TYPE_DONT_MOVE:
case 0xA:
case 0xB: