code_8040094 decompiled

This commit is contained in:
DizzyEggg 2025-03-08 18:57:40 +01:00
parent f03e66dd33
commit 2c79110bad
4 changed files with 87 additions and 236 deletions

View File

@ -1,215 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_804151C
sub_804151C:
push {r4-r6,lr}
sub sp, 0x8
adds r6, r0, 0
adds r5, r1, 0
lsls r4, r2, 24
lsrs r4, 24
adds r0, r5, 0
bl sub_800DC9C
adds r3, r0, 0
lsls r3, 24
lsrs r3, 24
movs r0, 0x2
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
adds r0, r6, 0
adds r1, r5, 0
adds r2, r4, 0
bl sub_8041550
add sp, 0x8
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_804151C
thumb_func_start sub_8041550
sub_8041550:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x30
adds r7, r0, 0
mov r10, r1
ldr r0, [sp, 0x54]
lsls r2, 24
lsrs r2, 24
str r2, [sp, 0x2C]
lsls r3, 24
lsrs r3, 24
mov r9, r3
lsls r0, 24
lsrs r6, r0, 24
adds r0, r7, 0
bl EntityIsValid
lsls r0, 24
cmp r0, 0
beq _0804159C
ldr r0, [r7, 0x70]
mov r8, r0
adds r0, r7, 0
bl sub_8042768
lsls r0, 24
cmp r0, 0
beq _0804159C
cmp r6, 0
bne _080415A2
mov r0, r8
adds r0, 0xFF
ldrb r0, [r0]
cmp r0, 0x2
bne _080415A2
_0804159C:
movs r0, 0x1
negs r0, r0
b _08041692
_080415A2:
ldr r1, [sp, 0x50]
cmp r1, 0
beq _080415B4
movs r0, 0
cmp r1, 0x2
bne _080415B0
movs r0, 0x1
_080415B0:
bl sub_804178C
_080415B4:
add r6, sp, 0x28
adds r1, r7, 0
adds r1, 0x28
adds r0, r6, 0
mov r2, r9
bl sub_800569C
movs r2, 0
ldrsh r0, [r6, r2]
cmp r0, 0x63
beq _080415F2
ldrh r0, [r6, 0x2]
cmp r0, 0x63
beq _080415F2
movs r1, 0
ldrsh r0, [r6, r1]
lsls r0, 8
ldr r1, [r7, 0xC]
adds r4, r1, r0
movs r2, 0x2
ldrsh r0, [r6, r2]
lsls r0, 8
ldr r2, [r7, 0x10]
adds r0, r2, r0
movs r1, 0xBA
lsls r1, 1
add r1, r8
ldr r1, [r1]
subs r5, r0, r1
adds r1, r2, 0
b _08041600
_080415F2:
ldr r4, [r7, 0xC]
movs r0, 0xBA
lsls r0, 1
add r0, r8
ldr r1, [r7, 0x10]
ldr r0, [r0]
subs r5, r1, r0
_08041600:
cmp r1, 0
bge _08041606
adds r1, 0xFF
_08041606:
asrs r1, 8
ldr r0, _0804166C
ldr r0, [r0]
ldr r2, _08041670
adds r0, r2
movs r2, 0
ldrsh r0, [r0, r2]
subs r1, r0
lsrs r0, r1, 31
adds r0, r1, r0
asrs r1, r0, 1
adds r1, 0x1
mov r0, r10
str r0, [sp]
movs r3, 0
str r3, [sp, 0x4]
movs r6, 0x1
negs r6, r6
str r6, [sp, 0x8]
mov r2, sp
adds r0, r4, 0
cmp r4, 0
bge _08041636
adds r0, 0xFF
_08041636:
asrs r0, 8
strh r0, [r2, 0xC]
mov r2, sp
adds r0, r5, 0
cmp r0, 0
bge _08041644
adds r0, 0xFF
_08041644:
asrs r0, 8
strh r0, [r2, 0xE]
str r6, [sp, 0x14]
mov r0, sp
strh r3, [r0, 0x10]
strh r3, [r0, 0x12]
str r1, [sp, 0x18]
add r0, sp, 0x1C
bl sub_8004E8C
mov r0, sp
movs r1, 0
bl sub_8041764
adds r4, r0, 0
ldr r1, [sp, 0x2C]
cmp r1, 0
beq _08041690
movs r5, 0
b _0804167C
.align 2, 0
_0804166C: .4byte gDungeon
_08041670: .4byte 0x000181f2
_08041674:
movs r0, 0x42
bl sub_803E46C
adds r5, 0x1
_0804167C:
cmp r5, 0x63
bgt _0804168C
adds r0, r4, 0
bl sub_800E9A8
lsls r0, 24
cmp r0, 0
bne _08041674
_0804168C:
movs r4, 0x1
negs r4, r4
_08041690:
adds r0, r4, 0
_08041692:
add sp, 0x30
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8041550
.align 2,0

View File

@ -202,7 +202,6 @@ SECTIONS {
src/code_8040094.o(.text);
src/dungeon_map.o(.text);
src/code_8040094_1.o(.text);
asm/code_8040094.o(.text);
src/code_8041AD0.o(.text);
asm/code_8041AD0.o(.text);
src/code_804267C.o(.text);

View File

@ -35,7 +35,6 @@ extern void sub_803E46C(u32);
extern u8 sub_800EA44(s32 species, u16 a2);
extern s32 sub_800E790(s32 species, u16 a2);
extern void sub_806CDD4(Entity *entity, u8, u32 direction);
void sub_8041500(struct UnkStruct_8040094 *a0);
extern s32 sub_800E52C(struct UnkStruct_8040094 *a0);
extern s32 sub_800EA84(struct UnkStruct_8040094 *a0);
extern bool8 sub_800E838(struct UnkStruct_8040094 *a0, s32 a1);
@ -51,6 +50,7 @@ extern s32 sub_800ED20(u16 param_1);
extern u8 sub_800EC84(s32 param_1);
extern bool8 MoveMatchesBideClassStatus(Entity *pokemon, Move *move);
extern bool8 IsSleeping(Entity *pokemon);
extern void sub_80421C0(Entity *pokemon, u16);
extern u8 gUnknown_203B40D;
extern s16 gUnknown_2026E4E;
@ -61,13 +61,13 @@ extern const u8 *const gPtrMagnitudeMessage;
extern const s32 gUnknown_8106A8C[];
u16 sub_80412E0(u16 moveId, u8 weather, bool32 a2);
bool32 sub_804143C(Entity *entity, Move *move);
bool8 sub_80414C0(Entity *entity, Move *move);
bool8 sub_804141C(u16 moveId, u8 weather, bool32 a2);
void sub_8040C4C(Entity *entity, Move *move, bool32 a2);
void sub_8041038(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2);
void sub_8041108(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2);
void sub_80421C0(Entity *pokemon, u16);
static bool32 sub_804143C(Entity *entity, Move *move);
static bool8 sub_80414C0(Entity *entity, Move *move);
static bool8 sub_804141C(u16 moveId, u8 weather, bool32 a2);
static void sub_8040C4C(Entity *entity, Move *move, bool32 a2);
static void sub_8041038(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2);
static void sub_8041108(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2);
static void sub_8041500(struct UnkStruct_8040094 *a0);
bool8 sub_8040BB0(Entity *entity, Move *move, bool8 a2)
{
@ -88,7 +88,7 @@ bool8 sub_8040BB0(Entity *entity, Move *move, bool8 a2)
return r9;
}
void sub_8040C4C(Entity *entity, Move *move, bool32 a2)
static void sub_8040C4C(Entity *entity, Move *move, bool32 a2)
{
u8 savedUnkVar;
s32 r4;
@ -243,7 +243,7 @@ void sub_8040DA0(Entity *entity, Move *move)
}
}
void sub_8041038(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2)
static void sub_8041038(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2)
{
EntityInfo *entInfo = GetEntInfo(entity);
u16 var_24 = sub_80412E0(move->id, GetApparentWeather(entity), a2);
@ -270,7 +270,7 @@ void sub_8041038(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool3
}
}
void sub_8041108(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2)
static void sub_8041108(struct UnkStruct_8040094 *a0, Entity *entity, Move *move, bool32 a2)
{
u16 r4 = sub_80412E0(move->id, GetApparentWeather(entity), a2);
s32 var = sub_800ECB8(r4)->unk2;
@ -432,12 +432,12 @@ UNUSED static s32 sub_8041400(u16 moveId, u8 weather, bool32 a2)
return sub_800ED20(sub_80412E0(moveId, weather, a2));
}
bool8 sub_804141C(u16 moveId, u8 weather, bool32 a2)
static bool8 sub_804141C(u16 moveId, u8 weather, bool32 a2)
{
return sub_800EC84(sub_80412E0(moveId, weather, a2));
}
bool32 sub_804143C(Entity *entity, Move *move)
static bool32 sub_804143C(Entity *entity, Move *move)
{
if (move->id == MOVE_CURSE) {
if (EntityIsValid(entity) && GetEntityType(entity) == ENTITY_MONSTER) {
@ -461,7 +461,7 @@ bool32 sub_804143C(Entity *entity, Move *move)
return MoveMatchesBideClassStatus(entity, move) != FALSE;
}
bool8 sub_80414C0(Entity *entity, Move *move)
static bool8 sub_80414C0(Entity *entity, Move *move)
{
if (move->id == MOVE_DIVE) {
if (IsTileGround(GetTileAtEntitySafe(entity)))
@ -475,12 +475,10 @@ bool8 sub_80414C0(Entity *entity, Move *move)
return FALSE;
}
void sub_8041500(struct UnkStruct_8040094 *a0)
static void sub_8041500(struct UnkStruct_8040094 *a0)
{
if (sub_800E7D0(a0)) {
sub_803E46C(0x5C);
sub_8052740(0x5D);
}
}
//

View File

@ -32,12 +32,11 @@ extern u32 gStatusSpriteMasks_InvisibleClassStatus[];
extern u32 gStatusSpriteMasks_BlinkerClassStatus[];
extern u32 gStatusSpriteMasks_MuzzledStatus[];
extern void sub_803ED30(u8, Entity *pokemon, u8, u8);
extern void sub_804151C(Entity *pokemon, u32 r1, u8 r2);
extern u32 sub_806F62C(u32);
extern u32 sub_800DC9C(s32 a0);
extern void sub_800569C(DungeonPos *, axdata *, u8);
extern void PlaySoundEffect(u32);
extern void sub_8041550(Entity *pokemon, u32, u32, u32, u32, u32);
void EntityUpdateStatusSprites(Entity *entity);
@ -51,8 +50,78 @@ extern void sub_8042E98(void);
extern void sub_800EE5C(u32);
extern void sub_800EF64(void);
void sub_804178C(u8 param_1);
u32 sub_8041764(unkStruct_80416E0 *param_1, bool8 param_2);
s32 sub_80416E0(PixelPos *pos, u32 param_2, bool8 param_3);
s32 sub_8041550(Entity *entity, s32 a1, u8 a2, u8 a3, s32 a4, u8 a5);
s32 sub_804151C(Entity *entity, s32 r1, u8 r2)
{
u8 r3 = sub_800DC9C(r1);
return sub_8041550(entity, r1, r2, r3, 2, 0);
}
s32 sub_8041550(Entity *entity, s32 a1, u8 a2, u8 a3, s32 a4, u8 a5)
{
s32 i;
EntityInfo *entInfo;
DungeonPos pos;
unkStruct_80416E0 sp;
unkStruct_2039DB0 unkStruct;
PixelPos pixelPos;
s32 var;
s32 r4;
if (!EntityIsValid(entity))
return -1;
entInfo = GetEntInfo(entity);
if (!sub_8042768(entity))
return -1;
if (!a5 && entInfo->unkFF == 2)
return -1;
if (a4 != 0) {
sub_804178C(a4 == 2);
}
sub_800569C(&pos, &entity->axObj.axdata, a3);
if (pos.x != 99 && pos.y != 99) {
pixelPos.x = entity->pixelPos.x + (pos.x << 8);
pixelPos.y = (entity->pixelPos.y + (pos.y << 8)) - entInfo->unk174.raw;
}
else {
pixelPos.x = entity->pixelPos.x;
pixelPos.y = entity->pixelPos.y - entInfo->unk174.raw;
}
var = entity->pixelPos.y / 256;
var -= gDungeon->unk181e8.cameraPixelPos.y;
var /= 2;
var++;
sp.unk0 = a1;
sp.unk4 = 0;
sp.dir = -1;
sp.x = pixelPos.x / 256;
sp.y = pixelPos.y / 256;
sp.unk14 = -1;
sp.unk10 = 0;
sp.unk12 = 0;
sp.unk18 = var;
sub_8004E8C(&unkStruct);
r4 = sub_8041764(&sp, FALSE);
if (a2) {
for (i = 0; i < 100; i++) {
if (!sub_800E9A8(r4)) {
break;
}
sub_803E46C(0x42);
}
r4 = -1;
}
return r4;
}
s32 sub_80416A4(DungeonPos *pos_1, u32 param_2, bool8 param_3)
{