more decomp and doc

This commit is contained in:
Seth Barberee 2024-08-01 21:04:34 -07:00
parent 23c76bc334
commit 18ff91141c
11 changed files with 121 additions and 170 deletions

View File

@ -2594,103 +2594,4 @@ _08069D0E:
bx r0
thumb_func_end sub_8069844
thumb_func_start sub_8069D18
sub_8069D18:
push {r4,r5,lr}
ldr r3, [r1, 0x70]
ldr r4, _08069D48
adds r3, 0x46
ldrb r2, [r3]
lsls r2, 2
adds r2, r4
ldrh r2, [r2]
ldrh r5, [r1, 0x4]
adds r2, r5
strh r2, [r0]
ldrb r2, [r3]
lsls r2, 2
adds r2, r4
ldrh r2, [r2, 0x2]
ldrh r1, [r1, 0x6]
adds r2, r1
strh r2, [r0, 0x2]
ldrb r1, [r3]
movs r0, 0x1
ands r0, r1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_08069D48: .4byte gAdjacentTileOffsets
thumb_func_end sub_8069D18
thumb_func_start sub_8069D4C
sub_8069D4C:
push {r4-r6,lr}
sub sp, 0xC
adds r5, r0, 0
ldr r4, [r1, 0x70]
ldrh r0, [r4, 0x2]
strh r0, [r5]
ldr r0, [r1, 0x4]
str r0, [r5, 0x4]
adds r0, r4, 0
adds r0, 0xF7
ldrb r0, [r0]
cmp r0, 0
beq _08069D6A
ldrh r0, [r4, 0x12]
b _08069D6C
_08069D6A:
ldrh r0, [r4, 0x10]
_08069D6C:
strh r0, [r5, 0x8]
ldrb r0, [r4, 0x9]
strh r0, [r5, 0xE]
movs r0, 0x2
ldrsh r1, [r4, r0]
ldrb r2, [r4, 0x9]
mov r0, sp
bl GetPokemonLevelData
ldr r0, [sp]
str r0, [r5, 0x10]
ldrb r0, [r4, 0x14]
strb r0, [r5, 0xA]
ldrb r0, [r4, 0x15]
strb r0, [r5, 0xB]
ldrb r0, [r4, 0x16]
strb r0, [r5, 0xC]
ldrb r0, [r4, 0x17]
strb r0, [r5, 0xD]
ldr r0, [r4, 0x60]
str r0, [r5, 0x1C]
adds r1, r5, 0
adds r1, 0x20
movs r2, 0x8C
lsls r2, 1
adds r0, r4, r2
ldm r0!, {r2,r3,r6}
stm r1!, {r2,r3,r6}
ldm r0!, {r2,r3,r6}
stm r1!, {r2,r3,r6}
ldm r0!, {r2,r3,r6}
stm r1!, {r2,r3,r6}
movs r3, 0x9E
lsls r3, 1
adds r0, r4, r3
ldr r0, [r0]
str r0, [r5, 0x14]
movs r6, 0xA0
lsls r6, 1
adds r0, r4, r6
ldr r0, [r0]
str r0, [r5, 0x18]
ldr r0, [r4, 0x3C]
str r0, [r5, 0x44]
add sp, 0xC
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_8069D4C
.align 2,0

View File

@ -5,45 +5,6 @@
.text
thumb_func_start sub_80861B8
sub_80861B8:
push {r4,r5,lr}
adds r4, r1, 0
lsls r4, 24
lsrs r4, 24
ldr r5, [r0, 0x70]
adds r1, r4, 0
bl sub_806CDD4
adds r5, 0xFE
strb r4, [r5]
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_80861B8
thumb_func_start sub_80861D4
sub_80861D4:
push {r4,lr}
adds r4, r0, 0
lsls r1, 24
lsrs r1, 24
bl sub_806CDD4
adds r0, r4, 0
bl sub_80861EC
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_80861D4
thumb_func_start sub_80861EC
sub_80861EC:
ldr r0, [r0, 0x70]
adds r0, 0xFE
movs r1, 0x63
strb r1, [r0]
bx lr
thumb_func_end sub_80861EC
thumb_func_start sub_80861F8
sub_80861F8:
push {r4-r7,lr}

View File

@ -7,8 +7,8 @@ void sub_806CC10(void);
void sub_806CC70(void);
void sub_806CCB4(Entity *entity, u8);
void sub_806CD90(void);
void sub_806CDD4(Entity *entity, u8, u32);
void sub_806CDFC(Entity *entity, u8, u32);
void sub_806CDD4(Entity *entity, u8, u32 direction);
void sub_806CDFC(Entity *entity, u8, u32 direction);
void sub_806CE34(Entity *entity, u32 newDir);
void sub_806CE68(Entity *entity, u32 newDir);
void sub_806CE94(Entity *entity, u32 newDir);
@ -19,4 +19,4 @@ u8 sub_806CF54(Entity *entity);
void sub_806CF60(void);
u32 sub_806CF98(Entity *entity);
#endif // GUARD_CODE_806CD90_H
#endif // GUARD_CODE_806CD90_H

View File

@ -4,5 +4,7 @@
#include "structs/dungeon_entity.h"
void sub_80861A8(Entity *a0);
void sub_80861B8(Entity *a0, u8 r1, s32 direction);
void sub_80861D4(Entity *a0, u8 r1, s32 direction);
#endif

View File

@ -246,6 +246,7 @@ SECTIONS {
asm/code_8066D04.o(.text);
src/code_805D8C8.o(.text);
asm/code_805D8C8_1.o(.text);
src/code_8069D4C.o(.text);
src/targeting.o(.text);
src/code_8069E0C.o(.text);
asm/code_8069E0C.o(.text);

View File

@ -327,7 +327,6 @@ extern void sub_8068FE0(Entity *, u32, u32);
extern void sub_8086448(void);
extern void sub_8042B0C(Entity *);
extern u8 sub_806FD18(Entity *);
extern void sub_80861D4(Entity *, u32, s32 direction);
extern void sub_806FDF4(Entity *, Entity *, Entity **);
extern u32 sub_80861F8(u32, Entity *, u32);
extern s32 GetCameraXPos();
@ -363,7 +362,6 @@ extern void sub_806BFC0(EntityInfo *, u32);
extern void sub_808BBA8(Entity * );
extern void sub_8041888(u32);
extern void sub_80861B8(Entity *, u32, u32);
extern void DisplayDungeonDialogue(const u8 *r0);
extern u32 sub_80861F8(u32, Entity *, u32);
@ -1259,7 +1257,7 @@ void sub_808862C(void)
sub_8085930(DIRECTION_NORTH);
sub_80855E4(sub_8086A3C);
SetFacingDirection(AlakazamEntity, DIRECTION_NORTH);
sub_80861D4(AlakazamEntity,0xd,4);
sub_80861D4(AlakazamEntity,0xd,DIRECTION_NORTH);
SetFacingDirection(GroudonEntity, DIRECTION_SOUTH);
sub_8086A3C(GroudonEntity);
sub_8085860(LeaderEntity->pos.x,LeaderEntity->pos.y -3);
@ -1315,7 +1313,7 @@ void sub_808875C(void)
else {
sub_8072008(GroudonEntity,GroudonEntity,gUnknown_80F57D2,0,0);
SetFacingDirection(GroudonEntity, DIRECTION_SOUTH);
sub_80861D4(GroudonEntity,0xf,0);
sub_80861D4(GroudonEntity,0xf,DIRECTION_SOUTH);
}
sub_8085860(LeaderEntity->pos.x,LeaderEntity->pos.y - 3);
CopyMonsterNametoBuffer(gUnknown_202E038, MONSTER_GROUDON);
@ -1375,7 +1373,7 @@ void GroudonPreFightDialogue(void)
sub_803E708(10,0x46);
sub_808682C();
sub_803E708(0x3c,0x46);
sub_80861B8(AlakazamEntity,6,4);
sub_80861B8(AlakazamEntity,6,DIRECTION_NORTH);
PlaySoundEffect(0x205);
sub_8086738();
sub_8068FE0(AlakazamEntity,0x21c,0);
@ -1498,7 +1496,7 @@ void SceneGroudonMovement(Entity * GroudonEntity)
sub_803E46C(0x46);
}
sub_80856C8(GroudonEntity,GroudonEntity->pos.x,GroudonEntity->pos.y + 1);
sub_80861D4(GroudonEntity,0xf,0);
sub_80861D4(GroudonEntity,0xf,DIRECTION_SOUTH);
sub_803E708(10,0x46);
sub_808682C();
sub_8085930(DIRECTION_NORTH);
@ -3465,7 +3463,7 @@ void sub_808B50C(void)
sub_8041888(0);
JirachiEntity->info->unk15C = 1;
JirachiEntity->info->unk15E = 0;
sub_80861B8(JirachiEntity,0xe,0);
sub_80861B8(JirachiEntity,0xe,DIRECTION_SOUTH);
DungeonFadeOutBGM(0x1e);
sub_803E708(0x1e,70);
// Fwaaaahhhh
@ -3506,7 +3504,7 @@ void JirachiWish(void)
sub_8041888(0);
JirachiEntity->info->unk15C = 1;
JirachiEntity->info->unk15E = 0;
sub_80861B8(JirachiEntity,0xe,0);
sub_80861B8(JirachiEntity,0xe,DIRECTION_SOUTH);
sub_80855E4(sub_80861A8);
gDungeon->unk1356C = 1;
DungeonFadeOutBGM(0x1e);
@ -3744,7 +3742,7 @@ void JirachiDropInEffect(Entity *jirachiEntity)
sub_80861F8(0x1b,jirachiEntity,0);
sub_8086A54(jirachiEntity);
sub_80861B8(jirachiEntity,0xe,0);
sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH);
iVar1 = 0xa000;
iVar2 = 0x200;
PlaySoundEffect(0x1f8);
@ -3912,16 +3910,16 @@ void LugiaPreFightDialogue(void)
sub_803E708(10,0x46);
DisplayDungeonDialogue(gLugiaPreFightDialogue_4);
PlaySoundEffect(0x1f8);
sub_80861D4(LugiaEntity,0xd,0);
sub_80861D4(LugiaEntity,0xd,DIRECTION_SOUTH);
sub_803E708(0x2b,0x46);
sub_80861B8(LugiaEntity,0,0);
sub_80861B8(LugiaEntity,0,DIRECTION_SOUTH);
DisplayDungeonDialogue(gLugiaPreFightDialogue_5);
LugiaScreenFlash();
DisplayDungeonDialogue(gLugiaPreFightDialogue_6);
LugiaScreenFlash2();
SetDungeonBGColorRGB(0xffffff06,0xffffff06,0xffffff06,1,0);
DungeonStopBGM();
sub_80861D4(LugiaEntity,7,0);
sub_80861D4(LugiaEntity,7,DIRECTION_SOUTH);
DisplayDungeonDialogue(gLugiaPreFightDialogue_7);
LugiaScreenFlash();
SetupBossFightHP(LugiaEntity,800,MUS_BATTLE_WITH_RAYQUAZA);
@ -4308,7 +4306,7 @@ void CelebiJoinDialogue(void)
}
DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST);
PlaySoundEffect(0x1c7);
sub_80861D4(CelebiEntity,0xd,0);
sub_80861D4(CelebiEntity,0xd,DIRECTION_SOUTH);
sub_803E708(0x37,0x46);
PlaySoundEffect(0x1d5);
sub_803E708(0x1a,0x46);
@ -4321,7 +4319,7 @@ void CelebiJoinDialogue(void)
DisplayDungeonDialogue(gCelebiJoinDialogue_5);
sub_803E708(10,0x46);
PlaySoundEffect(0x1c7);
sub_80861D4(CelebiEntity,0xd,0);
sub_80861D4(CelebiEntity,0xd,DIRECTION_SOUTH);
sub_803E708(0x37,0x46);
PlaySoundEffect(0x1d5);
sub_803E708(0x1a,0x46);

View File

@ -2445,11 +2445,11 @@ void sub_805E738(Entity *a0)
// What???
for (i = 0; i < 1; i++) {
bool8 r9 = FALSE;
u32 r5 = entityInfo->action.direction;
r5++;
for (j = 1; j < 8; j++, r5++) {
r5 &= 7;
tile = GetTile(a0->pos.x + gAdjacentTileOffsets[r5].x, a0->pos.y + gAdjacentTileOffsets[r5].y);
u32 direction = entityInfo->action.direction;
direction++;
for (j = 1; j < 8; j++, direction++) {
direction &= DIRECTION_MASK;
tile = GetTile(a0->pos.x + gAdjacentTileOffsets[direction].x, a0->pos.y + gAdjacentTileOffsets[direction].y);
if (tile->monster != NULL && GetEntityType(tile->monster) == ENTITY_MONSTER) {
EntityInfo *tileMonsterInfo = tile->monster->info;
if (CanSeeTarget(a0, tile->monster)) {
@ -2461,8 +2461,8 @@ void sub_805E738(Entity *a0)
}
}
if (r9) {
a0->info->action.direction = r5 & 7;
sub_806CDD4(a0, sub_806CEBC(a0), r5);
a0->info->action.direction = direction & DIRECTION_MASK;
sub_806CDD4(a0, sub_806CEBC(a0), direction);
break;
}
}

64
src/code_8069D4C.c Normal file
View File

@ -0,0 +1,64 @@
#include "global.h"
#include "pokemon_mid.h"
#include "dungeon_util.h"
struct unkStruct_8069D4C
{
s16 id;
Position pos;
s16 HP;
u8 atk;
u8 spAtk;
u8 def;
u8 spDef;
u16 level;
u32 exp;
u32 belly;
u32 maxBelly;
Item heldItem;
Move moves[MAX_MON_MOVES];
u32 unk40; // strugglemoveFlags?
HiddenPower hiddenPower;
};
u32 sub_8069D18(Position *pos,Entity *entity)
{
EntityInfo *info;
info = entity->info;
pos->x = (entity->pos).x + gAdjacentTileOffsets[(info->action).direction].x;
pos->y = (entity->pos).y + gAdjacentTileOffsets[(info->action).direction].y;
return info->action.direction & 1;
}
void sub_8069D4C(struct unkStruct_8069D4C *r0, Entity *target)
{
EntityInfo *info;
LevelData leveldata;
info = target->info;
r0->id = info->id;
r0->pos = target->pos;
if(info->bossFlag)
r0->HP = info->originalHP;
else
r0->HP = info->maxHPStat;
r0->level = info->level;
GetPokemonLevelData(&leveldata, info->id, info->level);
r0->exp = leveldata.expRequired;
r0->atk = info->atk;
r0->spAtk = info->spAtk;
r0->def = info->def;
r0->spDef = info->spDef;
r0->heldItem = info->heldItem;
memcpy(r0->moves, info->moves, sizeof(r0->moves) + sizeof(r0->unk40));
r0->belly = info->belly;
r0->maxBelly = info->maxBelly;
r0->hiddenPower = info->hiddenPower;
}

View File

@ -89,22 +89,22 @@ void sub_806CD90(void)
}
}
void sub_806CDD4(Entity *entity, u8 a1, u32 a2)
void sub_806CDD4(Entity *entity, u8 a1, u32 direction)
{
if (GetEntityType(entity) == ENTITY_MONSTER) {
entity->unk6A = a1;
if (a2 < NUM_DIRECTIONS)
entity->direction = a2;
if (direction < NUM_DIRECTIONS)
entity->direction = direction;
}
}
void sub_806CDFC(Entity *entity, u8 a1, u32 a2)
void sub_806CDFC(Entity *entity, u8 a1, u32 direction)
{
if (GetEntityType(entity) == ENTITY_MONSTER) {
if (entity->unk6B == a1 && entity->direction2 == a2)
if (entity->unk6B == a1 && entity->direction2 == direction)
return;
sub_806CDD4(entity, a1, a2);
sub_806CDD4(entity, a1, direction);
}
}

View File

@ -1,9 +1,33 @@
#include "global.h"
#include "constants/direction.h"
#include "code_80861A8.h"
#include "code_806CD90.h"
static void sub_80861EC(Entity *);
void sub_80861A8(Entity *a0)
{
sub_806CDD4(a0, 0, 8);
sub_806CDD4(a0, 0, NUM_DIRECTIONS);
}
void sub_80861B8(Entity *a0, u8 r1, s32 direction)
{
EntityInfo *info;
info = a0->info;
sub_806CDD4(a0, r1, direction);
info->unkFE = r1;
}
void sub_80861D4(Entity *a0, u8 r1, s32 direction)
{
sub_806CDD4(a0, r1, direction);
sub_80861EC(a0);
}
void sub_80861EC(Entity *a0)
{
a0->info->unkFE = 0x63;
}

View File

@ -6,6 +6,7 @@
#include "code_806CD90.h"
#include "constants/direction.h"
#include "constants/dungeon.h"
#include "code_80861A8.h"
#include "dungeon_leader.h"
#include "dungeon_util.h"
#include "random.h"
@ -21,7 +22,6 @@ extern void sub_803F878(s32, s32);
extern void sub_8068FE0(Entity *, u32, Entity*);
extern void sub_80457DC(Entity *);
extern void sub_80861D4(Entity *, u32, s32 direction);
extern void sub_80694C0(Entity *, s32, s32, u32);