Decompile object96

This commit is contained in:
Tal Hayon 2022-03-16 14:04:58 +02:00
parent dc374ad503
commit c8547ffe35
5 changed files with 183 additions and 378 deletions

View File

@ -1,288 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start Object96
Object96: @ 0x0809D784
push {lr}
ldr r1, _0809D7A0 @ =gUnk_081240B0
ldrb r3, [r0, #0xc]
lsls r3, r3, #2
adds r3, r3, r1
ldrb r1, [r0, #0xa]
lsls r1, r1, #5
ldr r2, _0809D7A4 @ =gUnk_08123FB0
adds r1, r1, r2
ldr r2, [r3]
bl _call_via_r2
pop {pc}
.align 2, 0
_0809D7A0: .4byte gUnk_081240B0
_0809D7A4: .4byte gUnk_08123FB0
thumb_func_start sub_0809D7A8
sub_0809D7A8: @ 0x0809D7A8
push {r4, r5, lr}
adds r5, r0, #0
ldrb r0, [r5, #0xc]
adds r0, #1
movs r4, #0
strb r0, [r5, #0xc]
adds r2, r5, #0
adds r2, #0x38
movs r0, #2
strb r0, [r2]
ldrb r2, [r5, #0x19]
movs r0, #0x3f
ands r0, r2
movs r2, #0x40
orrs r0, r2
strb r0, [r5, #0x19]
ldr r0, [r1, #0x10]
str r0, [r5, #0x20]
ldrb r3, [r1, #0xf]
strb r3, [r5, #0x15]
ldrh r0, [r1, #0x18]
strh r0, [r5, #0x24]
ldrh r0, [r5, #0x32]
ldrh r2, [r1, #0x1a]
subs r0, r0, r2
strh r0, [r5, #0x32]
str r4, [r5, #0x34]
ldrb r0, [r1, #0x1e]
strb r0, [r5, #0xe]
movs r0, #0x80
ands r0, r3
cmp r0, #0
beq _0809D80C
ldrb r0, [r5, #0x15]
cmp r0, #0x81
bne _0809D80C
bl Random
ldr r1, _0809D820 @ =gPlayerEntity
ldrb r1, [r1, #0x14]
lsls r1, r1, #2
movs r2, #3
ands r0, r2
adds r1, r1, r0
subs r1, #2
movs r0, #0x1f
ands r1, r0
movs r0, #0x10
eors r1, r0
strb r1, [r5, #0x15]
_0809D80C:
adds r0, r5, #0
bl UpdateSpriteForCollisionLayer
ldrb r4, [r5, #0xa]
adds r0, r5, #0
bl sub_08080CB4
strb r4, [r5, #0xa]
pop {r4, r5, pc}
.align 2, 0
_0809D820: .4byte gPlayerEntity
thumb_func_start sub_0809D824
sub_0809D824: @ 0x0809D824
push {r4, r5, r6, lr}
adds r5, r0, #0
adds r6, r1, #0
movs r0, #1
ldr r2, [r6, #4]
cmp r2, #0
beq _0809D838
adds r0, r5, #0
bl _call_via_r2
_0809D838:
cmp r0, #0
beq _0809D850
ldrb r0, [r5, #0xc]
adds r0, #1
strb r0, [r5, #0xc]
ldrh r1, [r6, #0x1a]
ldrh r2, [r5, #0x32]
adds r0, r1, r2
strh r0, [r5, #0x32]
ldrh r0, [r5, #0x36]
subs r0, r0, r1
strh r0, [r5, #0x36]
_0809D850:
ldrb r4, [r5, #0xa]
ldrb r0, [r6, #0xd]
strb r0, [r5, #0xa]
adds r0, r5, #0
bl sub_08080CB4
strb r4, [r5, #0xa]
pop {r4, r5, r6, pc}
thumb_func_start sub_0809D860
sub_0809D860: @ 0x0809D860
push {r4, r5, r6, lr}
adds r5, r0, #0
adds r6, r1, #0
bl LinearMoveUpdate
ldr r1, [r6, #0x14]
adds r0, r5, #0
bl sub_080044EC
cmp r0, #1
bhi _0809D8B2
ldrb r0, [r5, #0xe]
cmp r0, #0
beq _0809D888
subs r0, #1
strb r0, [r5, #0xe]
ldr r0, [r6, #0x14]
lsls r0, r0, #3
str r0, [r5, #0x20]
b _0809D8AC
_0809D888:
ldrb r0, [r5, #0xc]
adds r0, #1
strb r0, [r5, #0xc]
ldr r0, _0809D8C4 @ =gPlayerEntity
adds r0, #0x38
ldrb r1, [r0]
adds r0, r5, #0
adds r0, #0x38
strb r1, [r0]
adds r0, r5, #0
bl UpdateSpriteForCollisionLayer
ldr r1, [r6]
cmp r1, #0
beq _0809D8AC
adds r0, r5, #0
bl _call_via_r1
_0809D8AC:
movs r0, #0x6e
bl SoundReq
_0809D8B2:
ldrb r4, [r5, #0xa]
ldrb r0, [r6, #0xd]
strb r0, [r5, #0xa]
adds r0, r5, #0
bl sub_08080CB4
strb r4, [r5, #0xa]
pop {r4, r5, r6, pc}
.align 2, 0
_0809D8C4: .4byte gPlayerEntity
thumb_func_start sub_0809D8C8
sub_0809D8C8: @ 0x0809D8C8
push {r4, r5, r6, lr}
adds r5, r0, #0
adds r6, r1, #0
ldr r0, _0809D8E4 @ =gPlayerState
ldr r0, [r0, #0x30]
movs r1, #0x80
ands r0, r1
cmp r0, #0
beq _0809D8E8
adds r0, r5, #0
bl sub_0800445C
b _0809D90A
.align 2, 0
_0809D8E4: .4byte gPlayerState
_0809D8E8:
adds r0, r5, #0
bl IsCollidingPlayer
cmp r0, #0
beq _0809D90A
ldrb r0, [r6, #0xd]
ldrb r1, [r5, #0xb]
movs r2, #0
bl CreateItemEntity
ldrh r0, [r6, #0x1c]
cmp r0, #0
beq _0809D906
bl SetFlag
_0809D906:
bl DeleteThisEntity
_0809D90A:
ldrb r4, [r5, #0xa]
ldrb r0, [r6, #0xd]
strb r0, [r5, #0xa]
adds r0, r5, #0
bl sub_08080CB4
strb r4, [r5, #0xa]
pop {r4, r5, r6, pc}
.align 2, 0
thumb_func_start sub_0809D91C
sub_0809D91C: @ 0x0809D91C
push {r4, lr}
adds r4, r0, #0
movs r1, #0x11
movs r2, #0
bl CreateFx
adds r1, r0, #0
cmp r1, #0
beq _0809D934
adds r0, r4, #0
bl SortEntityBelow
_0809D934:
movs r0, #0x72
bl SoundReq
pop {r4, pc}
thumb_func_start sub_0809D93C
sub_0809D93C: @ 0x0809D93C
push {r4, r5, lr}
adds r4, r0, #0
adds r3, r1, #0
ldr r2, _0809D9A0 @ =gPlayerEntity
ldrb r0, [r2, #0xc]
cmp r0, #6
bne _0809D9A4
ldrb r0, [r3, #0xc]
ldrb r1, [r2, #0x14]
asrs r0, r1
movs r1, #1
ands r0, r1
cmp r0, #0
beq _0809D9A4
movs r5, #0x2e
ldrsh r0, [r2, r5]
movs r5, #0x2e
ldrsh r1, [r4, r5]
subs r0, r0, r1
movs r1, #8
ldrsb r1, [r3, r1]
adds r0, r0, r1
ldrb r1, [r3, #0xa]
adds r0, r0, r1
lsls r1, r1, #1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r1, r0
ble _0809D9A4
movs r0, #0x32
ldrsh r2, [r2, r0]
movs r1, #0x32
ldrsh r0, [r4, r1]
movs r4, #0x1a
ldrsh r1, [r3, r4]
adds r0, r0, r1
subs r2, r2, r0
movs r0, #9
ldrsb r0, [r3, r0]
adds r2, r2, r0
ldrb r1, [r3, #0xb]
adds r0, r2, r1
lsls r1, r1, #1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r1, r0
ble _0809D9A4
movs r0, #1
b _0809D9A6
.align 2, 0
_0809D9A0: .4byte gPlayerEntity
_0809D9A4:
movs r0, #0
_0809D9A6:
pop {r4, r5, pc}

View File

@ -44743,11 +44743,6 @@
"size": 4,
"type": "animation"
},
{
"path": "object96/gUnk_08123FB0.bin",
"start": 1196172,
"size": 36
},
{
"path": "animations/gSpriteAnimations_Object98_0.bin",
"start": 1196436,

View File

@ -1,83 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_08123FB0:: @ 08123FB0
.4byte sub_0809D91C
.4byte sub_0809D93C
.4byte 0x30300000
.4byte 0x133c3c01
.4byte 0x00010000
.4byte 0x00001800
.4byte 0x00400060
.4byte 0x00014021
.4byte sub_0809D91C
.4byte 00000000
.4byte 00000000
.4byte 0x10636300
.4byte 00000000
.4byte 0x00001800
.4byte 0x00180000
.ifdef JP
.4byte 0x000000CD
.else
.ifdef DEMO_JP
.4byte 0x000000CD
.else
.ifdef EU
.4byte 0x000000CD @ TODO deduplicate
.else
.4byte 0x000000d0
.endif
.endif
.endif
.4byte sub_0809D91C
.4byte 00000000
.4byte 00000000
.4byte 0x0f3c3c00
.4byte 0x00010000
.4byte 0x00001800
.4byte 0x00400060
.4byte 0x00014021
.4byte sub_0809D91C
.4byte 00000000
.4byte 00000000
.4byte 0x023c3c00
.4byte 0x00010000
.4byte 0x00001800
.4byte 0x00400140
.4byte 0x00014021
.4byte sub_0809D91C
.4byte 00000000
.4byte 00000000
.4byte 0x0d3c3c00
.4byte 0x00010000
.4byte 0x00001800
.4byte 0x00400060
.4byte 0x00014021
.4byte sub_0809D91C
.4byte 00000000
.4byte 00000000
.4byte 0x1a3c3c00
.4byte 0x00010000
.4byte 0x00001800
.4byte 0x00400100
.4byte 0x00014021
.4byte sub_0809D91C
.4byte 00000000
.4byte 00000000
.4byte 0x133c3c00
.4byte 0x00010000
.4byte 0x00001800
.4byte 0x00400060
.incbin "object96/gUnk_08123FB0.bin"
gUnk_081240B0:: @ 081240B0
.4byte sub_0809D7A8
.4byte sub_0809D824
.4byte sub_0809D860
.4byte sub_0809D8C8

View File

@ -775,7 +775,7 @@ SECTIONS {
src/object/windTribeFlag.o(.text);
src/object/bird.o(.text);
asm/object/bird.o(.text);
asm/object/object96.o(.text);
src/object/object96.o(.text);
src/object/keyStealingTakkuri.o(.text);
asm/object/object98.o(.text);
asm/object/object99.o(.text);
@ -1526,7 +1526,7 @@ SECTIONS {
data/animations/object/lamp.o(.rodata);
data/const/object/bird.o(.rodata);
data/animations/object/bird.o(.rodata);
data/const/object/object96.o(.rodata);
src/object/object96.o(.rodata);
src/object/keyStealingTakkuri.o(.rodata);
data/const/object/object98.o(.rodata);
data/animations/object/object98.o(.rodata);

181
src/object/object96.c Normal file
View File

@ -0,0 +1,181 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "asm.h"
#include "functions.h"
#include "sound.h"
#include "item.h"
#include "flags.h"
#include "effects.h"
typedef struct _struct_gUnk_08123FB0 {
void (*const funcEnt)(Entity*);
bool32 (*const func)(Entity*, const struct _struct_gUnk_08123FB0*);
s8 unk08;
s8 unk09;
u8 unk0a;
u8 unk0b;
u8 unk0c;
u8 type;
u8 unk0e;
u8 unk0f;
s32 zVelocity;
u32 unk14;
s16 speed;
s16 y;
u16 flag;
u8 actionDelay;
u8 unk1f;
} struct_gUnk_08123FB0;
static_assert(sizeof(struct_gUnk_08123FB0) == 0x20);
void sub_0809D91C(Entity*);
bool32 sub_0809D93C(Entity*, const struct_gUnk_08123FB0*);
void Object96_Init(Entity*, const struct_gUnk_08123FB0*);
void Object96_Action1(Entity*, const struct_gUnk_08123FB0*);
void Object96_Action2(Entity*, const struct_gUnk_08123FB0*);
void Object96_Action3(Entity*, const struct_gUnk_08123FB0*);
static const struct_gUnk_08123FB0 gUnk_08123FB0[] = {
{ sub_0809D91C, sub_0809D93C, 0, 0, 0x30, 0x30, 0x1, 0x3c, 0x3c, 0x13, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1,
0x0 },
{ sub_0809D91C, NULL, 0, 0, 0, 0, 0, 0x63, 0x63, 0x10, 0, 0x1800, 0, 0x18,
#if defined(JP) || defined(DEMO_JP) || defined(EU)
0xCD,
#else
0xd0,
#endif
0, 0 },
{ sub_0809D91C, NULL, 0, 0, 0, 0, 0, 0x3c, 0x3c, 0xf, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1, 0x0 },
{ sub_0809D91C, NULL, 0, 0, 0, 0, 0, 0x3c, 0x3c, 0x2, 0x10000, 0x1800, 0x140, 0x40, 0x4021, 0x1, 0x0 },
{ sub_0809D91C, NULL, 0, 0, 0, 0, 0x0, 0x3c, 0x3c, 0xd, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1, 0x0 },
{ sub_0809D91C, NULL, 0, 0, 0, 0, 0x0, 0x3c, 0x3c, 0x1a, 0x10000, 0x1800, 0x100, 0x40, 0x4021, 0x1, 0x0 },
{ sub_0809D91C, NULL, 0, 0, 0, 0, 0x0, 0x3c, 0x3c, 0x13, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1, 0x0 },
{ NULL, NULL, 0, 0, 0, 0, 0x0, 0x5c, 0x5c, 0x81, 0, 0x1800, 0x100, 0x20, 0x0, 0x1, 0x0 },
};
void Object96(Entity* this) {
static void (*const actionFuncs[])(Entity*, const struct_gUnk_08123FB0*) = {
Object96_Init,
Object96_Action1,
Object96_Action2,
Object96_Action3,
};
actionFuncs[this->action](this, &gUnk_08123FB0[this->type]);
}
void Object96_Init(Entity* this, const struct_gUnk_08123FB0* param_2) {
u32 type;
u32 dir;
this->action++;
this->collisionLayer = 2;
this->spriteRendering.b3 = 1;
this->zVelocity = param_2->zVelocity;
this->direction = param_2->unk0f;
this->speed = param_2->speed;
this->y.HALF.HI -= param_2->y;
this->z.WORD = 0;
this->actionDelay = param_2->actionDelay;
if ((this->direction & 0x80)) {
dir = this->direction;
if (dir == 0x81) {
this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ 0x10;
}
}
UpdateSpriteForCollisionLayer(this);
type = this->type;
sub_08080CB4(this);
this->type = type;
}
void Object96_Action1(Entity* this, const struct_gUnk_08123FB0* param_2) {
u32 type;
s32 iVar3;
iVar3 = 1;
if (param_2->func != NULL) {
iVar3 = param_2->func(this, param_2);
}
if (iVar3 != 0) {
this->action++;
this->y.HALF.HI += param_2->y;
this->z.HALF.HI -= param_2->y;
}
type = this->type;
this->type = param_2->type;
sub_08080CB4(this);
this->type = type;
}
void Object96_Action2(Entity* this, const struct_gUnk_08123FB0* param_2) {
u8 type;
LinearMoveUpdate(this);
if (sub_080044EC(this, param_2->unk14) < 2) {
if (this->actionDelay) {
this->actionDelay--;
this->zVelocity = param_2->unk14 << 3;
} else {
this->action++;
this->collisionLayer = gPlayerEntity.collisionLayer;
UpdateSpriteForCollisionLayer(this);
if (param_2->funcEnt != NULL) {
param_2->funcEnt(this);
}
}
SoundReq(SFX_RUPEE_BOUNCE);
}
type = this->type;
this->type = param_2->type;
sub_08080CB4(this);
this->type = type;
}
void Object96_Action3(Entity* this, const struct_gUnk_08123FB0* param_2) {
u8 type;
if (gPlayerState.flags & 0x80) {
sub_0800445C(this);
} else {
if (IsCollidingPlayer(this)) {
CreateItemEntity(param_2->type, this->type2, 0);
if (param_2->flag) {
SetFlag(param_2->flag);
}
DeleteThisEntity();
}
}
type = this->type;
this->type = param_2->type;
sub_08080CB4(this);
this->type = type;
}
void sub_0809D91C(Entity* this) {
Entity* fxEnt;
fxEnt = CreateFx(this, FX_DASH, 0);
if (fxEnt != NULL) {
SortEntityBelow(this, fxEnt);
}
SoundReq(SFX_SECRET);
}
bool32 sub_0809D93C(Entity* this, const struct_gUnk_08123FB0* param_2) {
u32 uVar1;
if (gPlayerEntity.action == 6 && ((param_2->unk0c >> gPlayerEntity.animationState & 1) != 0)) {
uVar1 = (gPlayerEntity.x.HALF.HI - this->x.HALF.HI) + param_2->unk08 + param_2->unk0a;
if (param_2->unk0a * 2 <= (u16)uVar1) {
return 0;
}
uVar1 = (gPlayerEntity.y.HALF.HI - (this->y.HALF.HI + param_2->y)) + param_2->unk09 + param_2->unk0b;
if (param_2->unk0b * 2 > (u16)uVar1) {
return 1;
}
}
return 0;
}