decomping decomp

This commit is contained in:
Seth Barberee 2022-05-20 16:04:12 -07:00
parent 773510c329
commit 3a467af07a
3 changed files with 100 additions and 196 deletions

View File

@ -5,201 +5,6 @@
.text
thumb_func_start sub_806CEBC
sub_806CEBC:
push {lr}
ldr r0, [r0, 0x70]
adds r1, r0, 0
adds r0, 0xA8
ldrb r0, [r0]
cmp r0, 0x1
beq _0806CED2
cmp r0, 0x5
beq _0806CED2
cmp r0, 0x3
bne _0806CEE8
_0806CED2:
movs r2, 0x4
ldrsh r0, [r1, r2]
cmp r0, 0xB9
bne _0806CEE4
adds r0, r1, 0
adds r0, 0xA9
ldrb r0, [r0]
cmp r0, 0x7F
beq _0806CEF2
_0806CEE4:
movs r0, 0x5
b _0806CEF8
_0806CEE8:
adds r0, r1, 0
adds r0, 0xC0
ldrb r0, [r0]
cmp r0, 0x1
beq _0806CEF6
_0806CEF2:
movs r0, 0x7
b _0806CEF8
_0806CEF6:
movs r0, 0xB
_0806CEF8:
pop {r1}
bx r1
thumb_func_end sub_806CEBC
thumb_func_start sub_806CEFC
sub_806CEFC:
push {r4,lr}
adds r4, r1, 0
ldr r2, [r0, 0x70]
movs r3, 0x7
ands r1, r3
adds r2, 0x46
strb r1, [r2]
movs r1, 0x7
ands r1, r4
bl sub_806CE68
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_806CEFC
thumb_func_start sub_806CF18
sub_806CF18:
push {r4-r6,lr}
adds r4, r0, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _0806CF4C
ldr r6, [r4, 0x70]
movs r5, 0
b _0806CF2E
_0806CF2C:
adds r5, 0x1
_0806CF2E:
cmp r5, 0x63
bgt _0806CF4C
movs r0, 0x21
bl sub_803E46C
movs r1, 0x4
ldrsh r0, [r6, r1]
adds r1, r4, 0
adds r1, 0x6B
ldrb r1, [r1]
bl sub_808DA44
lsls r0, 24
cmp r0, 0
bne _0806CF2C
_0806CF4C:
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_806CF18
thumb_func_start sub_806CF54
sub_806CF54:
ldr r0, [r0, 0x70]
movs r1, 0x81
lsls r1, 2
adds r0, r1
ldrb r0, [r0]
bx lr
thumb_func_end sub_806CF54
thumb_func_start sub_806CF60
sub_806CF60:
push {r4,r5,lr}
movs r5, 0
_0806CF64:
ldr r0, _0806CF90
ldr r0, [r0]
lsls r1, r5, 2
ldr r2, _0806CF94
adds r0, r2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _0806CF84
adds r0, r4, 0
bl sub_806CF98
_0806CF84:
adds r5, 0x1
cmp r5, 0x13
ble _0806CF64
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_0806CF90: .4byte gDungeonGlobalData
_0806CF94: .4byte 0x000135cc
thumb_func_end sub_806CF60
thumb_func_start sub_806CF98
sub_806CF98:
push {r4-r7,lr}
adds r4, r0, 0
bl GetMapTileForDungeonEntity_2
ldrh r0, [r0]
movs r5, 0x3
ands r5, r0
adds r6, r5, 0
ldr r7, [r4, 0x70]
movs r1, 0x4
ldrsh r0, [r7, r1]
bl GetShadowSize
lsls r0, 24
lsrs r4, r0, 24
cmp r5, 0x3
bne _0806CFBE
movs r0, 0x6
b _0806CFF8
_0806CFBE:
cmp r5, 0x1
bne _0806CFCE
bl IsWaterTileset
lsls r0, 24
cmp r0, 0
beq _0806CFEE
b _0806CFE8
_0806CFCE:
cmp r6, 0x2
bne _0806CFEE
ldr r1, _0806D000
ldr r0, _0806D004
ldr r0, [r0]
ldr r2, _0806D008
adds r0, r2
movs r2, 0
ldrsh r0, [r0, r2]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
beq _0806CFEE
_0806CFE8:
ldr r0, _0806D00C
adds r0, r4, r0
ldrb r4, [r0]
_0806CFEE:
movs r1, 0x81
lsls r1, 2
adds r0, r7, r1
strb r4, [r0]
adds r0, r4, 0
_0806CFF8:
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0806D000: .4byte gDungeonWaterType
_0806D004: .4byte gDungeonGlobalData
_0806D008: .4byte 0x00003a0e
_0806D00C: .4byte gUnknown_8106EEF
thumb_func_end sub_806CF98
thumb_func_start sub_806D010
sub_806D010:
push {r4-r7,lr}

View File

@ -220,7 +220,7 @@ struct DungeonEntityData
/* 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.
/* 0x200 */ u32 statusSprites;
u32 unk204;
u8 unk204;
};
// Used for Pokémon, items, and traps.

View File

@ -1,11 +1,20 @@
#include "global.h"
#include "constants/direction.h"
#include "constants/status.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_util.h"
#include "pokemon.h"
#include "tile_types.h"
extern u8 sub_806CEBC(struct DungeonEntity *);
extern void sub_806CCB4(struct DungeonEntity *, u8);
extern void sub_803E46C(u32);
extern bool8 sub_808DA44(s32 a1_, u32 a2_);
extern u32 sub_806CF98(struct DungeonEntity *);
extern const u8 gUnknown_8106EEF[];
extern const u8 gDungeonWaterType[];
void sub_806CD90(void)
{
@ -83,3 +92,93 @@ void sub_806CE94(struct DungeonEntity *r0, u32 newDir)
}
}
}
u8 sub_806CEBC(struct DungeonEntity *param_1)
{
u8 sleepStatus;
struct DungeonEntityData * iVar2;
struct DungeonEntityData * iVar3;
// NOTE: copy needed to match
iVar2 = param_1->entityData;
iVar3 = param_1->entityData;
sleepStatus = iVar2->sleepStatus;
if ((sleepStatus == SLEEP_STATUS_SLEEP) || (sleepStatus == SLEEP_STATUS_NAPPING) || (sleepStatus == SLEEP_STATUS_NIGHTMARE)) {
if ((iVar3->transformSpecies != 0xb9) || (iVar3->sleepStatusTurnsLeft != 0x7f)) {
return 5;
}
else
return 7;
}
else if (iVar3->chargingStatus == CHARGING_STATUS_BIDE) {
return 0xB;
}
return 0x7;
}
void sub_806CEFC(struct DungeonEntity *param_1, u32 newDir)
{
param_1->entityData->action.facingDir = newDir & DIRECTION_MASK;
sub_806CE68(param_1, (newDir & DIRECTION_MASK));
}
void sub_806CF18(struct DungeonEntity *param_1)
{
s32 iVar2;
struct DungeonEntityData *entityData;
if (EntityExists(param_1)) {
entityData = param_1->entityData;
for (iVar2 = 0; iVar2 < 100; iVar2++) {
sub_803E46C(0x21);
if (!sub_808DA44(entityData->transformSpecies, param_1->unk6B)) {
break;
}
}
}
}
u8 sub_806CF54(struct DungeonEntity *param_1)
{
return param_1->entityData->unk204;
}
void sub_806CF60(void)
{
struct DungeonEntity *uVar2;
s32 iVar3;
for(iVar3 = 0; iVar3 < DUNGEON_MAX_POKEMON; iVar3++)
{
uVar2 = gDungeonGlobalData->allPokemon[iVar3];
if (EntityExists(uVar2)) {
sub_806CF98(uVar2);
}
}
}
u32 sub_806CF98(struct DungeonEntity *param_1)
{
struct MapTile *mapTile;
u32 uVar3;
u16 tileType;
struct DungeonEntityData *entityData;
mapTile = GetMapTileForDungeonEntity_2(param_1);
tileType = mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
entityData = param_1->entityData;
uVar3 = GetShadowSize(entityData->transformSpecies);
if (tileType == (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) {
return 6;
}
if (tileType == TILE_TYPE_FLOOR) {
if (IsWaterTileset()) {
uVar3 = gUnknown_8106EEF[uVar3];
}
}
else if ((tileType == TILE_TYPE_LIQUID) && (gDungeonWaterType[gDungeonGlobalData->tileset] != DUNGEON_WATER_TYPE_LAVA))
uVar3 = gUnknown_8106EEF[uVar3];
entityData->unk204 = uVar3;
return uVar3;
}