Decompile a few functions in objectutils

This commit is contained in:
Tal Hayon 2022-02-27 05:56:38 +02:00
parent 4e10e89cca
commit 640810a005
9 changed files with 53 additions and 78 deletions

View File

@ -5113,7 +5113,7 @@ _0807AEA8:
bne _0807AEDE
adds r0, r4, #0
movs r1, #4
bl sub_080A2A84
bl CreateRandomWaterTrace
b _0807AEDE
.align 2, 0
_0807AEC8: .4byte gRoomTransition

View File

@ -288,7 +288,7 @@ _08085808:
cmp r0, #0
bne _0808581A
adds r0, r7, #0
bl sub_080A2AD4
bl CreateLargeWaterTrace
_0808581A:
ldr r0, [r7, #0x2c]
ldr r1, [r7, #0x6c]

View File

@ -63,7 +63,7 @@ sub_0808BE2C: @ 0x0808BE2C
adds r0, r2, #0
movs r1, #0x58
movs r2, #0
bl sub_080A2A20
bl CreateGroundItem
adds r1, r0, #0
cmp r1, #0
beq _0808BE6C

View File

@ -5,66 +5,7 @@
.text
thumb_func_start sub_080A2A84
sub_080A2A84: @ 0x080A2A84
push {r4, r5, r6, r7, lr}
adds r5, r1, #0
bl CreateWaterTrace
adds r6, r0, #0
cmp r6, #0
beq _080A2AD2
bl Random
adds r4, r0, #0
adds r5, #1
adds r1, r5, #0
bl __modsi3
adds r1, r0, #0
lsrs r4, r4, #8
movs r7, #1
adds r0, r4, #0
ands r0, r7
cmp r0, #0
beq _080A2AB0
rsbs r1, r1, #0
_080A2AB0:
ldrh r0, [r6, #0x2e]
adds r0, r0, r1
strh r0, [r6, #0x2e]
lsrs r4, r4, #8
adds r0, r4, #0
adds r1, r5, #0
bl __modsi3
adds r1, r0, #0
lsrs r4, r4, #8
ands r4, r7
cmp r4, #0
beq _080A2ACC
rsbs r1, r1, #0
_080A2ACC:
ldrh r0, [r6, #0x32]
adds r0, r0, r1
strh r0, [r6, #0x32]
_080A2AD2:
pop {r4, r5, r6, r7, pc}
thumb_func_start sub_080A2AD4
sub_080A2AD4: @ 0x080A2AD4
push {lr}
movs r1, #0x21
movs r2, #0
bl CreateFx
adds r2, r0, #0
cmp r2, #0
beq _080A2AF0
adds r3, r2, #0
adds r3, #0x29
ldrb r0, [r3]
movs r1, #7
orrs r0, r1
strb r0, [r3]
_080A2AF0:
adds r0, r2, #0
pop {pc}
thumb_func_start sub_080A2AF4
sub_080A2AF4: @ 0x080A2AF4
@ -73,7 +14,7 @@ sub_080A2AF4: @ 0x080A2AF4
push {r7}
adds r5, r1, #0
adds r4, r2, #0
bl sub_080A2AD4
bl CreateLargeWaterTrace
adds r6, r0, #0
cmp r6, #0
beq _080A2B74

View File

@ -198,9 +198,9 @@ extern void sub_0809EABC(Entity*);
extern void sub_0809EAD8(Entity*);
extern void sub_0809EB30(Entity*);
extern void sub_080A1ED0(u32, u32, u32);
extern Entity* sub_080A2A20(Entity*, u32, u32);
extern Entity* sub_080A2A3C(Entity*, u32, u32, u32);
extern Entity* sub_080A2AD4(Entity*);
extern Entity* CreateGroundItem(Entity*, u32, u32);
extern Entity* CreateGroundItemWithFlags(Entity*, u32, u32, u32);
extern Entity* CreateLargeWaterTrace(Entity*);
extern void sub_080A2AF4(Entity*, u32, u32);
extern void sub_080A2CC0(Entity*, Entity**, u16*);
extern void sub_080A57F4(void);

View File

@ -91,7 +91,7 @@ void BigIceBlock_Action2(BigIceBlockEntity* this) {
if (super->type != 2) {
SetFlag(this->unk_86);
} else {
sub_080A2A3C(super, 0x53, 0, this->unk_86);
CreateGroundItemWithFlags(super, 0x53, 0, this->unk_86);
}
}
super->action = 3;

View File

@ -66,7 +66,7 @@ void sub_08094774(Object68Entity* this) {
}
break;
case 2:
child = sub_080A2A20(&gPlayerEntity, 0x60, 0);
child = CreateGroundItem(&gPlayerEntity, 0x60, 0);
super->child = child;
if (child != NULL) {
child->actionDelay = 1;

View File

@ -138,10 +138,10 @@ void SmallIceBlock_Action3(SmallIceBlockEntity* this) {
}
sub_0805EC9C(super, 0x100, gUnk_08123748[super->actionDelay >> 5], 0);
if (super->type == 1) {
sub_080A2A3C(super, 0x53, 0, this->unk_86);
CreateGroundItemWithFlags(super, 0x53, 0, this->unk_86);
SoundReq(SFX_SECRET);
} else if (super->type == 2) {
sub_080A2A3C(super, 0x52, 0, this->unk_86);
CreateGroundItemWithFlags(super, 0x52, 0, this->unk_86);
SoundReq(SFX_SECRET);
}
super->action = 4;

View File

@ -97,20 +97,20 @@ u32 LoadObjectSprite(Entity* this, s32 type, const ObjectDefinition* definition)
return 2;
}
Entity* CreateObject(u32 subtype, u32 form, u32 parameter) {
Entity* CreateObject(u32 subtype, u32 form, u32 type2) {
Entity* entity = GetEmptyEntity();
if (entity != NULL) {
entity->kind = OBJECT;
entity->id = subtype;
entity->type = form;
entity->type2 = parameter;
entity->type2 = type2;
AppendEntityToList(entity, 6);
}
return entity;
}
Entity* CreateObjectWithParent(Entity* parent, u32 subtype, u32 form, u32 parameter) {
Entity* entity = CreateObject(subtype, form, parameter);
Entity* CreateObjectWithParent(Entity* parent, u32 subtype, u32 form, u32 type2) {
Entity* entity = CreateObject(subtype, form, type2);
if (entity != NULL) {
entity->parent = parent;
CopyPosition(parent, entity);
@ -150,23 +150,23 @@ void CreateWaterSplash(Entity* parent) {
CreateFx(parent, FX_WATER_SPLASH, 0);
}
Entity* sub_080A2A20(Entity* parent, u32 form, u32 parameter) {
Entity* CreateGroundItem(Entity* parent, u32 form, u32 subtype) {
Entity* ent;
ent = CreateObjectWithParent(parent, GROUND_ITEM, form, parameter);
ent = CreateObjectWithParent(parent, GROUND_ITEM, form, subtype);
if (ent != NULL) {
ent->actionDelay = 5;
}
return ent;
}
Entity* sub_080A2A3C(Entity* parent, u32 form, u32 subtype, u32 param_4) {
Entity* CreateGroundItemWithFlags(Entity* parent, u32 form, u32 subtype, u32 flags) {
Entity* ent;
ent = CreateObjectWithParent(parent, GROUND_ITEM, form, subtype);
if (ent != NULL) {
ent->actionDelay = 5;
ent->field_0x86.HWORD = param_4;
ent->field_0x86.HWORD = flags;
}
return ent;
}
@ -180,3 +180,37 @@ Entity* CreateWaterTrace(Entity* parent) {
}
return ent;
}
void CreateRandomWaterTrace(Entity* parent, int range) {
s32 sVar1, sVar2, sVar3;
Entity* ent;
u32 uVar3;
ent = CreateWaterTrace(parent);
if (ent != NULL) {
uVar3 = Random();
sVar1 = (int)uVar3 % (++range);
uVar3 >>= 8;
if ((uVar3 & 1) != 0) {
sVar1 = -sVar1;
}
ent->x.HALF.HI += sVar1;
uVar3 >>= 8;
sVar2 = (int)uVar3 % range;
uVar3 >>= 8;
if ((uVar3 & 1) != 0) {
sVar2 = -sVar2;
}
ent->y.HALF.HI += sVar2;
}
}
Entity* CreateLargeWaterTrace(Entity* parent) {
Entity* ent;
ent = CreateFx(parent, FX_RIPPLE_LARGE, 0);
if (ent != NULL) {
ent->spritePriority.b0 = 7;
}
return ent;
}